@@ -81,8 +81,7 @@ module CSRMatrix =
8181
8282 let eWiseAdd ( clContext : ClContext ) ( opAdd : Expr < 'a option -> 'b option -> 'c option >) workGroupSize =
8383
84- let toCOOInplaceLeft = toCOOInplace clContext workGroupSize
85- let toCOOInplaceRight = toCOOInplace clContext workGroupSize
84+ let prepareRows = prepareRows clContext workGroupSize
8685
8786 let eWiseCOO =
8887 COOMatrix.eWiseAdd clContext opAdd workGroupSize
@@ -91,24 +90,32 @@ module CSRMatrix =
9190 COOMatrix.toCSRInplace clContext workGroupSize
9291
9392 fun ( processor : MailboxProcessor < _ >) ( m1 : CSRMatrix < 'a >) ( m2 : CSRMatrix < 'b >) ->
94-
95- let m1COO = toCOOInplaceLeft processor m1
96- let m2COO = toCOOInplaceRight processor m2
93+ let m1COO =
94+ { Context = clContext
95+ RowCount = m1.RowCount
96+ ColumnCount = m1.ColumnCount
97+ Rows = prepareRows processor m1.RowPointers m1.Values.Length m1.RowCount
98+ Columns = m1.Columns
99+ Values = m1.Values }
100+
101+ let m2COO =
102+ { Context = clContext
103+ RowCount = m2.RowCount
104+ ColumnCount = m2.ColumnCount
105+ Rows = prepareRows processor m2.RowPointers m2.Values.Length m2.RowCount
106+ Columns = m2.Columns
107+ Values = m2.Values }
97108
98109 let m3COO = eWiseCOO processor m1COO m2COO
99110
100111 processor.Post( Msg.CreateFreeMsg( m1COO.Rows))
101112 processor.Post( Msg.CreateFreeMsg( m2COO.Rows))
102113
103- let m3 = toCSRInplace processor m3COO
104- processor.Post( Msg.CreateFreeMsg( m3COO.Rows))
105-
106- m3
114+ toCSRInplace processor m3COO
107115
108116 let eWiseAddAtLeastOne ( clContext : ClContext ) ( opAdd : Expr < AtLeastOne < 'a , 'b > -> 'c option >) workGroupSize =
109117
110- let toCOOInplaceLeft = toCOOInplace clContext workGroupSize
111- let toCOOInplaceRight = toCOOInplace clContext workGroupSize
118+ let prepareRows = prepareRows clContext workGroupSize
112119
113120 let eWiseCOO =
114121 COOMatrix.eWiseAddAtLeastOne clContext opAdd workGroupSize
@@ -117,19 +124,28 @@ module CSRMatrix =
117124 COOMatrix.toCSRInplace clContext workGroupSize
118125
119126 fun ( processor : MailboxProcessor < _ >) ( m1 : CSRMatrix < 'a >) ( m2 : CSRMatrix < 'b >) ->
120-
121- let m1COO = toCOOInplaceLeft processor m1
122- let m2COO = toCOOInplaceRight processor m2
127+ let m1COO =
128+ { Context = clContext
129+ RowCount = m1.RowCount
130+ ColumnCount = m1.ColumnCount
131+ Rows = prepareRows processor m1.RowPointers m1.Values.Length m1.RowCount
132+ Columns = m1.Columns
133+ Values = m1.Values }
134+
135+ let m2COO =
136+ { Context = clContext
137+ RowCount = m2.RowCount
138+ ColumnCount = m2.ColumnCount
139+ Rows = prepareRows processor m2.RowPointers m2.Values.Length m2.RowCount
140+ Columns = m2.Columns
141+ Values = m2.Values }
123142
124143 let m3COO = eWiseCOO processor m1COO m2COO
125144
126145 processor.Post( Msg.CreateFreeMsg( m1COO.Rows))
127146 processor.Post( Msg.CreateFreeMsg( m2COO.Rows))
128147
129- let m3 = toCSRInplace processor m3COO
130- processor.Post( Msg.CreateFreeMsg( m3COO.Rows))
131-
132- m3
148+ toCSRInplace processor m3COO
133149
134150 let transposeInplace ( clContext : ClContext ) workGroupSize =
135151
0 commit comments