Skip to content

Commit

Permalink
extension/runner_util test (pytorch#3777)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: pytorch#3777

Reviewed By: shoumikhin

Differential Revision: D57976685

Pulled By: kirklandsign

fbshipit-source-id: 8bd8cd565b5ae8eaddb5f900ef6434c669c8148f
  • Loading branch information
kirklandsign authored and facebook-github-bot committed May 30, 2024
1 parent f1cc982 commit ba67296
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions build/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(lib_list
portable_ops_lib
extension_module
extension_module_static
extension_runner_util
xnnpack_backend
XNNPACK
cpuinfo
Expand Down
3 changes: 0 additions & 3 deletions examples/models/toy_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ def __init__(self):

def forward(self, x, y):
z = x + y
z = z + x
z = z + x
z = z + z
return z

def get_eager_model(self) -> torch.nn.Module:
Expand Down
37 changes: 37 additions & 0 deletions extension/runner_util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# @generated by test/utils/generate_gtest_cmakelists.py
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(extension_runner_util_test)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs inputs_test.cpp)

et_cxx_test(
extension_runner_util_test
SOURCES
${_test_srcs}
EXTRA_LIBS
extension_data_loader
extension_runner_util
portable_kernels
portable_ops_lib
)
11 changes: 10 additions & 1 deletion test/run_oss_cpp_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ build_executorch() {
-DEXECUTORCH_USE_CPP_CODE_COVERAGE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_VULKAN=$BUILD_VULKAN \
-Bcmake-out
cmake --build cmake-out -j9 --target install
Expand All @@ -46,6 +47,10 @@ build_gtest() {
popd
}

export_test_add_model() {
python3 -m examples.portable.scripts.export --model_name="add" --output_dir="cmake-out"
}

build_and_run_test() {
local test_dir=$1
cmake "${test_dir}" \
Expand All @@ -55,7 +60,10 @@ build_and_run_test() {
-Bcmake-out/"${test_dir}"
cmake --build cmake-out/"${test_dir}" -j9

export RESOURCES_PATH=extension/module/test/resources
RESOURCES_PATH=$(realpath extension/module/test/resources)
export RESOURCES_PATH
ET_MODULE_ADD_PATH=$(realpath cmake-out/add.pte)
export ET_MODULE_ADD_PATH

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

build_executorch
build_gtest
export_test_add_model

if [ -z "$1" ]; then
echo "Running all directories:"
Expand Down
13 changes: 12 additions & 1 deletion test/utils/OSSTestConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@
"extension_module_static",
"portable_kernels",
"portable_ops_lib"

]
},
{
"directory": "extension/runner_util/test",
"sources": [
"inputs_test.cpp"
],
"additional_libs": [
"extension_data_loader",
"extension_runner_util",
"portable_kernels",
"portable_ops_lib"
]
},
{
Expand Down

0 comments on commit ba67296

Please sign in to comment.