Skip to content

Commit ba8a037

Browse files
committed
[HACK NOT FOR LAND] Add option specify a list of ops
Summary: This is needed to generate `portable_ops_lib` with select number of ops for quick testing when we can't afford to link all the ops for size reasons. Arm Baremetal builds is one example. Differential Revision: D49899554 fbshipit-source-id: 9d35e7bfd1c1975da640e62493fc744898ad6714
1 parent 1129776 commit ba8a037

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ option(BUILD_SELECTIVE_BUILD_TEST
9494

9595
option(EXECUTORCH_BUILD_SIZE_TEST "Whether to build size test" OFF)
9696

97+
# Option to register op list
98+
option(EXECUTORCH_SELECT_OPS_LIST "Register the following list of ops" OFF)
99+
97100
if(BUILD_SELECTIVE_BUILD_TEST)
98101
option(SELECT_ALL_OPS
99102
"Whether to register all ops defined in portable kernel library." OFF)
100103

101-
# Option to register op list
102-
option(SELECT_OPS_LIST "Register the following list of ops" OFF)
103-
104104
# Option to register ops from yaml file
105105
option(SELECT_OPS_YAML "Register all the ops from a given yaml file" OFF)
106106
endif()

kernels/portable/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ file(GLOB_RECURSE _portable_kernels__srcs
3737
"${CMAKE_CURRENT_SOURCE_DIR}/cpu/*.cpp")
3838
list(FILTER _portable_kernels__srcs EXCLUDE REGEX "test/*.cpp")
3939
list(FILTER _portable_kernels__srcs EXCLUDE REGEX "codegen")
40-
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
41-
# Executorch (for runtime). Here select all ops in functions.yaml
42-
gen_selected_ops("${CMAKE_CURRENT_LIST_DIR}/functions.yaml" "" "")
40+
41+
# If a filterlist is provided only generate wrappers for those
42+
# Else for all - this is the default behavior.
43+
if(EXECUTORCH_SELECT_OPS_LIST)
44+
message("Selecting only ${EXECUTORCH_SELECT_OPS_LIST} op(s)!")
45+
gen_selected_ops("" "${EXECUTORCH_SELECT_OPS_LIST}" "")
46+
else()
47+
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
48+
# Executorch (for runtime). Here select all ops in functions.yaml
49+
message("Selecting all ops")
50+
gen_selected_ops("${CMAKE_CURRENT_LIST_DIR}/functions.yaml" "" "")
51+
endif()
52+
4353
# Expect gen_selected_ops output file to be selected_operators.yaml
4454
generate_bindings_for_kernels(${CMAKE_CURRENT_SOURCE_DIR}/functions.yaml "")
4555
message("Generated files ${gen_command_sources}")

0 commit comments

Comments
 (0)