|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +cmake_minimum_required(VERSION 3.19) |
| 8 | + |
| 9 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 10 | +if(NOT CMAKE_CXX_STANDARD) |
| 11 | + set(CMAKE_CXX_STANDARD 17) |
| 12 | +endif() |
| 13 | + |
| 14 | +include(${EXECUTORCH_ROOT}/build/Utils.cmake) |
| 15 | +include(${EXECUTORCH_ROOT}/build/Codegen.cmake) |
| 16 | + |
| 17 | +if(NOT PYTHON_EXECUTABLE) |
| 18 | + resolve_python_executable() |
| 19 | +endif() |
| 20 | + |
| 21 | +# ATen compliant ops that are needed to run this model. |
| 22 | +set(_aten_ops__srcs |
| 23 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/activation_ops_util.cpp" |
| 24 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/copy_ops_util.cpp" |
| 25 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/broadcast_util.cpp" |
| 26 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/index_util.cpp" |
| 27 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/kernel_ops_util.cpp" |
| 28 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/matmul_ops_util.cpp" |
| 29 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/reduce_util.cpp" |
| 30 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/repeat_util.cpp" |
| 31 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/slice_util.cpp" |
| 32 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_add.cpp" |
| 33 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_mul.cpp" |
| 34 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_cat.cpp" |
| 35 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_softmax.cpp" |
| 36 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_native_layer_norm.cpp" |
| 37 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_quantize.cpp" |
| 38 | + "${CMAKE_CURRENT_SOURCE_DIR}/op_dequantize.cpp" |
| 39 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_bmm.cpp" |
| 40 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp" |
| 41 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_div.cpp" |
| 42 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_embedding.cpp" |
| 43 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_full.cpp" |
| 44 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_permute_copy.cpp" |
| 45 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_sigmoid.cpp" |
| 46 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_slice_copy.cpp" |
| 47 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_split_with_sizes_copy.cpp" |
| 48 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_sub.cpp" |
| 49 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_to_copy.cpp" |
| 50 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_view_copy.cpp" |
| 51 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/op_where.cpp" |
| 52 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/dtype_util.cpp" |
| 53 | + "${EXECUTORCH_ROOT}/kernels/portable/cpu/util/normalization_ops_util.cpp" |
| 54 | +) |
| 55 | +add_library(aten_ops_cadence ${_aten_ops__srcs}) |
| 56 | +target_link_libraries(aten_ops_cadence PUBLIC executorch) |
| 57 | +target_link_libraries(aten_ops_cadence PRIVATE xa_nnlib) |
| 58 | + |
| 59 | +# Let files say "include <executorch/path/to/header.h>". |
| 60 | +set(_common_include_directories ${EXECUTORCH_ROOT}/..) |
| 61 | + |
| 62 | +target_include_directories( |
| 63 | + aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} |
| 64 | + ${_common_include_directories} |
| 65 | + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/common/include/ |
| 66 | + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include/nnlib |
| 67 | + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/include |
| 68 | + ${EXECUTORCH_ROOT}/backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3/xa_nnlib/algo/kernels/tables/include |
| 69 | +) |
| 70 | + |
| 71 | +# Generate C++ bindings to register kernels into both PyTorch (for AOT) and |
| 72 | +# Executorch (for runtime). Here select all ops in functions.yaml |
| 73 | +gen_selected_ops( |
| 74 | + LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML |
| 75 | + "${CMAKE_CURRENT_LIST_DIR}/../../aot/functions_fusion_g3.yaml" "" "" |
| 76 | +) |
| 77 | +generate_bindings_for_kernels( |
| 78 | + LIB_NAME "cadence_ops_lib" OPS_SCHEMA_YAML FUNCTIONS_YAML |
| 79 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../aot/functions_fusion_g3.yaml |
| 80 | +) |
| 81 | +message("Generated files ${gen_command_sources}") |
| 82 | + |
| 83 | +gen_operators_lib( |
| 84 | + LIB_NAME "cadence_ops_lib" KERNEL_LIBS DEPS aten_ops_cadence |
| 85 | +) |
0 commit comments