Skip to content

Commit 63ce4eb

Browse files
committed
[ET][Testing] Build test_backend_compiler_lib when testing is on
ghstack-source-id: d858101 ghstack-comment-id: 2784895427 Pull Request resolved: #9953
1 parent ae2d822 commit 63ce4eb

File tree

7 files changed

+42
-15
lines changed

7 files changed

+42
-15
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ if(EXECUTORCH_BUILD_PYBIND)
810810
torch
811811
)
812812

813+
if(EXECUTORCH_BUILD_TESTS)
814+
list(APPEND _dep_libs test_backend_compiler_lib)
815+
endif()
816+
813817
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
814818
list(APPEND _dep_libs optimized_native_cpu_ops_lib)
815819
else()

devtools/inspector/tests/inspector_utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def test_compare_results(self):
205205
self.assertAlmostEqual(calculate_cosine_similarity([a], [b])[0], 1.0)
206206

207207
def test_compare_results_uint8(self):
208-
a = torch.randint(0, 255, (4, 4), dtype=torch.uint8)
208+
a = torch.randint(1, 255, (4, 4), dtype=torch.uint8)
209209

210210
# Create tensor b which has very close value to tensor a
211211
b = a.clone()

exir/backend/test/test_lowered_backend_module.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from executorch.extension.pybindings.portable_lib import ( # @manual
2323
_load_for_executorch_from_buffer,
2424
)
25-
from hypothesis import given, settings, strategies as st
2625
from torch.export import export
2726

2827

@@ -65,7 +64,6 @@ def forward(self, *args):
6564
.executorch_program
6665
)
6766

68-
@settings(deadline=500000)
6967
def test_emit_lowered_backend_module_end_to_end(self):
7068
class SinModule(torch.nn.Module):
7169
def __init__(self):
@@ -109,11 +107,7 @@ def forward(self, x):
109107
torch.allclose(model_outputs[0], expected_res, atol=1e-03, rtol=1e-03)
110108
)
111109

112-
@given(
113-
unlift=st.booleans(), # verify both lifted and unlifted graph
114-
)
115-
@settings(deadline=500000)
116-
def test_emit_lowered_backend_module(self, unlift):
110+
def test_emit_lowered_backend_module(self):
117111
module_list = [
118112
models.Emformer(),
119113
models.Repeat(),
@@ -166,11 +160,7 @@ def test_emit_lowered_backend_module(self, unlift):
166160
_ = lowered_model.buffer()
167161
self.validate_lowered_module_program(program)
168162

169-
@given(
170-
unlift=st.booleans(), # verify both lifted and unlifted graph
171-
)
172-
@settings(deadline=500000)
173-
def test_emit_nested_lowered_backend_module(self, unlift):
163+
def test_emit_nested_lowered_backend_module(self):
174164
module_list = [
175165
models.Emformer(),
176166
models.Repeat(),

pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ addopts =
6363
--ignore=exir/backend/test/demos
6464
--ignore=exir/backend/test/test_backends.py
6565
--ignore=exir/backend/test/test_backends_lifted.py
66-
--ignore=exir/backend/test/test_compatibility.py
67-
--ignore=exir/backend/test/test_lowered_backend_module.py
6866
--ignore=exir/backend/test/test_partitioner.py
6967
--ignore=exir/tests/test_common.py
7068
--ignore=exir/tests/test_memory_format_ops_pass_aten.py

runtime/executor/test/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,23 @@ target_include_directories(
152152
PRIVATE "${CMAKE_INSTALL_PREFIX}/schema/include"
153153
"${EXECUTORCH_ROOT}/third-party/flatbuffers/include"
154154
)
155+
156+
list(TRANSFORM _test_backend_compiler_lib__srcs PREPEND "${EXECUTORCH_ROOT}/")
157+
add_library(
158+
test_backend_compiler_lib
159+
STATIC
160+
${_test_backend_compiler_lib__srcs}
161+
)
162+
163+
target_link_libraries(
164+
test_backend_compiler_lib
165+
PUBLIC
166+
executorch_core
167+
)
168+
169+
target_link_options_shared_lib(test_backend_compiler_lib)
170+
171+
install(
172+
TARGETS test_backend_compiler_lib
173+
DESTINATION lib
174+
)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ def run(self):
718718
# enabled. TODO(dbort): Remove this override once this option is
719719
# managed by cmake itself.
720720
"-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF",
721+
"-DEXECUTORCH_BUILD_TESTS=ON",
721722
]
722723

723724
build_args = [f"-j{self.parallel}"]

tools/cmake/cmake_deps.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ deps = [
150150
"optimized_cpublas",
151151
"portable_kernels",
152152
]
153+
154+
[targets.test_backend_compiler_lib]
155+
buck_targets = [
156+
"//runtime/executor/test:test_backend_compiler_lib",
157+
]
158+
filters = [
159+
".cpp$",
160+
]
161+
excludes = [
162+
]
163+
deps = [
164+
"executorch",
165+
"executorch_core",
166+
]
153167
# ---------------------------------- core end ----------------------------------
154168
# ---------------------------------- extension start ----------------------------------
155169
[targets.extension_data_loader]

0 commit comments

Comments
 (0)