From b09d09ea76fd7c1397ef3a169cff8097cb3696a5 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Thu, 27 Jun 2024 15:52:32 +0100 Subject: [PATCH 1/6] Add event tracing and ETDumps to executor_runner - Enabled via EXECUTORCH_ENABLE_EVENT_TRACER - Add flag 'etdump_path' to specify the file path for the ETDump file - Add flag 'num_executions' for number of iterations to run - Create and pass event tracer 'ETDumpGen' - Save ETDump to disk - Update docs to reflect the changes Signed-off-by: Benjamin Klimczak Change-Id: I7e8e8b7f21453bb8d88fa2b9c2ef66c532f3ea46 --- CMakeLists.txt | 5 ++ backends/xnnpack/CMakeLists.txt | 8 ++- ...e-delegates-executorch-xnnpack-delegate.md | 2 +- .../tutorial-xnnpack-delegate-lowering.md | 3 + .../executor_runner/executor_runner.cpp | 60 +++++++++++++++---- 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fd1ce7e6c8..f0969d779ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. +# Copyright 2024 Arm Limited and/or its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the @@ -804,6 +805,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) list(APPEND _executor_runner_libs quantized_ops_lib) endif() + if(EXECUTORCH_ENABLE_EVENT_TRACER) + list(APPEND _executor_runner_libs etdump ${FLATCCRT_LIB}) + endif() + add_executable(executor_runner ${_executor_runner__srcs}) if(CMAKE_BUILD_TYPE STREQUAL "Release") if(APPLE) diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index c22f029c263..7d82483cf4a 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. +# Copyright 2024 Arm Limited and/or its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the @@ -122,8 +123,13 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") # list(TRANSFORM _xnn_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") add_executable(xnn_executor_runner ${_xnn_executor_runner__srcs}) + + if(EXECUTORCH_ENABLE_EVENT_TRACER) + list(APPEND xnn_executor_runner_libs etdump) + endif() + target_link_libraries( - xnn_executor_runner xnnpack_backend gflags portable_ops_lib + xnn_executor_runner gflags portable_ops_lib ${xnn_executor_runner_libs} ) target_compile_options(xnn_executor_runner PUBLIC ${_common_compile_options}) endif() diff --git a/docs/source/native-delegates-executorch-xnnpack-delegate.md b/docs/source/native-delegates-executorch-xnnpack-delegate.md index 41de29687e3..16cbcf5f225 100644 --- a/docs/source/native-delegates-executorch-xnnpack-delegate.md +++ b/docs/source/native-delegates-executorch-xnnpack-delegate.md @@ -74,7 +74,7 @@ Since weight packing creates an extra copy of the weights inside XNNPACK, We fre When executing the XNNPACK subgraphs, we prepare the tensor inputs and outputs and feed them to the XNNPACK runtime graph. After executing the runtime graph, the output pointers are filled with the computed tensors. #### **Profiling** -We have enabled basic profiling for XNNPACK delegate that can be enabled with the following compiler flag `-DENABLE_XNNPACK_PROFILING`. With ExecuTorch's Developer Tools integration, you can also now use the Developer Tools to profile the model. You can follow the steps in [Using the ExecuTorch Developer Tools to Profile a Model](./tutorials/devtools-integration-tutorial) on how to profile ExecuTorch models and use Developer Tools' Inspector API to view XNNPACK's internal profiling information. +We have enabled basic profiling for the XNNPACK delegate that can be enabled with the compiler flag `-DEXECUTORCH_ENABLE_EVENT_TRACER` (add `-DENABLE_XNNPACK_PROFILING` for additional details). With ExecuTorch's Developer Tools integration, you can also now use the Developer Tools to profile the model. You can follow the steps in [Using the ExecuTorch Developer Tools to Profile a Model](./tutorials/devtools-integration-tutorial) on how to profile ExecuTorch models and use Developer Tools' Inspector API to view XNNPACK's internal profiling information. An example implementation is available in the `xnn_executor_runner` (see [tutorial here](tutorial-xnnpack-delegate-lowering.md#profiling)). [comment]: <> (TODO: Refactor quantizer to a more official quantization doc) diff --git a/docs/source/tutorial-xnnpack-delegate-lowering.md b/docs/source/tutorial-xnnpack-delegate-lowering.md index 666ee23aa35..ef2026aea65 100644 --- a/docs/source/tutorial-xnnpack-delegate-lowering.md +++ b/docs/source/tutorial-xnnpack-delegate-lowering.md @@ -172,3 +172,6 @@ Now you should be able to find the executable built at `./cmake-out/backends/xnn ## Building and Linking with the XNNPACK Backend You can build the XNNPACK backend [CMake target](https://github.com/pytorch/executorch/blob/main/backends/xnnpack/CMakeLists.txt#L83), and link it with your application binary such as an Android or iOS application. For more information on this you may take a look at this [resource](demo-apps-android.md) next. + +## Profiling +To enable profiling in the `xnn_executor_runner` pass the flags `-DEXECUTORCH_ENABLE_EVENT_TRACER=ON` and `-DEXECUTORCH_BUILD_SDK=ON` to the build command (add `-DENABLE_XNNPACK_PROFILING=ON` for additional details). This will enable ETDump generation when running the inference and enables command line flags for profiling (see `xnn_executor_runner --help` for details). diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index 93c150c0b90..40540d059bd 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) Meta Platforms, Inc. and affiliates. + * Copyright 2024 Arm Limited and/or its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the @@ -25,10 +26,14 @@ #include #include #include +#include #include #include #include #include +#ifdef ET_EVENT_TRACER_ENABLED +#include +#endif // ET_EVENT_TRACER_ENABLED static uint8_t method_allocator_pool[4 * 1024U * 1024U]; // 4 MB @@ -36,10 +41,18 @@ DEFINE_string( model_path, "model.pte", "Model serialized in flatbuffer format."); +DEFINE_uint32(num_executions, 1, "Number of times to run the model."); +#ifdef ET_EVENT_TRACER_ENABLED +DEFINE_string( + etdump_path, + "model.etdump", + "If ETDump generation is enabled an ETDump will be written out to this path."); +#endif // ET_EVENT_TRACER_ENABLED using executorch::extension::FileDataLoader; using executorch::runtime::Error; using executorch::runtime::EValue; +using executorch::runtime::EventTracer; using executorch::runtime::HierarchicalAllocator; using executorch::runtime::MemoryAllocator; using executorch::runtime::MemoryManager; @@ -151,8 +164,20 @@ int main(int argc, char** argv) { // the method can mutate the memory-planned buffers, so the method should only // be used by a single thread at at time, but it can be reused. // - - Result method = program->load_method(method_name, &memory_manager); + EventTracer* event_tracer_ptr = nullptr; +#ifdef ET_EVENT_TRACER_ENABLED + std::unique_ptr etdump_file( + fopen(FLAGS_etdump_path.c_str(), "w+"), fclose); + ET_CHECK_MSG( + etdump_file, + "Failed to open ETDump file at %s.", + FLAGS_etdump_path.c_str()); + + torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen(); + event_tracer_ptr = &etdump_gen; +#endif // ET_EVENT_TRACER_ENABLED + Result method = + program->load_method(method_name, &memory_manager, event_tracer_ptr); ET_CHECK_MSG( method.ok(), "Loading of method %s failed with status 0x%" PRIx32, @@ -171,18 +196,20 @@ int main(int argc, char** argv) { ET_LOG(Info, "Inputs prepared."); // Run the model. - Error status = method->execute(); - ET_CHECK_MSG( - status == Error::Ok, - "Execution of method %s failed with status 0x%" PRIx32, - method_name, - (uint32_t)status); - ET_LOG(Info, "Model executed successfully."); + for (uint32_t i = 0; i < FLAGS_num_executions; i++) { + Error status = method->execute(); + ET_CHECK_MSG( + status == Error::Ok, + "Execution of method %s failed with status 0x%" PRIx32, + method_name, + (uint32_t)status); + } + ET_LOG(Info, "Model executed successfully %i time(s).", FLAGS_num_executions); // Print the outputs. std::vector outputs(method->outputs_size()); ET_LOG(Info, "%zu outputs: ", outputs.size()); - status = method->get_outputs(outputs.data(), outputs.size()); + Error status = method->get_outputs(outputs.data(), outputs.size()); ET_CHECK(status == Error::Ok); // Print the first and last 100 elements of long lists of scalars. std::cout << executorch::extension::evalue_edge_items(100); @@ -190,5 +217,18 @@ int main(int argc, char** argv) { std::cout << "Output " << i << ": " << outputs[i] << std::endl; } +#ifdef ET_EVENT_TRACER_ENABLED + // Dump the ETDump data containing profiling/debugging data to the specified + // file. + torch::executor::etdump_result result = etdump_gen.get_etdump_data(); + if (result.buf != nullptr && result.size > 0) { + fwrite((uint8_t*)result.buf, 1, result.size, etdump_file.get()); + free(result.buf); + ET_LOG(Info, "ETDump written to file '%s'.", FLAGS_etdump_path.c_str()); + } else { + ET_LOG(Error, "No ETDump data available!"); + } +#endif // ET_EVENT_TRACER_ENABLED + return 0; } From 1a9721fae6e6726cf195f5749e4c68ca0b9ef5e5 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Fri, 10 Jan 2025 12:03:39 +0000 Subject: [PATCH 2/6] Fix comments during code review - Raise a CMake error if event tracing is enabled without the devtools - Re-factoring of the changes in the portable executor_runner - Minor fix in docs Change-Id: Ia50fef8172f678f9cbe2b33e2178780ff983f335 Signed-off-by: Benjamin Klimczak --- CMakeLists.txt | 8 +- backends/xnnpack/CMakeLists.txt | 8 +- .../tutorial-xnnpack-delegate-lowering.md | 2 +- .../executor_runner/executor_runner.cpp | 91 ++++++++++++------- 4 files changed, 73 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7100005d9d..73718bd13f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. -# Copyright 2024 Arm Limited and/or its affiliates. +# Copyright 2024-2025 Arm Limited and/or its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the @@ -824,7 +824,11 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) endif() if(EXECUTORCH_ENABLE_EVENT_TRACER) - list(APPEND _executor_runner_libs etdump ${FLATCCRT_LIB}) + if(EXECUTORCH_BUILD_DEVTOOLS) + list(APPEND _executor_runner_libs etdump ${FLATCCRT_LIB}) + else() + message(SEND_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.") + endif() endif() add_executable(executor_runner ${_executor_runner__srcs}) diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 8f50671d780..a21ef4f6686 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. -# Copyright 2024 Arm Limited and/or its affiliates. +# Copyright 2024-2025 Arm Limited and/or its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the @@ -131,7 +131,11 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") add_executable(xnn_executor_runner ${_xnn_executor_runner__srcs}) if(EXECUTORCH_ENABLE_EVENT_TRACER) - list(APPEND xnn_executor_runner_libs etdump) + if(EXECUTORCH_BUILD_DEVTOOLS) + list(APPEND xnn_executor_runner_libs etdump) + else() + message(SEND_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.") + endif() endif() target_link_libraries( diff --git a/docs/source/tutorial-xnnpack-delegate-lowering.md b/docs/source/tutorial-xnnpack-delegate-lowering.md index a9acadd270b..736b72632ae 100644 --- a/docs/source/tutorial-xnnpack-delegate-lowering.md +++ b/docs/source/tutorial-xnnpack-delegate-lowering.md @@ -179,4 +179,4 @@ Now you should be able to find the executable built at `./cmake-out/backends/xnn You can build the XNNPACK backend [CMake target](https://github.com/pytorch/executorch/blob/main/backends/xnnpack/CMakeLists.txt#L83), and link it with your application binary such as an Android or iOS application. For more information on this you may take a look at this [resource](demo-apps-android.md) next. ## Profiling -To enable profiling in the `xnn_executor_runner` pass the flags `-DEXECUTORCH_ENABLE_EVENT_TRACER=ON` and `-DEXECUTORCH_BUILD_SDK=ON` to the build command (add `-DENABLE_XNNPACK_PROFILING=ON` for additional details). This will enable ETDump generation when running the inference and enables command line flags for profiling (see `xnn_executor_runner --help` for details). +To enable profiling in the `xnn_executor_runner` pass the flags `-DEXECUTORCH_ENABLE_EVENT_TRACER=ON` and `-DEXECUTORCH_BUILD_DEVTOOLS=ON` to the build command (add `-DENABLE_XNNPACK_PROFILING=ON` for additional details). This will enable ETDump generation when running the inference and enables command line flags for profiling (see `xnn_executor_runner --help` for details). diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index 40540d059bd..1ece0c229ba 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) Meta Platforms, Inc. and affiliates. - * Copyright 2024 Arm Limited and/or its affiliates. + * Copyright 2024-2025 Arm Limited and/or its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the @@ -43,10 +43,7 @@ DEFINE_string( "Model serialized in flatbuffer format."); DEFINE_uint32(num_executions, 1, "Number of times to run the model."); #ifdef ET_EVENT_TRACER_ENABLED -DEFINE_string( - etdump_path, - "model.etdump", - "If ETDump generation is enabled an ETDump will be written out to this path."); +DEFINE_string(etdump_path, "model.etdump", "Write ETDump data to this path."); #endif // ET_EVENT_TRACER_ENABLED using executorch::extension::FileDataLoader; @@ -62,6 +59,50 @@ using executorch::runtime::Program; using executorch::runtime::Result; using executorch::runtime::Span; +/// Helper to manage resources for ETDump generation +class EventTraceManager { + public: + EventTraceManager() : event_tracer_ptr_(nullptr) { +#ifdef ET_EVENT_TRACER_ENABLED + event_tracer_ptr_ = std::make_shared(); +#endif // ET_EVENT_TRACER_ENABLED + } + + EventTracer* get_event_tracer() const { + return event_tracer_ptr_.get(); + }; + + Error write_etdump_to_file(const char* filename) const { + torch::executor::ETDumpGen* const etdump_ptr = + static_cast(get_event_tracer()); + if (!etdump_ptr) { + return Error::NotSupported; + } + + std::unique_ptr etdump_file( + fopen(filename, "w+"), fclose); + if (!etdump_file) { + ET_LOG(Error, "Failed to open ETDump file at %s.", filename); + return Error::AccessFailed; + } + + torch::executor::etdump_result result = etdump_ptr->get_etdump_data(); + if (result.buf != nullptr && result.size > 0) { + fwrite((uint8_t*)result.buf, 1, result.size, etdump_file.get()); + free(result.buf); + ET_LOG(Info, "ETDump written to file '%s'.", filename); + } else { + ET_LOG(Error, "No ETDump data available!"); + return Error::NotFound; + } + + return Error::Ok; + } + + private: + std::shared_ptr event_tracer_ptr_; +}; + int main(int argc, char** argv) { executorch::runtime::runtime_init(); @@ -164,20 +205,9 @@ int main(int argc, char** argv) { // the method can mutate the memory-planned buffers, so the method should only // be used by a single thread at at time, but it can be reused. // - EventTracer* event_tracer_ptr = nullptr; -#ifdef ET_EVENT_TRACER_ENABLED - std::unique_ptr etdump_file( - fopen(FLAGS_etdump_path.c_str(), "w+"), fclose); - ET_CHECK_MSG( - etdump_file, - "Failed to open ETDump file at %s.", - FLAGS_etdump_path.c_str()); - - torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen(); - event_tracer_ptr = &etdump_gen; -#endif // ET_EVENT_TRACER_ENABLED - Result method = - program->load_method(method_name, &memory_manager, event_tracer_ptr); + EventTraceManager tracer; + Result method = program->load_method( + method_name, &memory_manager, tracer.get_event_tracer()); ET_CHECK_MSG( method.ok(), "Loading of method %s failed with status 0x%" PRIx32, @@ -204,7 +234,10 @@ int main(int argc, char** argv) { method_name, (uint32_t)status); } - ET_LOG(Info, "Model executed successfully %i time(s).", FLAGS_num_executions); + ET_LOG( + Info, + "Model executed successfully %" PRIu32 " time(s).", + FLAGS_num_executions); // Print the outputs. std::vector outputs(method->outputs_size()); @@ -217,18 +250,14 @@ int main(int argc, char** argv) { std::cout << "Output " << i << ": " << outputs[i] << std::endl; } -#ifdef ET_EVENT_TRACER_ENABLED - // Dump the ETDump data containing profiling/debugging data to the specified - // file. - torch::executor::etdump_result result = etdump_gen.get_etdump_data(); - if (result.buf != nullptr && result.size > 0) { - fwrite((uint8_t*)result.buf, 1, result.size, etdump_file.get()); - free(result.buf); - ET_LOG(Info, "ETDump written to file '%s'.", FLAGS_etdump_path.c_str()); - } else { - ET_LOG(Error, "No ETDump data available!"); + if (tracer.get_event_tracer()) { + // Dump ETDump data containing profiling/debugging data to specified file. + Error status = tracer.write_etdump_to_file(FLAGS_etdump_path.c_str()); + ET_CHECK_MSG( + status == Error::Ok, + "Failed to save ETDump file at %s.", + FLAGS_etdump_path.c_str()); } -#endif // ET_EVENT_TRACER_ENABLED return 0; } From fde58621db6411d7b294671c1a4e0ec8e59ddb86 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Wed, 15 Jan 2025 10:17:20 +0000 Subject: [PATCH 3/6] Small fix for use of flag `FLAGS_etdump` Change-Id: I0ebb22636cdd64aea24bcee51cba05496ed78b1f --- .../executor_runner/executor_runner.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index 1ece0c229ba..aa1a4f2450b 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -72,13 +72,18 @@ class EventTraceManager { return event_tracer_ptr_.get(); }; - Error write_etdump_to_file(const char* filename) const { + Error write_etdump_to_file() const { torch::executor::ETDumpGen* const etdump_ptr = static_cast(get_event_tracer()); if (!etdump_ptr) { return Error::NotSupported; } + const char* filename = nullptr; +#ifdef ET_EVENT_TRACER_ENABLED + filename = FLAGS_etdump_path.c_str(); +#endif // ET_EVENT_TRACER_ENABLED + std::unique_ptr etdump_file( fopen(filename, "w+"), fclose); if (!etdump_file) { @@ -251,12 +256,10 @@ int main(int argc, char** argv) { } if (tracer.get_event_tracer()) { - // Dump ETDump data containing profiling/debugging data to specified file. - Error status = tracer.write_etdump_to_file(FLAGS_etdump_path.c_str()); - ET_CHECK_MSG( - status == Error::Ok, - "Failed to save ETDump file at %s.", - FLAGS_etdump_path.c_str()); + // Dump ETDump data containing profiling/debugging data to file specified in + // command line flag. + Error status = tracer.write_etdump_to_file(); + ET_CHECK_MSG(status == Error::Ok, "Failed to save ETDump file."); } return 0; From 931ddf43bf3cb3cb5761e99ea1c21b0650fc8310 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Wed, 15 Jan 2025 14:20:48 +0000 Subject: [PATCH 4/6] Another fix for case ET_EVENT_TRACER_ENABLED=OFF Change-Id: I7d72e4d8f46ec727a60c9553851d5b71da8e91d4 Signed-off-by: Benjamin Klimczak --- .../portable/executor_runner/executor_runner.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index aa1a4f2450b..3fcb6f5f0e1 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -73,16 +73,16 @@ class EventTraceManager { }; Error write_etdump_to_file() const { - torch::executor::ETDumpGen* const etdump_ptr = - static_cast(get_event_tracer()); - if (!etdump_ptr) { + EventTracer* const event_tracer_ptr = get_event_tracer(); + if (!event_tracer_ptr) { return Error::NotSupported; } - const char* filename = nullptr; #ifdef ET_EVENT_TRACER_ENABLED - filename = FLAGS_etdump_path.c_str(); -#endif // ET_EVENT_TRACER_ENABLED + torch::executor::ETDumpGen* const etdump_ptr = + static_cast(event_tracer_ptr); + + const char* filename = FLAGS_etdump_path.c_str(); std::unique_ptr etdump_file( fopen(filename, "w+"), fclose); @@ -100,6 +100,7 @@ class EventTraceManager { ET_LOG(Error, "No ETDump data available!"); return Error::NotFound; } +#endif // ET_EVENT_TRACER_ENABLED return Error::Ok; } From 42a8b9cb9b23b69055a86f7a08b1d2ec311a5e3e Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Fri, 17 Jan 2025 10:30:51 +0000 Subject: [PATCH 5/6] Revert use of FLATCCRT_LIB to flatccrt Signed-off-by: Benjamin Klimczak Change-Id: I5e7d8ef5d66bc3d5de36ea451b31fb3bdcd42d09 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73718bd13f6..46ee9a204cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -825,7 +825,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) if(EXECUTORCH_ENABLE_EVENT_TRACER) if(EXECUTORCH_BUILD_DEVTOOLS) - list(APPEND _executor_runner_libs etdump ${FLATCCRT_LIB}) + list(APPEND _executor_runner_libs etdump flatccrt) else() message(SEND_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.") endif() From c886ad2a87a25628f8ef0667cc59edef5e40205e Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Fri, 24 Jan 2025 12:03:57 +0000 Subject: [PATCH 6/6] Fix linker issue when building executor_runner - Remove explicit addition of `-DET_EVENT_TRACER_ENABLED` from backends/qualcomm/CMakeLists.txt as setting the definition without enabling cmake flag `EXECUTORCH_ENABLE_EVENT_TRACER` caused issues when building the executor_runner. - Replace deprecated namespace `torch::executor` with `executorch::etdump` in the executor_runner.cpp. Signed-off-by: Benjamin Klimczak Change-Id: Iadff38374e661f42e394dc69903548922ca08aea --- backends/qualcomm/CMakeLists.txt | 6 +----- examples/portable/executor_runner/executor_runner.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index 3c66796594b..bc0f51a236b 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) Qualcomm Innovation Center, Inc. +# Copyright 2025 Arm Limited and/or its affiliates. # All rights reserved # # This source code is licensed under the BSD-style license found in the @@ -199,11 +200,6 @@ target_link_libraries( # target_link_options_shared_lib(qnn_executorch_backend) -# -# add compile option -# -target_compile_options(executorch PUBLIC -DET_EVENT_TRACER_ENABLED) - # # add sources # diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index 3fcb6f5f0e1..cf62d88f26c 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -64,7 +64,7 @@ class EventTraceManager { public: EventTraceManager() : event_tracer_ptr_(nullptr) { #ifdef ET_EVENT_TRACER_ENABLED - event_tracer_ptr_ = std::make_shared(); + event_tracer_ptr_ = std::make_shared(); #endif // ET_EVENT_TRACER_ENABLED } @@ -79,8 +79,8 @@ class EventTraceManager { } #ifdef ET_EVENT_TRACER_ENABLED - torch::executor::ETDumpGen* const etdump_ptr = - static_cast(event_tracer_ptr); + executorch::etdump::ETDumpGen* const etdump_ptr = + static_cast(event_tracer_ptr); const char* filename = FLAGS_etdump_path.c_str(); @@ -91,7 +91,7 @@ class EventTraceManager { return Error::AccessFailed; } - torch::executor::etdump_result result = etdump_ptr->get_etdump_data(); + executorch::etdump::ETDumpResult result = etdump_ptr->get_etdump_data(); if (result.buf != nullptr && result.size > 0) { fwrite((uint8_t*)result.buf, 1, result.size, etdump_file.get()); free(result.buf);