Skip to content

Commit

Permalink
Rename executorch_no_prim_ops to executorch_core (pytorch#5740)
Browse files Browse the repository at this point in the history
Summary:
Minor CMake target cleanup for beta.

Pull Request resolved: pytorch#5740

Reviewed By: shoumikhin

Differential Revision: D63576097

Pulled By: GregoryComer

fbshipit-source-id: b10f9f15cfcae3bce769d07cd014e8064d735dbd
  • Loading branch information
GregoryComer authored and facebook-github-bot committed Sep 29, 2024
1 parent fe0e676 commit 905b88c
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 77 deletions.
38 changes: 21 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,22 @@ endif()
add_subdirectory(schema)

#
# executorch_no_prim_ops: Minimal runtime library
# executorch_core: Minimal runtime library
#
# The bare-minimum runtime library, supporting the Program and Method
# interfaces. Does not contain any operators, including primitive ops. Does not
# contain any backends.
#

# Remove any PAL-definition files from the sources.
list(FILTER _executorch_no_prim_ops__srcs EXCLUDE REGEX
list(FILTER _executorch_core__srcs EXCLUDE REGEX
"runtime/platform/default/[^/]*.cpp$"
)

# Add the source file that maps to the requested default PAL implementation.
if(EXECUTORCH_PAL_DEFAULT MATCHES "^(posix|minimal)$")
message(STATUS "executorch: Using PAL default '${EXECUTORCH_PAL_DEFAULT}'")
list(APPEND _executorch_no_prim_ops__srcs
list(APPEND _executorch_core__srcs
"runtime/platform/default/${EXECUTORCH_PAL_DEFAULT}.cpp"
)
else()
Expand All @@ -483,45 +483,49 @@ else()
)
endif()

add_library(executorch_no_prim_ops ${_executorch_no_prim_ops__srcs})
target_link_libraries(executorch_no_prim_ops PRIVATE program_schema)
add_library(executorch_core ${_executorch_core__srcs})

# Legacy name alias.
add_library(executorch_no_prim_ops ALIAS executorch_core)

target_link_libraries(executorch_core PRIVATE program_schema)
if(EXECUTORCH_USE_DL)
# Check if dl exists for this toolchain and only then link it.
find_library(DL_LIBRARY_EXISTS NAMES dl)
# Check if the library was found
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch_no_prim_ops PRIVATE dl) # For dladdr()
target_link_libraries(executorch_core PRIVATE dl) # For dladdr()
endif()
endif()
target_include_directories(
executorch_no_prim_ops PUBLIC ${_common_include_directories}
executorch_core PUBLIC ${_common_include_directories}
)
target_compile_options(executorch_no_prim_ops PUBLIC ${_common_compile_options})
target_compile_options(executorch_core PUBLIC ${_common_compile_options})
if(MAX_KERNEL_NUM)
target_compile_definitions(
executorch_no_prim_ops PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
executorch_core PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
)
endif()

if(EXECUTORCH_BUILD_PYBIND AND APPLE)
# shared version
add_library(
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
executorch_core_shared SHARED ${_executorch_core__srcs}
)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
target_link_libraries(executorch_core_shared PRIVATE program_schema)
if(DL_LIBRARY_EXISTS)
# For dladdr()
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl)
target_link_libraries(executorch_core_shared PRIVATE dl)
endif()
target_include_directories(
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
executorch_core_shared PUBLIC ${_common_include_directories}
)
target_compile_options(
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
executorch_core_shared PUBLIC ${_common_compile_options}
)
if(MAX_KERNEL_NUM)
target_compile_definitions(
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
executorch_core_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
)
endif()
endif()
Expand All @@ -534,7 +538,7 @@ endif()
# any backends.
#
add_library(executorch ${_executorch__srcs})
target_link_libraries(executorch PRIVATE executorch_no_prim_ops)
target_link_libraries(executorch PRIVATE executorch_core)
target_include_directories(executorch PUBLIC ${_common_include_directories})
target_compile_options(executorch PUBLIC ${_common_compile_options})
target_link_options_shared_lib(executorch)
Expand Down Expand Up @@ -570,7 +574,7 @@ endif()
# Install `executorch` library as well as `executorch-config.cmake` under
# ${CMAKE_INSTALL_PREFIX}/
install(
TARGETS executorch executorch_no_prim_ops
TARGETS executorch executorch_core
DESTINATION lib
INCLUDES
DESTINATION ${_common_include_directories}
Expand Down
6 changes: 3 additions & 3 deletions backends/apple/coreml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ target_include_directories(
coremldelegate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util
)
target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/..)
target_link_libraries(coremldelegate PRIVATE executorch_no_prim_ops)
target_link_libraries(coremldelegate PRIVATE executorch_core)

if(EXECUTORCH_BUILD_DEVTOOLS)
target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES})
Expand All @@ -159,7 +159,7 @@ find_library(SQLITE_LIBRARY sqlite3)

target_link_libraries(
coremldelegate
PRIVATE executorch_no_prim_ops ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK}
PRIVATE executorch_core ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK}
${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY}
)

Expand All @@ -176,7 +176,7 @@ target_compile_options(coremldelegate PRIVATE "-fno-exceptions")

if(EXECUTORCH_BUILD_DEVTOOLS)
target_compile_options(
executorch_no_prim_ops PUBLIC -DET_EVENT_TRACER_ENABLED
executorch_core PUBLIC -DET_EVENT_TRACER_ENABLED
)
target_compile_options(coremldelegate PRIVATE "-frtti")
target_compile_options(libprotobuf-lite PRIVATE "-frtti")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
C9E7D7962AB3F9BF00CCAE5D /* KeyValueStoreTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D78E2AB3F9BF00CCAE5D /* KeyValueStoreTests.mm */; };
C9E7D7A22AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D7A12AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm */; };
C9EC7E1B2BC73B3200A6B166 /* MultiArrayTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9EC7E1A2BC73B3200A6B166 /* MultiArrayTests.mm */; };
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */; };
F24817E52BC655E100E80D98 /* libexecutorch_core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F24817E42BC655E100E80D98 /* libexecutorch_core.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -310,7 +310,7 @@
C9EA3FE52B73EF6300B7D7BD /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
C9EC7E092BC662A300A6B166 /* objc_array_util.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = objc_array_util.h; path = ../util/objc_array_util.h; sourceTree = "<group>"; };
C9EC7E1A2BC73B3200A6B166 /* MultiArrayTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MultiArrayTests.mm; path = ../test/MultiArrayTests.mm; sourceTree = "<group>"; };
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libexecutorch_no_prim_ops.a; path = ../libraries/libexecutorch_no_prim_ops.a; sourceTree = "<group>"; };
F24817E42BC655E100E80D98 /* libexecutorch_core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libexecutorch_core.a; path = ../libraries/libexecutorch_core.a; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -319,7 +319,7 @@
buildActionMask = 2147483647;
files = (
C94D510F2ABDF87500AF47FD /* Accelerate.framework in Frameworks */,
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */,
F24817E52BC655E100E80D98 /* libexecutorch_core.a in Frameworks */,
C94D510E2ABDF86800AF47FD /* libsqlite3.tbd in Frameworks */,
C94D50D92ABD7B2400AF47FD /* CoreML.framework in Frameworks */,
C99883862B95AD7D000953A3 /* libprotobuf-lite.a in Frameworks */,
Expand Down Expand Up @@ -540,7 +540,7 @@
C96560942AABFDCE005F8126 /* libsqlite3.tbd */,
C96560922AABF992005F8126 /* CoreML.framework */,
C96560902AABF982005F8126 /* Accelerate.framework */,
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */,
F24817E42BC655E100E80D98 /* libexecutorch_core.a */,
C965608D2AABF72A005F8126 /* libexecutorch.a */,
);
name = "Recovered References";
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/coreml/scripts/build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cmake --build "$CMAKE_PROTOBUF_BUILD_DIR_PATH" -j9 -t libprotobuf-lite
echo "ExecuTorch: Copying libraries"
mkdir "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch.a" "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch_no_prim_ops.a" "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch_core.a" "$LIBRARIES_DIR_PATH"
cp -f "$CMAKE_PROTOBUF_BUILD_DIR_PATH/libprotobuf-lite.a" "$LIBRARIES_DIR_PATH"

#Copy ExecuTorch headers
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/mps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ target_link_libraries(
mpsdelegate
PRIVATE bundled_program
mps_schema
executorch_no_prim_ops
executorch_core
${FOUNDATION_FRAMEWORK}
${METAL_FRAMEWORK}
${MPS_FRAMEWORK}
Expand Down
2 changes: 1 addition & 1 deletion backends/mediatek/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/include)
add_library(neuron_backend SHARED)
target_link_libraries(neuron_backend
PRIVATE
executorch_no_prim_ops
executorch_core
portable_ops_lib
android
log
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ target_link_libraries(
)
target_link_libraries(
qnn_executorch_backend PRIVATE qnn_executorch_header qnn_schema qnn_manager
executorch_no_prim_ops qcir_utils extension_tensor
executorch_core qcir_utils extension_tensor
)
set_target_properties(
qnn_executorch_backend PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'"
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ include(cmake/Dependencies.cmake)
list(TRANSFORM _xnnpack_backend__srcs PREPEND "${EXECUTORCH_ROOT}/")
add_library(xnnpack_backend STATIC ${_xnnpack_backend__srcs})
target_link_libraries(
xnnpack_backend PRIVATE ${xnnpack_third_party} executorch_no_prim_ops
xnnpack_backend PRIVATE ${xnnpack_third_party} executorch_core
xnnpack_schema
)

Expand Down
2 changes: 1 addition & 1 deletion build/Codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function(gen_custom_ops_aot_lib)
if(TARGET portable_lib)
target_link_libraries(${GEN_LIB_NAME} PRIVATE portable_lib)
else()
target_link_libraries(${GEN_LIB_NAME} PRIVATE executorch_no_prim_ops)
target_link_libraries(${GEN_LIB_NAME} PRIVATE executorch_core)
endif()
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion build/build_apple_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PLATFORM_TARGET=("17.0" "17.0" "10.15")

FRAMEWORK_EXECUTORCH="executorch:\
libexecutorch.a,\
libexecutorch_no_prim_ops.a,\
libexecutorch_core.a,\
libextension_apple.a,\
libextension_data_loader.a,\
libextension_module.a,\
Expand Down
Loading

0 comments on commit 905b88c

Please sign in to comment.