Skip to content

Commit aead1d5

Browse files
authored
Revert "Add event tracing and ETDumps to executor_runner"
Differential Revision: D61362068 Pull Request resolved: #4743
1 parent f25f135 commit aead1d5

File tree

5 files changed

+12
-64
lines changed

5 files changed

+12
-64
lines changed

CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2-
# Copyright 2024 Arm Limited and/or its affiliates.
32
# All rights reserved.
43
#
54
# This source code is licensed under the BSD-style license found in the
@@ -589,10 +588,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
589588
list(APPEND _executor_runner_libs portable_ops_lib)
590589
endif()
591590

592-
if(EXECUTORCH_ENABLE_EVENT_TRACER)
593-
list(APPEND _executor_runner_libs etdump flatccrt)
594-
endif()
595-
596591
# Generate lib to register quantized ops
597592
if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
598593
list(APPEND _executor_runner_libs quantized_ops_lib)

backends/xnnpack/CMakeLists.txt

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2-
# Copyright 2024 Arm Limited and/or its affiliates.
32
# All rights reserved.
43
#
54
# This source code is licensed under the BSD-style license found in the
@@ -121,13 +120,8 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
121120
#
122121
list(TRANSFORM _xnn_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
123122
add_executable(xnn_executor_runner ${_xnn_executor_runner__srcs})
124-
125-
if(EXECUTORCH_ENABLE_EVENT_TRACER)
126-
list(APPEND xnn_executor_runner_libs etdump)
127-
endif()
128-
129123
target_link_libraries(
130-
xnn_executor_runner gflags portable_ops_lib ${xnn_executor_runner_libs}
124+
xnn_executor_runner xnnpack_backend gflags portable_ops_lib
131125
)
132126
target_compile_options(xnn_executor_runner PUBLIC ${_common_compile_options})
133127
endif()

docs/source/native-delegates-executorch-xnnpack-delegate.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Since weight packing creates an extra copy of the weights inside XNNPACK, We fre
7474
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.
7575

7676
#### **Profiling**
77-
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 SDK integration, you can also now use the SDK tools to profile the model. You can follow the steps in [Using the ExecuTorch SDK to Profile a Model](./tutorials/sdk-integration-tutorial) on how to profile ExecuTorch models and use SDK's 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)).
77+
We have enabled basic profiling for XNNPACK delegate that can be enabled with the following compiler flag `-DENABLE_XNNPACK_PROFILING`. With ExecuTorch's SDK integration, you can also now use the SDK tools to profile the model. You can follow the steps in [Using the ExecuTorch SDK to Profile a Model](./tutorials/sdk-integration-tutorial) on how to profile ExecuTorch models and use SDK's Inspector API to view XNNPACK's internal profiling information.
7878

7979

8080
[comment]: <> (TODO: Refactor quantizer to a more official quantization doc)

docs/source/tutorial-xnnpack-delegate-lowering.md

-3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,3 @@ Now you should be able to find the executable built at `./cmake-out/backends/xnn
171171

172172
## Building and Linking with the XNNPACK Backend
173173
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.
174-
175-
## Profiling
176-
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).

examples/portable/executor_runner/executor_runner.cpp

+10-48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
22
* Copyright (c) Meta Platforms, Inc. and affiliates.
3-
* Copyright 2024 Arm Limited and/or its affiliates.
43
* All rights reserved.
54
*
65
* This source code is licensed under the BSD-style license found in the
@@ -30,23 +29,13 @@
3029
#include <executorch/runtime/executor/program.h>
3130
#include <executorch/runtime/platform/log.h>
3231
#include <executorch/runtime/platform/runtime.h>
33-
#ifdef ET_EVENT_TRACER_ENABLED
34-
#include <executorch/sdk/etdump/etdump_flatcc.h>
35-
#endif // ET_EVENT_TRACER_ENABLED
3632

3733
static uint8_t method_allocator_pool[4 * 1024U * 1024U]; // 4 MB
3834

3935
DEFINE_string(
4036
model_path,
4137
"model.pte",
4238
"Model serialized in flatbuffer format.");
43-
DEFINE_uint32(num_executions, 1, "Number of times to run the model.");
44-
#ifdef ET_EVENT_TRACER_ENABLED
45-
DEFINE_string(
46-
etdump_path,
47-
"model.etdump",
48-
"If ETDump generation is enabled an ETDump will be written out to this path.");
49-
#endif // ET_EVENT_TRACER_ENABLED
5039

5140
using namespace torch::executor;
5241
using torch::executor::util::FileDataLoader;
@@ -153,20 +142,8 @@ int main(int argc, char** argv) {
153142
// the method can mutate the memory-planned buffers, so the method should only
154143
// be used by a single thread at at time, but it can be reused.
155144
//
156-
EventTracer* event_tracer_ptr = nullptr;
157-
#ifdef ET_EVENT_TRACER_ENABLED
158-
std::unique_ptr<FILE, decltype(&fclose)> etdump_file(
159-
fopen(FLAGS_etdump_path.c_str(), "w+"), fclose);
160-
ET_CHECK_MSG(
161-
etdump_file,
162-
"Failed to open ETDump file at %s.",
163-
FLAGS_etdump_path.c_str());
164-
165-
torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen();
166-
event_tracer_ptr = &etdump_gen;
167-
#endif // ET_EVENT_TRACER_ENABLED
168-
Result<Method> method =
169-
program->load_method(method_name, &memory_manager, event_tracer_ptr);
145+
146+
Result<Method> method = program->load_method(method_name, &memory_manager);
170147
ET_CHECK_MSG(
171148
method.ok(),
172149
"Loading of method %s failed with status 0x%" PRIx32,
@@ -185,39 +162,24 @@ int main(int argc, char** argv) {
185162
ET_LOG(Info, "Inputs prepared.");
186163

187164
// Run the model.
188-
for (uint32_t i = 0; i < FLAGS_num_executions; i++) {
189-
Error status = method->execute();
190-
ET_CHECK_MSG(
191-
status == Error::Ok,
192-
"Execution of method %s failed with status 0x%" PRIx32,
193-
method_name,
194-
(uint32_t)status);
195-
}
196-
ET_LOG(Info, "Model executed successfully %i time(s).", FLAGS_num_executions);
165+
Error status = method->execute();
166+
ET_CHECK_MSG(
167+
status == Error::Ok,
168+
"Execution of method %s failed with status 0x%" PRIx32,
169+
method_name,
170+
(uint32_t)status);
171+
ET_LOG(Info, "Model executed successfully.");
197172

198173
// Print the outputs.
199174
std::vector<EValue> outputs(method->outputs_size());
200175
ET_LOG(Info, "%zu outputs: ", outputs.size());
201-
Error status = method->get_outputs(outputs.data(), outputs.size());
176+
status = method->get_outputs(outputs.data(), outputs.size());
202177
ET_CHECK(status == Error::Ok);
203178
// Print the first and last 100 elements of long lists of scalars.
204179
std::cout << torch::executor::util::evalue_edge_items(100);
205180
for (int i = 0; i < outputs.size(); ++i) {
206181
std::cout << "Output " << i << ": " << outputs[i] << std::endl;
207182
}
208183

209-
#ifdef ET_EVENT_TRACER_ENABLED
210-
// Dump the ETDump data containing profiling/debugging data to the specified
211-
// file.
212-
etdump_result result = etdump_gen.get_etdump_data();
213-
if (result.buf != nullptr && result.size > 0) {
214-
fwrite((uint8_t*)result.buf, 1, result.size, etdump_file.get());
215-
free(result.buf);
216-
ET_LOG(Info, "ETDump written to file '%s'.", FLAGS_etdump_path.c_str());
217-
} else {
218-
ET_LOG(Error, "No ETDump data available!");
219-
}
220-
#endif // ET_EVENT_TRACER_ENABLED
221-
222184
return 0;
223185
}

0 commit comments

Comments
 (0)