Skip to content

Commit ba67296

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
extension/runner_util test (#3777)
Summary: Pull Request resolved: #3777 Reviewed By: shoumikhin Differential Revision: D57976685 Pulled By: kirklandsign fbshipit-source-id: 8bd8cd565b5ae8eaddb5f900ef6434c669c8148f
1 parent f1cc982 commit ba67296

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

build/executorch-config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ set(lib_list
4444
portable_ops_lib
4545
extension_module
4646
extension_module_static
47+
extension_runner_util
4748
xnnpack_backend
4849
XNNPACK
4950
cpuinfo

examples/models/toy_model/model.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ def __init__(self):
4545

4646
def forward(self, x, y):
4747
z = x + y
48-
z = z + x
49-
z = z + x
50-
z = z + z
5148
return z
5249

5350
def get_eager_model(self) -> torch.nn.Module:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# @generated by test/utils/generate_gtest_cmakelists.py
8+
#
9+
# This file should be formatted with
10+
# ~~~
11+
# cmake-format -i CMakeLists.txt
12+
# ~~~
13+
# It should also be cmake-lint clean.
14+
#
15+
16+
cmake_minimum_required(VERSION 3.19)
17+
project(extension_runner_util_test)
18+
19+
# Use C++17 for test.
20+
set(CMAKE_CXX_STANDARD 17)
21+
22+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
23+
24+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
25+
26+
set(_test_srcs inputs_test.cpp)
27+
28+
et_cxx_test(
29+
extension_runner_util_test
30+
SOURCES
31+
${_test_srcs}
32+
EXTRA_LIBS
33+
extension_data_loader
34+
extension_runner_util
35+
portable_kernels
36+
portable_ops_lib
37+
)

test/run_oss_cpp_tests.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ build_executorch() {
3232
-DEXECUTORCH_USE_CPP_CODE_COVERAGE=ON \
3333
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
35+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
3536
-DEXECUTORCH_BUILD_VULKAN=$BUILD_VULKAN \
3637
-Bcmake-out
3738
cmake --build cmake-out -j9 --target install
@@ -46,6 +47,10 @@ build_gtest() {
4647
popd
4748
}
4849

50+
export_test_add_model() {
51+
python3 -m examples.portable.scripts.export --model_name="add" --output_dir="cmake-out"
52+
}
53+
4954
build_and_run_test() {
5055
local test_dir=$1
5156
cmake "${test_dir}" \
@@ -55,7 +60,10 @@ build_and_run_test() {
5560
-Bcmake-out/"${test_dir}"
5661
cmake --build cmake-out/"${test_dir}" -j9
5762

58-
export RESOURCES_PATH=extension/module/test/resources
63+
RESOURCES_PATH=$(realpath extension/module/test/resources)
64+
export RESOURCES_PATH
65+
ET_MODULE_ADD_PATH=$(realpath cmake-out/add.pte)
66+
export ET_MODULE_ADD_PATH
5967

6068
for t in cmake-out/"${test_dir}"/*test; do
6169
if [ -e "$t" ]; then
@@ -92,6 +100,7 @@ probe_tests() {
92100

93101
build_executorch
94102
build_gtest
103+
export_test_add_model
95104

96105
if [ -z "$1" ]; then
97106
echo "Running all directories:"

test/utils/OSSTestConfig.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@
2121
"extension_module_static",
2222
"portable_kernels",
2323
"portable_ops_lib"
24-
24+
]
25+
},
26+
{
27+
"directory": "extension/runner_util/test",
28+
"sources": [
29+
"inputs_test.cpp"
30+
],
31+
"additional_libs": [
32+
"extension_data_loader",
33+
"extension_runner_util",
34+
"portable_kernels",
35+
"portable_ops_lib"
2536
]
2637
},
2738
{

0 commit comments

Comments
 (0)