File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,18 @@ def test_abs_cpu(self):
4646 def test_abs_cuda (self ):
4747 self ._test_fused_abs (device = "cuda" )
4848
49+ @unittest .skipIf (not RUN_CUDA , "requires CUDA" )
50+ @skipIfRocm
51+ def test_zero_element_tensors (self ):
52+ def decode (sin_t , cos_t ):
53+ theta = torch .atan2 (sin_t .float (), cos_t .float ())
54+ return theta
55+
56+ sin = torch .zeros (0 , device = "cuda" )
57+ cos = torch .zeros (0 , device = "cuda" )
58+ inputs = [sin , cos ]
59+ ge = self .checkScript (decode , inputs )
60+
4961 @unittest .skipIf (not RUN_CUDA , "fuser requires CUDA" )
5062 def test_arg_configurations_smoke_cuda (self ):
5163 # A smoke test to make sure we won't use the same kernel for contiguous
Original file line number Diff line number Diff line change @@ -313,8 +313,11 @@ void launchFusion(
313313 }
314314 }
315315 }
316-
317- fusion.launch_raw (numel, arguments);
316+ // Skip launching the kernel for zero-element tensor inputs
317+ // launches are skipped, empty zero-sized output is returned
318+ if (numel > 0 ) {
319+ fusion.launch_raw (numel, arguments);
320+ }
318321}
319322
320323bool runFusion (const int64_t key, Stack& stack, std::string* code_out) {
You can’t perform that action at this time.
0 commit comments