Skip to content

[ET][Testing] Build test_backend_compiler_lib when testing is on #9953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion devtools/inspector/tests/inspector_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 2 additions & 12 deletions exir/backend/test/test_lowered_backend_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason we don't test lifted vs unlifted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these variables aren't actually being used, I'm not sure why it's not being tested, but it wasn't being tested to begin with, and pytest complains about that, so i'm just cleaning up here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hmm, how did you find out they are not tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlift variable isn't used in the test body. pytest complains about that and says given is useless if that's the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah looks like it was deleted in #3169

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I understand now, it was used when exported program decided to lift all the params. It's not needed now params are all lifted anyway

)
@settings(deadline=500000)
def test_emit_lowered_backend_module(self, unlift):
def test_emit_lowered_backend_module(self):
module_list = [
models.Emformer(),
models.Repeat(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 0 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions runtime/executor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
Expand Down
14 changes: 14 additions & 0 deletions tools/cmake/cmake_deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading