-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
192 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Please this file formatted by running: | ||
# ~~~ | ||
# cmake-format -i CMakeLists.txt | ||
# ~~~ | ||
|
||
cmake_minimum_required(VERSION 3.19) | ||
|
||
# Source root directory for executorch. | ||
if(NOT EXECUTORCH_ROOT) | ||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
endif() | ||
|
||
list(TRANSFORM _extension_flat_tensor__srcs PREPEND "${EXECUTORCH_ROOT}/") | ||
add_library(extension_flat_tensor ${_extension_flat_tensor__srcs}) | ||
target_link_libraries(extension_flat_tensor executorch extension_data_loader) | ||
target_include_directories(extension_flat_tensor PUBLIC | ||
${EXECUTORCH_ROOT}/.. | ||
"${CMAKE_BINARY_DIR}/extension/flat_tensor/include" | ||
"${EXECUTORCH_ROOT}/third-party/flatbuffers/include" | ||
${_common_include_directories}) | ||
target_compile_options(extension_flat_tensor PUBLIC ${_common_compile_options}) | ||
|
||
# Install libraries | ||
install( | ||
TARGETS extension_flat_tensor | ||
DESTINATION lib | ||
INCLUDES | ||
DESTINATION ${_common_include_directories} | ||
) | ||
|
||
# if(BUILD_TESTING) | ||
# add_subdirectory(test) | ||
# endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Flatbuffer schema header lib. Please this file formatted by running: | ||
# ~~~ | ||
# cmake-format -i CMakeLists.txt | ||
# ~~~ | ||
|
||
if(NOT FLATC_EXECUTABLE) | ||
set(FLATC_EXECUTABLE flatc) | ||
endif() | ||
|
||
# The include directory that will contain the generated schema headers. | ||
set(_flat_tensor_schema__include_dir "${CMAKE_BINARY_DIR}/extension/flat_tensor/include") | ||
set(_flat_tensor_schema__output_dir "${_flat_tensor_schema__include_dir}/executorch/extension/flat_tensor/serialize") | ||
# Source root directory for executorch. | ||
if(NOT EXECUTORCH_ROOT) | ||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
endif() | ||
|
||
function(generate_flat_tensor_schema _schema_srcs _schema_name) | ||
set(_schema_outputs) | ||
foreach(fbs_file ${_schema_srcs}) | ||
string(REGEX REPLACE "[.]fbs$" "_generated.h" generated "${fbs_file}") | ||
list(APPEND _schema_outputs | ||
"${_flat_tensor_schema__output_dir}/${generated}" | ||
) | ||
endforeach() | ||
|
||
# Generate the headers from the .fbs files. | ||
add_custom_command( | ||
OUTPUT ${_schema_outputs} | ||
COMMAND | ||
${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o | ||
"${_flat_tensor_schema__output_dir}" ${_schema_srcs} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${FLATC_EXECUTABLE} ${_schema_srcs} | ||
COMMENT "Generating ${_schema_name} headers" | ||
VERBATIM | ||
) | ||
|
||
add_library(${_schema_name} INTERFACE ${_schema_outputs}) | ||
set_target_properties(${_schema_name} PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
# exir lets users set the alignment of tensor data embedded in the flatbuffer, | ||
# and some users need an alignment larger than the default, which is typically | ||
# 32. | ||
target_compile_definitions( | ||
${_schema_name} INTERFACE FLATBUFFERS_MAX_ALIGNMENT=1024 | ||
) | ||
|
||
target_include_directories( | ||
${_schema_name} | ||
INTERFACE ${_flat_tensor_schema__include_dir} | ||
${EXECUTORCH_ROOT}/third-party/flatbuffers/include | ||
) | ||
endfunction() | ||
|
||
# Generate common schema | ||
set(scalar_type_schema_srcs scalar_type.fbs) | ||
generate_flat_tensor_schema("${scalar_type_schema_srcs}" "scalar_type_schema") | ||
|
||
# For the other schemas | ||
set(flat_tensor_schema_srcs flat_tensor.fbs) | ||
generate_flat_tensor_schema("${flat_tensor_schema_srcs}" "flat_tensor_schema") | ||
add_dependencies(flat_tensor_schema scalar_type_schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# @generated by test/utils/generate_gtest_cmakelists.py | ||
# | ||
# This file should be formatted with | ||
# ~~~ | ||
# cmake-format -i CMakeLists.txt | ||
# ~~~ | ||
# It should also be cmake-lint clean. | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.19) | ||
|
||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..) | ||
|
||
include(${EXECUTORCH_ROOT}/build/Test.cmake) | ||
|
||
set(_test_srcs flat_tensor_data_map_test.cpp flat_tensor_header_test.cpp) | ||
|
||
et_cxx_test(extension_flat_tensor_test SOURCES ${_test_srcs} EXTRA_LIBS ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters