Skip to content

Commit 3d0b07b

Browse files
committed
refactor: formatting
1 parent a60b12a commit 3d0b07b

10 files changed

Lines changed: 29 additions & 42 deletions

File tree

src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<Compile Include="Matrix\CSR\Map2.fs" />
5353
<Compile Include="Matrix\CSR\Map2AtLeastOne.fs" />
5454
<Compile Include="Matrix\CSR\Matrix.fs" />
55-
<Compile Include="Matrix\Rows\Matrix.fs" />
55+
<Compile Include="Matrix\LIL\Matrix.fs" />
5656
<Compile Include="Matrix\SpGeMM\Expand.fs" />
5757
<Compile Include="Matrix\SpGeMM\Masked.fs" />
5858
<Compile Include="Matrix\Matrix.fs" />

src/GraphBLAS-sharp.Backend/Matrix/CSR/Matrix.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module Matrix =
149149
|> Seq.map (fun lazyValue -> lazyValue.Value)
150150
|> Seq.toArray
151151

152-
let toRows (clContext: ClContext) workGroupSize =
152+
let toLIL (clContext: ClContext) workGroupSize =
153153

154154
let byRows = byRows clContext workGroupSize
155155

src/GraphBLAS-sharp.Backend/Matrix/Rows/Matrix.fs renamed to src/GraphBLAS-sharp.Backend/Matrix/LIL/Matrix.fs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
namespace GraphBLAS.FSharp.Backend.Matrix.Rows
1+
namespace GraphBLAS.FSharp.Backend.Matrix.LIL
22

33
open Brahma.FSharp
44
open GraphBLAS.FSharp.Backend.Common
5-
open GraphBLAS.FSharp.Backend.Matrix
6-
open GraphBLAS.FSharp.Backend.Objects
7-
open GraphBLAS.FSharp.Backend
85
open GraphBLAS.FSharp.Backend.Objects.ClContext
96
open GraphBLAS.FSharp.Backend.Objects.ClMatrix
10-
open GraphBLAS.FSharp.Backend.Quotes
11-
open FSharp.Quotations.Evaluator
127

138
module Matrix =
149
let toCSR (clContext: ClContext) workGroupSize =

src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ module Matrix =
7171
let transpose =
7272
CSR.Matrix.transpose clContext workGroupSize
7373

74-
let rowsToCSR =
75-
Rows.Matrix.toCSR clContext workGroupSize
74+
let rowsToCSR = LIL.Matrix.toCSR clContext workGroupSize
7675

7776
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix<'a>) ->
7877
match matrix with
@@ -124,8 +123,7 @@ module Matrix =
124123
let transposeInPlace =
125124
COO.Matrix.transposeInPlace clContext workGroupSize
126125

127-
let rowsToCSR =
128-
Rows.Matrix.toCSR clContext workGroupSize
126+
let rowsToCSR = LIL.Matrix.toCSR clContext workGroupSize
129127

130128
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix<'a>) ->
131129
match matrix with
@@ -183,8 +181,7 @@ module Matrix =
183181
let transposeCOO =
184182
COO.Matrix.transpose clContext workGroupSize
185183

186-
let rowsToCSR =
187-
Rows.Matrix.toCSR clContext workGroupSize
184+
let rowsToCSR = LIL.Matrix.toCSR clContext workGroupSize
188185

189186
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix<'a>) ->
190187
match matrix with
@@ -233,7 +230,7 @@ module Matrix =
233230
|> ClMatrix.CSC
234231
| _ -> failwith "Not yet implemented"
235232

236-
let toRows (clContext: ClContext) workGroupSize =
233+
let toLIL (clContext: ClContext) workGroupSize =
237234

238235
let copy = copy clContext workGroupSize
239236

@@ -242,22 +239,21 @@ module Matrix =
242239
let transposeCSR =
243240
CSR.Matrix.transposeInPlace clContext workGroupSize
244241

245-
let CSRToRows =
246-
CSR.Matrix.toRows clContext workGroupSize
242+
let CSRToLIL = CSR.Matrix.toLIL clContext workGroupSize
247243

248244
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix<'a>) ->
249245
match matrix with
250246
| ClMatrix.CSC m ->
251247
m.ToCSR
252248
|> transposeCSR processor allocationMode
253-
|> CSRToRows processor allocationMode
249+
|> CSRToLIL processor allocationMode
254250
|> ClMatrix.LIL
255251
| ClMatrix.CSR m ->
256-
CSRToRows processor allocationMode m
252+
CSRToLIL processor allocationMode m
257253
|> ClMatrix.LIL
258254
| ClMatrix.COO m ->
259255
COOToCSR processor allocationMode m
260-
|> CSRToRows processor allocationMode
256+
|> CSRToLIL processor allocationMode
261257
|> ClMatrix.LIL
262258
| ClMatrix.LIL _ -> copy processor allocationMode matrix
263259

src/GraphBLAS-sharp/Objects/Matrix.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module Matrix =
135135
ColumnPointers = context.CreateClArray this.ColumnPointers
136136
Values = context.CreateClArray this.Values }
137137

138-
type Rows<'a when 'a: struct> =
138+
type LIL<'a when 'a: struct> =
139139
{ RowCount: int
140140
ColumnCount: int
141141
Rows: Vector.Sparse<'a> option []
@@ -184,32 +184,32 @@ type Matrix<'a when 'a: struct> =
184184
| CSR of Matrix.CSR<'a>
185185
| COO of Matrix.COO<'a>
186186
| CSC of Matrix.CSC<'a>
187-
| Rows of Matrix.Rows<'a>
187+
| LIL of Matrix.LIL<'a>
188188

189189
member this.RowCount =
190190
match this with
191191
| CSR matrix -> matrix.RowCount
192192
| COO matrix -> matrix.RowCount
193193
| CSC matrix -> matrix.RowCount
194-
| Rows matrix -> matrix.RowCount
194+
| LIL matrix -> matrix.RowCount
195195

196196
member this.ColumnCount =
197197
match this with
198198
| CSR matrix -> matrix.ColumnCount
199199
| COO matrix -> matrix.ColumnCount
200200
| CSC matrix -> matrix.ColumnCount
201-
| Rows matrix -> matrix.ColumnCount
201+
| LIL matrix -> matrix.ColumnCount
202202

203203
member this.NNZ =
204204
match this with
205205
| COO m -> m.NNZ
206206
| CSR m -> m.NNZ
207207
| CSC m -> m.NNZ
208-
| Rows m -> m.NNZ
208+
| LIL m -> m.NNZ
209209

210210
member this.ToDevice(context: ClContext) =
211211
match this with
212212
| COO matrix -> ClMatrix.COO <| matrix.ToDevice context
213213
| CSR matrix -> ClMatrix.CSR <| matrix.ToDevice context
214214
| CSC matrix -> ClMatrix.CSC <| matrix.ToDevice context
215-
| Rows matrix -> ClMatrix.LIL <| matrix.ToDevice context
215+
| LIL matrix -> ClMatrix.LIL <| matrix.ToDevice context

src/GraphBLAS-sharp/Objects/MatrixExtensions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module MatrixExtensions =
3838
m.Rows
3939
|> Array.map (Option.bind (fun row -> Some <| row.ToHost q))
4040
NNZ = m.NNZ }
41-
|> Matrix.Rows
41+
|> Matrix.LIL
4242

4343
member this.ToHostAndDispose(processor: MailboxProcessor<_>) =
4444
let result = this.ToHost processor

tests/GraphBLAS-sharp.Tests/Helpers.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ module Utils =
6464
Matrix.CSC
6565
<| Matrix.CSC.FromArray2D(array, isZero)
6666
| LIL ->
67-
Matrix.Rows
68-
<| Matrix.Rows.FromArray2D(array, isZero)
67+
Matrix.LIL
68+
<| Matrix.LIL.FromArray2D(array, isZero)
6969

7070
let createVectorFromArray vectorCase array isZero =
7171
match vectorCase with
@@ -130,7 +130,7 @@ module Utils =
130130
"Indices must be the same"
131131
|> compareArrays (=) actual.Indices expected.Indices
132132

133-
let compareLILMatrix isEqual (actual: Matrix.Rows<'a>) (expected: Matrix.Rows<'a>) =
133+
let compareLILMatrix isEqual (actual: Matrix.LIL<'a>) (expected: Matrix.LIL<'a>) =
134134
"Column count must be the same"
135135
|> Expect.equal actual.ColumnCount expected.ColumnCount
136136

tests/GraphBLAS-sharp.Tests/Matrix/Convert.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ let testFixtures formatTo =
7070
[ createTest<int> Matrix.toCSC formatTo ((=) 0)
7171
createTest<bool> Matrix.toCSC formatTo ((=) false) ]
7272
| LIL ->
73-
[ createTest<int> Matrix.toRows formatTo ((=) 0)
74-
createTest<bool> Matrix.toRows formatTo ((=) false) ]
73+
[ createTest<int> Matrix.toLIL formatTo ((=) 0)
74+
createTest<bool> Matrix.toLIL formatTo ((=) false) ]
7575
|> List.concat
7676
|> testList $"%A{formatTo}"
7777

tests/GraphBLAS-sharp.Tests/Matrix/SpGeMM/Expand.fs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ let makeTest isZero testFun (leftArray: 'a [], rightArray: 'a [,]) =
4545
|> Array.map (fun (fst, snd) -> snd - fst)
4646

4747
let expectedPointers, expectedLength =
48-
Array.init
49-
leftMatrixRow.Indices.Length
50-
(fun index -> rightMatrixRowsLength.[leftMatrixRow.Indices [ index ]])
48+
Array.init leftMatrixRow.Indices.Length (fun index -> rightMatrixRowsLength.[leftMatrixRow.Indices.[index]])
5149
|> HostPrimitives.prefixSumExclude 0 (+)
5250

5351
let clLeftMatrixRow = leftMatrixRow.ToDevice context
@@ -134,7 +132,7 @@ let makeExpandTest isEqual zero testFun (leftArray: 'a [], rightArray: 'a [,]) =
134132
|> fun rightMatrixRowsLengths ->
135133
Array.init
136134
leftMatrixRow.Indices.Length
137-
(fun index -> rightMatrixRowsLengths.[leftMatrixRow.Indices [ index ]])
135+
(fun index -> rightMatrixRowsLengths.[leftMatrixRow.Indices.[index]])
138136
|> HostPrimitives.prefixSumExclude 0 (+)
139137
|> fun (pointers, length) -> context.CreateClArray(pointers), length
140138

@@ -213,9 +211,9 @@ let makeGeneralTest<'a when 'a: struct> zero isEqual opMul opAdd testFun (leftAr
213211
clMatrixActual.ToHostAndDispose processor
214212

215213
match matrixActual with
216-
| Matrix.Rows actual ->
214+
| Matrix.LIL actual ->
217215
HostPrimitives.array2DMultiplication zero opMul opAdd leftArray rightArray
218-
|> fun array -> Matrix.Rows.FromArray2D(array, (isEqual zero))
216+
|> fun array -> Matrix.LIL.FromArray2D(array, (isEqual zero))
219217
|> Utils.compareLILMatrix isEqual actual
220218
| _ -> failwith "Matrix format are not matching"
221219

@@ -225,7 +223,7 @@ let createGeneralTest (zero: 'a) isEqual (opAddQ, opAdd) (opMulQ, opMul) testFun
225223
|> testPropertyWithConfig config $"test on %A{typeof<'a>}"
226224

227225
let generalTests =
228-
[ //createGeneralTest 0 (=) ArithmeticOperations.intAdd ArithmeticOperations.intMul Matrix.SpGeMM.expand
226+
[ createGeneralTest 0 (=) ArithmeticOperations.intAdd ArithmeticOperations.intMul Matrix.SpGeMM.expand
229227

230228
if Utils.isFloat64Available context.ClDevice then
231229
createGeneralTest

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ let commonTests =
2929
let reduceTests =
3030
testList
3131
"Reduce"
32-
[ Common.Reduce.ByKey.sequentialTest
33-
Common.Reduce.ByKey.sequentialSegmentTests
34-
Common.Reduce.ByKey.oneWorkGroupTest
32+
[ Common.Reduce.ByKey.allTests
3533
Common.Reduce.Reduce.tests
3634
Common.Reduce.Sum.tests ]
3735

0 commit comments

Comments
 (0)