Skip to content

Commit ab27368

Browse files
authored
CUDA tests: Skip running the program in test_same_tensor_returned_twice in fbcode (#25354)
Summary: In fbcode, `test_same_tensor_returned_twice` now stops after exporting and lowering the model and does not run the program. It still runs end to end in OSS. The check is `is_fbcode()` from `executorch.export.utils`, imported right before it. Reviewed By: shoumikhin Differential Revision: D129485547
1 parent 21c7c99 commit ab27368

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎backends/cuda/tests/targets.bzl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def define_common_targets(is_fbcode = False):
3535
"//executorch/exir/backend:backend_api",
3636
"//executorch/exir/backend:compile_spec_schema",
3737
"//executorch/examples/models/toy_model:toy_model",
38+
"//executorch/export:export_utils",
3839
],
3940
keep_gpu_sections = True,
4041
remote_execution = re_test_utils.remote_execution(

‎backends/cuda/tests/test_cuda_export.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,6 @@ def test_same_tensor_returned_twice(self):
12801280
"""AOTI gives two outputs one handle when they are the same tensor. With
12811281
CUDA graphs on, three calls run eagerly, the fourth captures a graph and
12821282
the fifth replays it."""
1283-
from executorch.runtime import Runtime
12841283

12851284
class Twice(torch.nn.Module):
12861285
def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, ...]:
@@ -1289,6 +1288,13 @@ def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, ...]:
12891288

12901289
model = Twice()
12911290
edge = self._export_to_cuda_with_lower(model, (torch.randn(4, 8),))
1291+
from executorch.export.utils import is_fbcode
1292+
1293+
if is_fbcode():
1294+
# Running the program is skipped in fbcode.
1295+
return
1296+
from executorch.runtime import Runtime
1297+
12921298
runtime = Runtime.get()
12931299
option = "enable_cuda_graph_for_method"
12941300
with tempfile.TemporaryDirectory() as directory:

0 commit comments

Comments
 (0)