@@ -22,6 +22,7 @@ let wgSize = Constants.Common.defaultWorkGroupSize
22
22
let makeTest
23
23
formatFrom
24
24
( convertFun : RawCommandQueue -> AllocationFlag -> ClVector < 'a > -> ClVector < 'a >)
25
+ ( convertFunUnsorted : option < RawCommandQueue -> AllocationFlag -> ClVector < 'a > -> ClVector < 'a >>)
25
26
isZero
26
27
case
27
28
( array : 'a [])
@@ -37,7 +38,7 @@ let makeTest
37
38
38
39
let actual =
39
40
let clVector = vector.ToDevice context
40
- let convertedVector = convertFun q HostInterop clVector
41
+ let convertedVector = convertFun q DeviceOnly clVector
41
42
42
43
let res = convertedVector.ToHost q
43
44
@@ -56,6 +57,27 @@ let makeTest
56
57
57
58
Expect.equal actual expected " Vectors must be the same"
58
59
60
+ match convertFunUnsorted with
61
+ | None -> ()
62
+ | Some convertFunUnsorted ->
63
+ let clVector = vector.ToDevice context
64
+ let convertedVector = convertFunUnsorted q DeviceOnly clVector
65
+
66
+ let res = convertedVector.ToHost q
67
+
68
+ match res, expected with
69
+ | Vector.Sparse res, Vector.Sparse expected ->
70
+ let iv = Array.zip res.Indices res.Values
71
+ let resSorted = Array.sortBy ( fun ( i , v ) -> i) iv
72
+ let indices , values = Array.unzip resSorted
73
+ Expect.equal indices expected.Indices " Indices must be the same"
74
+ Expect.equal values expected.Values " Values must be the same"
75
+ Expect.equal res.Size expected.Size " Size must be the same"
76
+ | _ -> ()
77
+
78
+ clVector.Dispose()
79
+ convertedVector.Dispose()
80
+
59
81
let testFixtures case =
60
82
let getCorrectnessTestName datatype formatFrom =
61
83
sprintf $" Correctness on %s {datatype}, %A {formatFrom} -> %A {case.Format}"
@@ -68,19 +90,21 @@ let testFixtures case =
68
90
match case.Format with
69
91
| Sparse ->
70
92
[ let convertFun = Vector.toSparse context wgSize
93
+ let convertFunUnsorted = Vector.toSparseUnsorted context wgSize
71
94
72
95
Utils.listOfUnionCases< VectorFormat>
73
96
|> List.map
74
97
( fun formatFrom ->
75
- makeTest formatFrom convertFun ((=) 0 ) case
98
+ makeTest formatFrom convertFun ( Some convertFunUnsorted ) ( (=) 0 ) case
76
99
|> testPropertyWithConfig config ( getCorrectnessTestName " int" formatFrom))
77
100
78
101
let convertFun = Vector.toSparse context wgSize
102
+ let convertFunUnsorted = Vector.toSparseUnsorted context wgSize
79
103
80
104
Utils.listOfUnionCases< VectorFormat>
81
105
|> List.map
82
106
( fun formatFrom ->
83
- makeTest formatFrom convertFun ((=) false ) case
107
+ makeTest formatFrom convertFun ( Some convertFunUnsorted ) ( (=) false ) case
84
108
|> testPropertyWithConfig config ( getCorrectnessTestName " bool" formatFrom)) ]
85
109
|> List.concat
86
110
| Dense ->
@@ -89,15 +113,15 @@ let testFixtures case =
89
113
Utils.listOfUnionCases< VectorFormat>
90
114
|> List.map
91
115
( fun formatFrom ->
92
- makeTest formatFrom convertFun ((=) 0 ) case
116
+ makeTest formatFrom convertFun None ((=) 0 ) case
93
117
|> testPropertyWithConfig config ( getCorrectnessTestName " int" formatFrom))
94
118
95
119
let convertFun = Vector.toDense context wgSize
96
120
97
121
Utils.listOfUnionCases< VectorFormat>
98
122
|> List.map
99
123
( fun formatFrom ->
100
- makeTest formatFrom convertFun ((=) false ) case
124
+ makeTest formatFrom convertFun None ((=) false ) case
101
125
|> testPropertyWithConfig config ( getCorrectnessTestName " bool" formatFrom)) ]
102
126
|> List.concat
103
127
0 commit comments