@@ -150,3 +150,61 @@ static void applyBenchSizes(benchmark::internal::Benchmark* b) {
150
150
151
151
TACO_BENCH_ARGS (bench_ufunc_sparse, xor_0.01 , 0.01 , " xor" )->Apply(applyBenchSizes);
152
152
TACO_BENCH_ARGS (bench_ufunc_sparse, rightShift_0.01 , 0.01 , " >>" )->Apply(applyBenchSizes);
153
+
154
+ static void bench_frostt_ufunc (benchmark::State& state, std::string tnsPath) {
155
+ auto path = getTacoTensorPath ();
156
+ auto frosttTensorPath = path;
157
+ if (frosttTensorPath[frosttTensorPath.size () - 1 ] != ' /' ) {
158
+ frosttTensorPath += " /" ;
159
+ }
160
+ frosttTensorPath += " FROSTT/" ;
161
+ frosttTensorPath += tnsPath;
162
+
163
+ // TODO (rohany): What format do we want to do here?
164
+ auto frosttTensor = read (frosttTensorPath, Sparse);
165
+ Tensor<double > other = shiftLastMode<double >(" other" , frosttTensor);
166
+
167
+ // TODO (rohany): Parametrize by the ufunc as well.
168
+ // TODO (rohany): Certain ufuncs need for operands to be of a certain type.
169
+ // ldexp for example requires the right hand side to be an integer (for python
170
+ // at least). Not sure how we'll handle that for this.
171
+ Func ldExp (" 2^" , Ldexp (), leftIncAlgebra ());
172
+
173
+ for (auto _ : state) {
174
+ state.PauseTiming ();
175
+ Tensor<double > result (" result" , frosttTensor.getDimensions (), frosttTensor.getFormat ());
176
+ switch (frosttTensor.getOrder ()) {
177
+ case 4 : {
178
+ IndexVar i, j, k, l;
179
+ result (i, j, k, l) = ldExp (frosttTensor (i, j, k, l), other (i, j, k, l));
180
+ break ;
181
+ }
182
+ case 5 : {
183
+ IndexVar i, j, k, l, m;
184
+ result (i, j, k, l, m) = ldExp (frosttTensor (i, j, k, l, m), other (i, j, k, l, m));
185
+ break ;
186
+ }
187
+ default :
188
+ state.SkipWithError (" invalid tensor dimension" );
189
+ return ;
190
+ }
191
+ result.compile ();
192
+ result.assemble ();
193
+ state.ResumeTiming ();
194
+
195
+ result.compute ();
196
+ }
197
+ }
198
+
199
+ // TODO (rohany): We can define another macro to "nest" defining benchmarks
200
+ // for each of the ufuncs that we want to operate on.
201
+ #define FOREACH_FROSTT_TENSOR (__func__ ) \
202
+ __func__ (nips, " nips.tns" ) \
203
+ __func__(uber_pickups, " uber-pickups.tns" ) \
204
+ __func__(chicaco_crime, " chicago-crime.tns" ) \
205
+ __func__(lbnl_network, " lbnl-network.tns" )
206
+
207
+ #define DECLARE_FROSTT_UFUNC_BENCH (name, path ) \
208
+ TACO_BENCH_ARGS (bench_frostt_ufunc, name, path);
209
+
210
+ FOREACH_FROSTT_TENSOR (DECLARE_FROSTT_UFUNC_BENCH)
0 commit comments