Skip to content

Commit

Permalink
Add emit/test (pytorch#3933)
Browse files Browse the repository at this point in the history
Summary:
Note that two tests are passing on internal but not OSS. Skip for now.

Change the test backend name from BackendWithCompilerDemo to BackendWithCompilerExample because BackendWithCompilerDemo is packaged by exir/backend/test/test_backends.py and could cause confusion in pytest.

Pull Request resolved: pytorch#3933

Reviewed By: JacobSzwejbka

Differential Revision: D58421581

Pulled By: kirklandsign

fbshipit-source-id: f89edcba323ee8d6c49e885c11acaf05877b7496
  • Loading branch information
kirklandsign authored and facebook-github-bot committed Jun 11, 2024
1 parent 88e9737 commit 10de8b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions exir/emit/test/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python_unittest(
"test_emit.py",
],
deps = [
"fbsource//third-party/pypi/pytest:pytest",
"//caffe2:torch",
"//caffe2/functorch:functorch_src",
"//executorch/exir:error",
Expand Down
17 changes: 10 additions & 7 deletions exir/emit/test/test_emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import executorch.exir.schema as schema
import executorch.exir.tests.models as models
import pytest
import torch
from executorch.exir import (
EdgeCompileConfig,
Expand Down Expand Up @@ -191,6 +192,7 @@ def test_basic_end_to_end(self) -> None:
self.assertEqual(exec_plan.inputs[0], 0)
self.assertEqual(exec_plan.outputs[0], 1)

@pytest.mark.skip(reason="Test not working on OSS")
def test_nested_return(self) -> None:
class Foo(torch.nn.Module):
def forward(
Expand Down Expand Up @@ -521,6 +523,7 @@ def forward(self, x: torch.Tensor, n: torch.Tensor) -> torch.Tensor:
self.assertEqual(len(program.execution_plan[0].chains[0].instructions), 1)
self._assertCallLength(program, 0, 4)

@pytest.mark.skip(reason="Test not working on OSS")
def test_emit_multiple_out(self) -> None:
class Foo(torch.nn.Module):
def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
Expand Down Expand Up @@ -1244,7 +1247,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
)

def test_delegate_with_input_list(self) -> None:
class BackendWithCompilerDemo(BackendDetails):
class BackendWithCompilerExample(BackendDetails):
@staticmethod
def preprocess(
edge_program,
Expand All @@ -1266,7 +1269,7 @@ def forward(self, x):
model = TestModel()
edgeir_m = to_edge(export(model, inputs))
lowered_module = to_backend(
"BackendWithCompilerDemo", edgeir_m.exported_program(), []
"BackendWithCompilerExample", edgeir_m.exported_program(), []
)

class CompositeModule(torch.nn.Module):
Expand All @@ -1284,7 +1287,7 @@ def forward(self, list_a):
exec_prog.buffer

def test_delegate_with_input_tuple(self) -> None:
class BackendWithCompilerDemo(BackendDetails):
class BackendWithCompilerExample(BackendDetails):
@staticmethod
def preprocess(
edge_program,
Expand All @@ -1308,7 +1311,7 @@ def forward(self, input): # a, x, b):
model = AddMulModule()
edgeir_m = to_edge(export(model, model_inputs))
lowered_module = to_backend(
"BackendWithCompilerDemo", edgeir_m.exported_program(), []
"BackendWithCompilerExample", edgeir_m.exported_program(), []
)

class CompositeModule(torch.nn.Module):
Expand All @@ -1328,7 +1331,7 @@ def forward(self, list_a):
def test_delegate_mapping(self) -> None:
debug_handle_map = {1: [1, 2]}

class BackendWithCompilerDemo(BackendDetails):
class BackendWithCompilerExample(BackendDetails):
@staticmethod
def preprocess(
edge_program,
Expand All @@ -1350,7 +1353,7 @@ def forward(self, x, y):
model = TestModel()
edgeir_m = to_edge(export(model, inputs))
lowered_module = to_backend(
"BackendWithCompilerDemo", edgeir_m.exported_program(), []
"BackendWithCompilerExample", edgeir_m.exported_program(), []
)

class CompositeModule(torch.nn.Module):
Expand All @@ -1375,7 +1378,7 @@ def forward(self, x, y):
)
self.assertEqual(
exec_prog.delegate_map.get("forward").get(0).get("name"),
"BackendWithCompilerDemo",
"BackendWithCompilerExample",
)
self.assertTrue(
len(exec_prog.delegate_map.get("forward").get(0).get("delegate_map")) != 0
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ addopts =
exir/dialects/backend/test
exir/dialects/edge/test
exir/dialects/test
exir/emit/test
exir/program/test
exir/tests/test_arg_validator.py
exir/tests/test_capture.py
Expand Down

0 comments on commit 10de8b2

Please sign in to comment.