forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable kernel testing in OSS (pytorch#3795)
Summary: We need to generate the correct Functions.h for each kernel and install it, so that the test binary can use it in include path. We also need to generate the wrapper so that we use the same test source for different kernels. So far we add two tests (abs, neg) for portable and optimized respectively to demonstrate how it works. Next, we will generate header executorch/kernels/test/supported_features.h to allow more ops. Pull Request resolved: pytorch#3795 Reviewed By: shoumikhin Differential Revision: D58042604 Pulled By: kirklandsign fbshipit-source-id: a442beb32cea8f622fba85ae7095bb993ceabf6c
- Loading branch information
1 parent
7bcdb0e
commit fa3bf82
Showing
5 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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. | ||
|
||
# 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(kernels_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(_kernels portable optimized) | ||
|
||
foreach(kernel ${_kernels}) | ||
set(_wrapper_path | ||
"${CMAKE_CURRENT_BINARY_DIR}/include/${kernel}/executorch/kernels/test/FunctionHeaderWrapper.h" | ||
) | ||
add_custom_command( | ||
OUTPUT "${_wrapper_path}" | ||
COMMAND mkdir -p include/${kernel}/executorch/kernels/test | ||
COMMAND echo "#include <${kernel}/Functions.h>" > "${_wrapper_path}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
COMMENT "Generating ${_wrapper_path}" | ||
VERBATIM | ||
) | ||
endforeach() | ||
|
||
add_custom_target( | ||
generate_wrapper | ||
DEPENDS | ||
"${CMAKE_CURRENT_BINARY_DIR}/include/portable/executorch/kernels/test/FunctionHeaderWrapper.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/include/optimized/executorch/kernels/test/FunctionHeaderWrapper.h" | ||
) | ||
|
||
set(_portable_kernels_test_sources op_abs_test.cpp) | ||
set(_optimized_kernels_test_sources op_neg_test.cpp) | ||
|
||
et_cxx_test( | ||
portable_kernels_test SOURCES ${_portable_kernels_test_sources} EXTRA_LIBS | ||
portable_kernels portable_ops_lib | ||
) | ||
add_dependencies(portable_kernels_test generate_wrapper) | ||
target_include_directories( | ||
portable_kernels_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/portable" | ||
"${CMAKE_INSTALL_PREFIX}/include" | ||
) | ||
|
||
et_cxx_test( | ||
optimized_kernels_test SOURCES ${_optimized_kernels_test_sources} EXTRA_LIBS | ||
optimized_kernels optimized_ops_lib | ||
) | ||
add_dependencies(optimized_kernels_test generate_wrapper) | ||
# message(FATAL_ERROR "${CMAKE_INSTALL_PREFIX}/include") | ||
target_include_directories( | ||
optimized_kernels_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/optimized" | ||
"${CMAKE_INSTALL_PREFIX}/include" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters