@@ -231,25 +231,32 @@ TEST_F(TensorFactoryTest, StandaloneIota) {
231
231
}
232
232
233
233
TEST_F (TensorFactoryTest, SimpleTriu) {
234
- auto fusion = std::make_unique<Fusion>();
235
-
236
- FusionGuard gf (fusion. get ()) ;
234
+ std::vector<std::vector< int64_t >> input_sizes = {
235
+ { 64 , 64 }, { 4 , 16 }, { 16 , 4 }, { 16 , 8 , 32 }};
236
+ auto offsets = { 0 , 1 , 2 , - 1 , - 2 , 200 , - 200 } ;
237
237
238
- auto tv_to_triu_on = makeSymbolicTensor (3 , DataType::Half);
239
- fusion->addInput (tv_to_triu_on);
238
+ for (auto input_size : input_sizes) {
239
+ for (auto offset : offsets) {
240
+ auto fusion = std::make_unique<Fusion>();
241
+ FusionGuard fg (fusion.get ());
240
242
241
- int64_t k_factor = - 2 ;
242
- auto out = triu (tv_to_triu_on, IrBuilder::create<Val>(k_factor , DataType::Int) );
243
- fusion->addOutput (out );
243
+ auto tv_to_triu_on =
244
+ makeSymbolicTensor (input_size. size () , DataType::Half );
245
+ fusion->addInput (tv_to_triu_on );
244
246
247
+ auto out =
248
+ triu (tv_to_triu_on, IrBuilder::create<Val>(offset, DataType::Int));
249
+ fusion->addOutput (out);
245
250
246
- auto options = at::TensorOptions ().dtype (at::kHalf ).device (at::kCUDA );
247
- auto in_tensor = at::randn ({ 4 , 4 , 8 } , options);
251
+ auto options = at::TensorOptions ().dtype (at::kHalf ).device (at::kCUDA );
252
+ auto in_tensor = at::randn (input_size , options);
248
253
249
- FusionExecutorCache executor_cache (std::move (fusion));
250
- auto cg_outputs = executor_cache.runFusionWithInputs ({in_tensor});
254
+ FusionExecutorCache executor_cache (std::move (fusion));
255
+ auto cg_outputs = executor_cache.runFusionWithInputs ({in_tensor});
251
256
252
- EXPECT_TRUE (cg_outputs[0 ].allclose (at::triu (in_tensor, k_factor), .001 , .001 ));
257
+ EXPECT_TRUE (at::equal (cg_outputs[0 ], at::triu (in_tensor, offset)));
258
+ }
259
+ }
253
260
}
254
261
255
262
TEST_F (TensorFactoryTest, StandaloneARange) {
0 commit comments