diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbb66afdaa..1ac7de469b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -810,6 +810,10 @@ if(EXECUTORCH_BUILD_PYBIND) torch ) + if(EXECUTORCH_BUILD_TESTS) + list(APPEND _dep_libs test_backend_compiler_lib) + endif() + if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) list(APPEND _dep_libs optimized_native_cpu_ops_lib) else() diff --git a/devtools/inspector/tests/inspector_utils_test.py b/devtools/inspector/tests/inspector_utils_test.py index 5e224415bb6..ee571e365fe 100644 --- a/devtools/inspector/tests/inspector_utils_test.py +++ b/devtools/inspector/tests/inspector_utils_test.py @@ -205,7 +205,7 @@ def test_compare_results(self): self.assertAlmostEqual(calculate_cosine_similarity([a], [b])[0], 1.0) def test_compare_results_uint8(self): - a = torch.randint(0, 255, (4, 4), dtype=torch.uint8) + a = torch.randint(1, 255, (4, 4), dtype=torch.uint8) # Create tensor b which has very close value to tensor a b = a.clone() diff --git a/exir/backend/test/test_lowered_backend_module.py b/exir/backend/test/test_lowered_backend_module.py index dcc5841bc3e..6cdaf92b3d2 100644 --- a/exir/backend/test/test_lowered_backend_module.py +++ b/exir/backend/test/test_lowered_backend_module.py @@ -22,7 +22,6 @@ from executorch.extension.pybindings.portable_lib import ( # @manual _load_for_executorch_from_buffer, ) -from hypothesis import given, settings, strategies as st from torch.export import export @@ -65,7 +64,6 @@ def forward(self, *args): .executorch_program ) - @settings(deadline=500000) def test_emit_lowered_backend_module_end_to_end(self): class SinModule(torch.nn.Module): def __init__(self): @@ -109,11 +107,7 @@ def forward(self, x): torch.allclose(model_outputs[0], expected_res, atol=1e-03, rtol=1e-03) ) - @given( - unlift=st.booleans(), # verify both lifted and unlifted graph - ) - @settings(deadline=500000) - def test_emit_lowered_backend_module(self, unlift): + def test_emit_lowered_backend_module(self): module_list = [ models.Emformer(), models.Repeat(), @@ -166,11 +160,7 @@ def test_emit_lowered_backend_module(self, unlift): _ = lowered_model.buffer() self.validate_lowered_module_program(program) - @given( - unlift=st.booleans(), # verify both lifted and unlifted graph - ) - @settings(deadline=500000) - def test_emit_nested_lowered_backend_module(self, unlift): + def test_emit_nested_lowered_backend_module(self): module_list = [ models.Emformer(), models.Repeat(), diff --git a/pytest.ini b/pytest.ini index cd647c43a1c..8c661aa9ee4 100644 --- a/pytest.ini +++ b/pytest.ini @@ -63,8 +63,6 @@ addopts = --ignore=exir/backend/test/demos --ignore=exir/backend/test/test_backends.py --ignore=exir/backend/test/test_backends_lifted.py - --ignore=exir/backend/test/test_compatibility.py - --ignore=exir/backend/test/test_lowered_backend_module.py --ignore=exir/backend/test/test_partitioner.py --ignore=exir/tests/test_common.py --ignore=exir/tests/test_memory_format_ops_pass_aten.py diff --git a/runtime/executor/test/CMakeLists.txt b/runtime/executor/test/CMakeLists.txt index 2de32c9176a..3003a5d2c74 100644 --- a/runtime/executor/test/CMakeLists.txt +++ b/runtime/executor/test/CMakeLists.txt @@ -152,3 +152,23 @@ target_include_directories( PRIVATE "${CMAKE_INSTALL_PREFIX}/schema/include" "${EXECUTORCH_ROOT}/third-party/flatbuffers/include" ) + +list(TRANSFORM _test_backend_compiler_lib__srcs PREPEND "${EXECUTORCH_ROOT}/") +add_library( + test_backend_compiler_lib + STATIC + ${_test_backend_compiler_lib__srcs} +) + +target_link_libraries( + test_backend_compiler_lib + PUBLIC + executorch_core +) + +target_link_options_shared_lib(test_backend_compiler_lib) + +install( + TARGETS test_backend_compiler_lib + DESTINATION lib +) diff --git a/setup.py b/setup.py index 44fb9a712a3..e29ce76ff7e 100644 --- a/setup.py +++ b/setup.py @@ -718,6 +718,7 @@ def run(self): # enabled. TODO(dbort): Remove this override once this option is # managed by cmake itself. "-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF", + "-DEXECUTORCH_BUILD_TESTS=ON", ] build_args = [f"-j{self.parallel}"] diff --git a/tools/cmake/cmake_deps.toml b/tools/cmake/cmake_deps.toml index ee810c2bfd5..9913a02c4d5 100644 --- a/tools/cmake/cmake_deps.toml +++ b/tools/cmake/cmake_deps.toml @@ -150,6 +150,20 @@ deps = [ "optimized_cpublas", "portable_kernels", ] + +[targets.test_backend_compiler_lib] +buck_targets = [ + "//runtime/executor/test:test_backend_compiler_lib", +] +filters = [ + ".cpp$", +] +excludes = [ +] +deps = [ + "executorch", + "executorch_core", +] # ---------------------------------- core end ---------------------------------- # ---------------------------------- extension start ---------------------------------- [targets.extension_data_loader]