|
12 | 12 | include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) |
13 | 13 |
|
14 | 14 | function(gen_selected_ops) |
15 | | - set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS) |
| 15 | + set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS DTYPE_SELECTIVE_BUILD) |
16 | 16 | cmake_parse_arguments(GEN "" "" "${arg_names}" ${ARGN}) |
17 | 17 |
|
18 | | - message(STATUS "Generating operator lib:") |
| 18 | + message(STATUS "Generating selected operator lib:") |
19 | 19 | message(STATUS " LIB_NAME: ${GEN_LIB_NAME}") |
20 | 20 | message(STATUS " OPS_SCHEMA_YAML: ${GEN_OPS_SCHEMA_YAML}") |
21 | 21 | message(STATUS " ROOT_OPS: ${GEN_ROOT_OPS}") |
22 | 22 | message(STATUS " INCLUDE_ALL_OPS: ${GEN_INCLUDE_ALL_OPS}") |
| 23 | + message(STATUS " DTYPE_SELECTIVE_BUILD: ${GEN_DTYPE_SELECTIVE_BUILD}") |
| 24 | + if(GEN_DTYPE_SELECTIVE_BUILD) |
| 25 | + message(STATUS " DTYPE_SELECTIVE_BUILD is still WIP and may not be fully functional") |
| 26 | + endif() |
23 | 27 |
|
24 | 28 | set(_oplist_yaml |
25 | 29 | ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/selected_operators.yaml |
26 | 30 | ) |
| 31 | + |
27 | 32 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}) |
28 | 33 |
|
29 | 34 | file(GLOB_RECURSE _codegen_tools_srcs "${EXECUTORCH_ROOT}/codegen/tools/*.py") |
@@ -53,6 +58,23 @@ function(gen_selected_ops) |
53 | 58 | WORKING_DIRECTORY ${EXECUTORCH_ROOT} |
54 | 59 | ) |
55 | 60 |
|
| 61 | + if(GEN_DTYPE_SELECTIVE_BUILD) |
| 62 | + set(_opvariant_h |
| 63 | + ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/selected_op_variants.h |
| 64 | + ) |
| 65 | + set(_gen_opvariant_command "${PYTHON_EXECUTABLE}" -m codegen.tools.gen_selected_op_variants |
| 66 | + --yaml-file=${_oplist_yaml} |
| 67 | + --output-dir=${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/ |
| 68 | + ) |
| 69 | + message("Command - ${_gen_opvariant_command}") |
| 70 | + add_custom_command( |
| 71 | + COMMENT "Generating selected_op_variants.h for ${GEN_LIB_NAME}" |
| 72 | + OUTPUT ${_opvariant_h} |
| 73 | + COMMAND ${_gen_opvariant_command} |
| 74 | + DEPENDS ${_optlist_yaml} ${_codegen_tools_srcs} |
| 75 | + WORKING_DIRECTORY ${EXECUTORCH_ROOT} |
| 76 | + ) |
| 77 | + endif() |
56 | 78 | endfunction() |
57 | 79 |
|
58 | 80 | # Codegen for registering kernels. Kernels are defined in functions_yaml and |
|
0 commit comments