Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .ci/scripts/test_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,25 @@ prepare_artifacts_upload() {
fi
}


build_cmake_executor_runner() {
local backend_string_select="${1:-}"
echo "Building executor_runner"
rm -rf ${CMAKE_OUTPUT_DIR}
mkdir ${CMAKE_OUTPUT_DIR}
# Common options:
COMMON="-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE"
if [[ "$backend_string_select" == "XNNPACK" ]]; then
echo "Backend $backend_string_select selected"
(cd ${CMAKE_OUTPUT_DIR} \
&& cmake -DCMAKE_BUILD_TYPE=Release \
cmake -DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
${COMMON} \
-B${CMAKE_OUTPUT_DIR} .
cmake --build ${CMAKE_OUTPUT_DIR} -j4
else
cmake -DCMAKE_BUILD_TYPE=Debug \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
${COMMON} \
-B${CMAKE_OUTPUT_DIR} .
cmake --build ${CMAKE_OUTPUT_DIR} -j4 --config Debug
fi
Expand Down
7 changes: 4 additions & 3 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ build_executorch_runner_cmake() {
clean_executorch_install_folders
mkdir "${CMAKE_OUTPUT_DIR}"

pushd "${CMAKE_OUTPUT_DIR}" || return
if [[ $1 == "Debug" ]]; then
CXXFLAGS="-fsanitize=address,undefined"
else
CXXFLAGS=""
fi
CXXFLAGS="$CXXFLAGS" retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE="${1:-Release}" ..
popd || return
CXXFLAGS="$CXXFLAGS" retry cmake \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-DCMAKE_BUILD_TYPE="${1:-Release}" \
-B${CMAKE_OUTPUT_DIR} .

if [ "$(uname)" == "Darwin" ]; then
CMAKE_JOBS=$(( $(sysctl -n hw.ncpu) - 1 ))
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
extension_runner_util gflags executorch_backends
)

if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
list(APPEND _executor_runner_libs extension_flat_tensor)
endif()

if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
list(APPEND _executor_runner_libs optimized_native_cpu_ops_lib)
elseif(EXECUTORCH_BUILD_CADENCE)
Expand Down
10 changes: 8 additions & 2 deletions examples/portable/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")

add_executable(custom_ops_executor_runner ${_executor_runner__srcs})
target_link_libraries(
custom_ops_executor_runner custom_ops_lib executorch extension_evalue_util
extension_runner_util gflags
custom_ops_executor_runner
custom_ops_lib
executorch
extension_evalue_util
extension_runner_util
gflags
extension_data_loader
extension_flat_tensor
)
target_compile_options(
custom_ops_executor_runner PUBLIC ${_common_compile_options}
Expand Down
36 changes: 35 additions & 1 deletion examples/portable/executor_runner/executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <executorch/extension/data_loader/file_data_loader.h>
#include <executorch/extension/evalue_util/print_evalue.h>
#include <executorch/extension/flat_tensor/flat_tensor_data_map.h>
#include <executorch/extension/runner_util/inputs.h>
#include <executorch/runtime/core/event_tracer.h>
#include <executorch/runtime/executor/method.h>
Expand All @@ -50,6 +51,7 @@ DEFINE_string(
model_path,
"model.pte",
"Model serialized in flatbuffer format.");
DEFINE_string(data_path, "", "Path to data file.");
DEFINE_string(inputs, "", "Comma-separated list of input files");
DEFINE_string(
output_file,
Expand All @@ -72,6 +74,7 @@ DEFINE_int32(
using executorch::aten::ScalarType;
using executorch::aten::Tensor;
using executorch::extension::FileDataLoader;
using executorch::extension::FlatTensorDataMap;
using executorch::runtime::Error;
using executorch::runtime::EValue;
using executorch::runtime::EventTracer;
Expand Down Expand Up @@ -171,6 +174,34 @@ int main(int argc, char** argv) {
"FileDataLoader::from() failed: 0x%" PRIx32,
(uint32_t)loader.error());

// Load .ptd file if provided
std::unique_ptr<FileDataLoader> ptd_loader;
std::unique_ptr<FlatTensorDataMap> ptd_data_map;
if (!FLAGS_data_path.empty()) {
const char* data_path = FLAGS_data_path.c_str();
Result<FileDataLoader> ptd_loader_result = FileDataLoader::from(data_path);
ET_CHECK_MSG(
ptd_loader_result.ok(),
"FileDataLoader::from() failed for PTD file: 0x%" PRIx32,
(uint32_t)ptd_loader_result.error());
ptd_loader =
std::make_unique<FileDataLoader>(std::move(ptd_loader_result.get()));
ET_LOG(Info, "PTD file %s is loaded.", data_path);

Result<FlatTensorDataMap> ptd_data_map_result =
FlatTensorDataMap::load(ptd_loader.get());
ET_CHECK_MSG(
ptd_data_map_result.ok(),
"FlatTensorDataMap::load() failed for PTD file: 0x%" PRIx32,
(uint32_t)ptd_data_map_result.error());
ptd_data_map = std::make_unique<FlatTensorDataMap>(
std::move(ptd_data_map_result.get()));
ET_LOG(
Info,
"PTD data map created with %" PRIu64 " keys.",
static_cast<uint64_t>(ptd_data_map->get_num_keys().get()));
}

std::vector<std::string> inputs_storage;
std::vector<std::pair<char*, size_t>> input_buffers;

Expand Down Expand Up @@ -294,7 +325,10 @@ int main(int argc, char** argv) {
//
EventTraceManager tracer;
Result<Method> method = program->load_method(
method_name, &memory_manager, tracer.get_event_tracer());
method_name,
&memory_manager,
tracer.get_event_tracer(),
ptd_data_map.get());
ET_CHECK_MSG(
method.ok(),
"Loading of method %s failed with status 0x%" PRIx32,
Expand Down
2 changes: 2 additions & 0 deletions examples/portable/executor_runner/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def define_common_targets():
"//executorch/devtools/etdump:etdump_flatcc",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/evalue_util:print_evalue",
"//executorch/extension/flat_tensor:flat_tensor_data_map",
"//executorch/extension/runner_util:inputs",
],
external_deps = [
Expand All @@ -38,6 +39,7 @@ def define_common_targets():
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/evalue_util:print_evalue",
"//executorch/extension/flat_tensor:flat_tensor_data_map",
"//executorch/extension/runner_util:inputs",
"//executorch/extension/threadpool:cpuinfo_utils",
"//executorch/extension/threadpool:threadpool",
Expand Down
9 changes: 7 additions & 2 deletions examples/selective_build/advanced/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
target_link_libraries(
selective_build_test
PRIVATE executorch_core extension_evalue_util extension_runner_util
gflags::gflags ${selected_kernel_target}
PRIVATE executorch_core
extension_evalue_util
extension_runner_util
gflags::gflags
extension_flat_tensor
extension_data_loader
${selected_kernel_target}
)
target_compile_options(selective_build_test PUBLIC ${_common_compile_options})
9 changes: 7 additions & 2 deletions examples/selective_build/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
target_link_libraries(
selective_build_test
PRIVATE executorch_core extension_evalue_util extension_runner_util
gflags::gflags executorch_kernels
PRIVATE executorch_core
extension_evalue_util
extension_runner_util
gflags::gflags
executorch_kernels
extension_data_loader
extension_flat_tensor
)
target_compile_options(selective_build_test PUBLIC ${_common_compile_options})
2 changes: 1 addition & 1 deletion extension/flat_tensor/flat_tensor_data_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Result<const flat_tensor_flatbuffer::NamedData*> get_named_data(
if (named_data == nullptr) {
return Error::NotFound;
}
for (int i = 0; i < named_data->size(); i++) {
for (flatbuffers::uoffset_t i = 0; i < named_data->size(); ++i) {
if (key.size() == named_data->Get(i)->key()->size() &&
std::strncmp(
named_data->Get(i)->key()->c_str(),
Expand Down
2 changes: 2 additions & 0 deletions extension/flat_tensor/serialize/flat_tensor_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <executorch/runtime/core/error.h>
#include <executorch/runtime/core/result.h>

#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated"
#endif

namespace executorch {
using runtime::Error;
Expand Down
3 changes: 2 additions & 1 deletion tools/cmake/preset/arm_baremetal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER OFF)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR OFF)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF)
set_overridable_option(EXECUTORCH_BUILD_ARM_BAREMETAL ON)
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
Expand All @@ -18,7 +20,6 @@ define_overridable_option(
if("${EXECUTORCH_BUILD_ARM_ETDUMP}")
set(EXECUTORCH_BUILD_DEVTOOLS ON)
set(EXECUTORCH_ENABLE_EVENT_TRACER ON)
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF)
set(FLATCC_ALLOW_WERROR OFF)
else()
set(EXECUTORCH_ENABLE_EVENT_TRACER OFF)
Expand Down
4 changes: 2 additions & 2 deletions tools/cmake/preset/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ define_overridable_option(
)
define_overridable_option(
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "Build the Data Loader extension" BOOL
OFF
ON # Required by executor_runner
)
define_overridable_option(
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR "Build the Flat Tensor extension" BOOL
OFF
ON # Required by executor_runner
)
define_overridable_option(
EXECUTORCH_BUILD_EXTENSION_LLM "Build the LLM extension" BOOL OFF
Expand Down
Loading