@@ -29,6 +29,35 @@ def sliceTensor(tensor, dim, config):
29
29
else :
30
30
assert (False )
31
31
32
+ # Benchmark to measure the time it takes to perform the slice.
33
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
34
+ @pytest .mark .parametrize ("format" , ['csr' ])
35
+ @pytest .mark .parametrize ("config" , sizeConfigs [:len (sizeConfigs )- 1 ])
36
+ def bench_slice_sparse_window (tacoBench , dim , format , config ):
37
+ loader = RandomScipySparseTensorLoader (format )
38
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
39
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
40
+ def bench ():
41
+ x = sliceTensor (matrix , dim , config )
42
+ x2 = sliceTensor (matrix2 , dim , config )
43
+ return (x , x2 )
44
+ tacoBench (bench )
45
+
46
+ # Benchmark to measure the time it takes to perform the addition.
47
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
48
+ @pytest .mark .parametrize ("format" , ['csr' ])
49
+ @pytest .mark .parametrize ("config" , sizeConfigs [:len (sizeConfigs )- 1 ])
50
+ def bench_add_sliced_sparse_window (tacoBench , dim , format , config ):
51
+ loader = RandomScipySparseTensorLoader (format )
52
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
53
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
54
+ x = sliceTensor (matrix , dim , config )
55
+ x2 = sliceTensor (matrix2 , dim , config )
56
+ def bench ():
57
+ return x + x2
58
+ tacoBench (bench )
59
+
60
+ # Benchmark that performs the slice and addition.
32
61
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
33
62
@pytest .mark .parametrize ("format" , ['csr' ])
34
63
@pytest .mark .parametrize ("config" , sizeConfigs )
@@ -44,8 +73,30 @@ def bench():
44
73
# res = matrix + matrix
45
74
tacoBench (bench )
46
75
47
- # TODO (rohany): This is really slow (compared to scipy.sparse). Check with hameer
48
- # that this result makes sense.
76
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
77
+ @pytest .mark .parametrize ("config" , sizeConfigs [:len (sizeConfigs )- 1 ])
78
+ def bench_slice_pydata_sparse_window (tacoBench , dim , config ):
79
+ loader = RandomPydataSparseTensorLoader ()
80
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
81
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
82
+ def bench ():
83
+ x = sliceTensor (matrix , dim , config )
84
+ x2 = sliceTensor (matrix2 , dim , config )
85
+ return (x , x2 )
86
+ tacoBench (bench )
87
+
88
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
89
+ @pytest .mark .parametrize ("config" , sizeConfigs [:len (sizeConfigs )- 1 ])
90
+ def bench_add_sliced_pydata_sparse_window (tacoBench , dim , config ):
91
+ loader = RandomPydataSparseTensorLoader ()
92
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
93
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
94
+ x = sliceTensor (matrix , dim , config )
95
+ x2 = sliceTensor (matrix2 , dim , config )
96
+ def bench ():
97
+ return x + x2
98
+ tacoBench (bench )
99
+
49
100
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
50
101
@pytest .mark .parametrize ("config" , sizeConfigs )
51
102
def bench_add_pydata_sparse_window (tacoBench , dim , config ):
@@ -61,56 +112,75 @@ def bench():
61
112
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
62
113
@pytest .mark .parametrize ("format" , ['csr' ])
63
114
@pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
64
- def bench_add_sparse_strided_window (tacoBench , dim , format , strideWidth ):
115
+ def bench_slice_strided_window (tacoBench , dim , format , strideWidth ):
65
116
loader = RandomScipySparseTensorLoader (format )
66
117
matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
67
118
matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
68
119
def bench ():
69
120
x = matrix [0 :dim :strideWidth , 0 :dim :strideWidth ]
70
121
x2 = matrix2 [0 :dim :strideWidth , 0 :dim :strideWidth ]
122
+ return (x , x2 )
123
+ tacoBench (bench )
124
+
125
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
126
+ @pytest .mark .parametrize ("format" , ['csr' ])
127
+ @pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
128
+ def bench_add_sliced_sparse_strided_window (tacoBench , dim , format , strideWidth ):
129
+ loader = RandomScipySparseTensorLoader (format )
130
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
131
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
132
+ x = matrix [0 :dim :strideWidth , 0 :dim :strideWidth ]
133
+ x2 = matrix2 [0 :dim :strideWidth , 0 :dim :strideWidth ]
134
+ def bench ():
71
135
res = x + x2
72
136
tacoBench (bench )
73
137
74
138
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
75
- @pytest .mark .parametrize ("format" , ['csr' , 'csc' ])
76
- @pytest .mark .parametrize ("fraction" , [2 , 4 , 8 ])
77
- @pytest .mark .skip (reason = "not doing index sets" )
78
- def bench_add_sparse_index_set (tacoBench , dim , format , fraction ):
79
- indexes = [i * fraction for i in range (0 , dim // fraction )]
139
+ @pytest .mark .parametrize ("format" , ['csr' ])
140
+ @pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
141
+ def bench_add_sparse_strided_window (tacoBench , dim , format , strideWidth ):
80
142
loader = RandomScipySparseTensorLoader (format )
81
- matrix = loader .random ((dim , dim ), 0.01 )
82
- matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 )
143
+ matrix = loader .random ((dim , dim ), 0.01 ). astype ( 'float64' )
144
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ). astype ( 'float64' )
83
145
def bench ():
84
- x = matrix [:, indexes ]
85
- x2 = matrix2 [:, indexes ]
146
+ x = matrix [0 : dim : strideWidth , 0 : dim : strideWidth ]
147
+ x2 = matrix2 [0 : dim : strideWidth , 0 : dim : strideWidth ]
86
148
res = x + x2
87
149
tacoBench (bench )
88
150
89
151
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
90
152
@pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
91
- def bench_add_pydata_sparse_strided_window (tacoBench , dim , strideWidth ):
153
+ def bench_slice_pydata_sparse_strided_window (tacoBench , dim , strideWidth ):
92
154
loader = RandomPydataSparseTensorLoader ()
93
155
matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
94
156
matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
95
157
def bench ():
96
158
x = matrix [0 :dim :strideWidth , 0 :dim :strideWidth ]
97
159
x2 = matrix2 [0 :dim :strideWidth , 0 :dim :strideWidth ]
160
+ return (x , x2 )
161
+ tacoBench (bench )
162
+
163
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
164
+ @pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
165
+ def bench_add_sliced_pydata_sparse_strided_window (tacoBench , dim , strideWidth ):
166
+ loader = RandomPydataSparseTensorLoader ()
167
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
168
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
169
+ x = matrix [0 :dim :strideWidth , 0 :dim :strideWidth ]
170
+ x2 = matrix2 [0 :dim :strideWidth , 0 :dim :strideWidth ]
171
+ def bench ():
98
172
res = x + x2
99
173
tacoBench (bench )
100
174
101
- # TODO (rohany): This is really slow (compared to scipy.sparse). Check with hameer
102
- # that this result makes sense.
103
175
@pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
104
- @pytest .mark .parametrize ("fraction" , [2 , 4 , 8 ])
105
- @pytest .mark .skip (reason = "not doing index sets" )
106
- def bench_add_pydata_sparse_index_set (tacoBench , dim , fraction ):
176
+ @pytest .mark .parametrize ("strideWidth" , [2 , 4 , 8 ])
177
+ def bench_add_pydata_sparse_strided_window (tacoBench , dim , strideWidth ):
107
178
loader = RandomPydataSparseTensorLoader ()
108
- indexes = [i * fraction for i in range (0 , dim // fraction )]
109
- matrix = loader .random ((dim , dim ), 0.01 )
110
- matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 )
179
+ matrix = loader .random ((dim , dim ), 0.01 ).astype ('float64' )
180
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 ).astype ('float64' )
111
181
def bench ():
112
- x = matrix [:, indexes ]
113
- x2 = matrix2 [:, indexes ]
182
+ x = matrix [0 : dim : strideWidth , 0 : dim : strideWidth ]
183
+ x2 = matrix2 [0 : dim : strideWidth , 0 : dim : strideWidth ]
114
184
res = x + x2
115
185
tacoBench (bench )
116
186
@@ -133,3 +203,34 @@ def bench():
133
203
res = x + x
134
204
tacoBench (bench )
135
205
206
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
207
+ @pytest .mark .parametrize ("format" , ['csr' , 'csc' ])
208
+ @pytest .mark .parametrize ("fraction" , [2 , 4 , 8 ])
209
+ @pytest .mark .skip (reason = "not doing index sets" )
210
+ def bench_add_sparse_index_set (tacoBench , dim , format , fraction ):
211
+ indexes = [i * fraction for i in range (0 , dim // fraction )]
212
+ loader = RandomScipySparseTensorLoader (format )
213
+ matrix = loader .random ((dim , dim ), 0.01 )
214
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 )
215
+ def bench ():
216
+ x = matrix [:, indexes ]
217
+ x2 = matrix2 [:, indexes ]
218
+ res = x + x2
219
+ tacoBench (bench )
220
+
221
+ # TODO (rohany): This is really slow (compared to scipy.sparse). Check with hameer
222
+ # that this result makes sense.
223
+ @pytest .mark .parametrize ("dim" , [5000 , 10000 , 20000 ])
224
+ @pytest .mark .parametrize ("fraction" , [2 , 4 , 8 ])
225
+ @pytest .mark .skip (reason = "not doing index sets" )
226
+ def bench_add_pydata_sparse_index_set (tacoBench , dim , fraction ):
227
+ loader = RandomPydataSparseTensorLoader ()
228
+ indexes = [i * fraction for i in range (0 , dim // fraction )]
229
+ matrix = loader .random ((dim , dim ), 0.01 )
230
+ matrix2 = loader .random ((dim , dim ), 0.01 , variant = 1 )
231
+ def bench ():
232
+ x = matrix [:, indexes ]
233
+ x2 = matrix2 [:, indexes ]
234
+ res = x + x2
235
+ tacoBench (bench )
236
+
0 commit comments