Skip to content

Commit 50b711e

Browse files
committed
Minor changes to event tracing in executor_runner
- Make flag 'num_executions' available in the executor_runner irrespective of the event tracing - Update docs to explain usage of 'ENABLE_XNNPACK_PROFILING' for additional profiling info Signed-off-by: Benjamin Klimczak <[email protected]> Change-Id: I35abbd2d913880cb129bddb80514992f4dd84004
1 parent 1df6f97 commit 50b711e

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
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 XNNPACK delegate that can be enabled with the following compiler flag `-DEXECUTORCH_ENABLE_EVENT_TRACER`. 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 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)).
7878

7979

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ Now you should be able to find the executable built at `./cmake-out/backends/xnn
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.
174174

175175
## 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. This will enable ETDump generation when running the inference and enables command line flags for profiling (see `xnn_executor_runner --help` for details).
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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ DEFINE_string(
4040
model_path,
4141
"model.pte",
4242
"Model serialized in flatbuffer format.");
43+
DEFINE_uint32(num_executions, 1, "Number of times to run the model.");
4344
#ifdef ET_EVENT_TRACER_ENABLED
4445
DEFINE_string(
4546
etdump_path,
4647
"model.etdump",
4748
"If ETDump generation is enabled an ETDump will be written out to this path.");
48-
DEFINE_uint32(num_executions, 10, "Number of times to run the model.");
4949
#endif // ET_EVENT_TRACER_ENABLED
5050

5151
using namespace torch::executor;
@@ -153,7 +153,6 @@ int main(int argc, char** argv) {
153153
// the method can mutate the memory-planned buffers, so the method should only
154154
// be used by a single thread at at time, but it can be reused.
155155
//
156-
uint32_t num_executions = 1;
157156
EventTracer* event_tracer_ptr = nullptr;
158157
#ifdef ET_EVENT_TRACER_ENABLED
159158
std::unique_ptr<FILE, decltype(&fclose)> etdump_file(
@@ -163,7 +162,6 @@ int main(int argc, char** argv) {
163162
"Failed to open ETDump file at %s.",
164163
FLAGS_etdump_path.c_str());
165164

166-
num_executions = FLAGS_num_executions;
167165
torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen();
168166
event_tracer_ptr = &etdump_gen;
169167
#endif // ET_EVENT_TRACER_ENABLED
@@ -187,15 +185,15 @@ int main(int argc, char** argv) {
187185
ET_LOG(Info, "Inputs prepared.");
188186

189187
// Run the model.
190-
for (uint32_t i = 0; i < num_executions; i++) {
188+
for (uint32_t i = 0; i < FLAGS_num_executions; i++) {
191189
Error status = method->execute();
192190
ET_CHECK_MSG(
193191
status == Error::Ok,
194192
"Execution of method %s failed with status 0x%" PRIx32,
195193
method_name,
196194
(uint32_t)status);
197195
}
198-
ET_LOG(Info, "Model executed successfully %i time(s).", num_executions);
196+
ET_LOG(Info, "Model executed successfully %i time(s).", FLAGS_num_executions);
199197

200198
// Print the outputs.
201199
std::vector<EValue> outputs(method->outputs_size());

0 commit comments

Comments
 (0)