Skip to content

Commit f2bb3af

Browse files
digantdesaifacebook-github-bot
authored andcommitted
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 1fa0952 commit f2bb3af

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
@@ -104,13 +104,13 @@ option(BUILD_SELECTIVE_BUILD_TEST
104104

105105
option(EXECUTORCH_BUILD_SIZE_TEST "Whether to build size test" OFF)
106106

107+
# Option to register op list
108+
option(SELECT_OPS_LIST "Register the following list of ops" OFF)
109+
107110
if(BUILD_SELECTIVE_BUILD_TEST)
108111
option(SELECT_ALL_OPS
109112
"Whether to register all ops defined in portable kernel library." OFF)
110113

111-
# Option to register op list
112-
option(SELECT_OPS_LIST "Register the following list of ops" OFF)
113-
114114
# Option to register ops from yaml file
115115
option(SELECT_OPS_YAML "Register all the ops from a given yaml file" OFF)
116116
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(SELECT_OPS_LIST)
44+
message("Selecting only ${SELECT_OPS_LIST} op(s)!")
45+
gen_selected_ops("" "${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)