Skip to content

Commit c5c7d93

Browse files
tarun292facebook-github-bot
authored andcommitted
Adding documentation for ETDump (#632)
Summary: Pull Request resolved: #632 Reviewed By: Jack-Khuu Differential Revision: D49945824 Pulled By: tarun292
1 parent 67913e3 commit c5c7d93

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ Topics in this section will help you get started with ExecuTorch.
174174

175175
sdk-overview
176176
sdk-profiling
177-
sdk-debugging
178177
sdk-bundled-io
179178
sdk-delegate-integration
180179
sdk-etdump

docs/source/sdk-etdump.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
# TBD
1+
# ETDump - ExecuTorch Dump
2+
3+
ETDump (ExecuTorch Dump) is one of the core components of the ExecuTorch SDK experience. It is the mechanism through which all forms of profiling and debugging data is extracted from the runtime. Users can't parse ETDump directly; instead, they should pass it into the Inspector API, which deserializes the data, offering interfaces for flexible analysis and debugging.
4+
5+
6+
## Generating an ETDump:
7+
8+
Generating an ETDump is a relatively straight forward process. Users can follow the steps detailed below to integrate it into their application that uses ExecuTorch.
9+
10+
1. ***Include*** the ETDump header in your code.
11+
```C++
12+
#include <executorch/sdk/etdump/etdump_flatcc.h>
13+
```
14+
15+
2. ***Create*** an Instance of the ETDumpGen class and pass it into the `load_method` call that is invoked in the runtime.
16+
17+
```C++
18+
torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen();
19+
Result<Method> method =
20+
program->load_method(method_name, &memory_manager, &etdump_gen);
21+
```
22+
23+
3. ***Dump out the ETDump buffer*** - after the inference iterations have been completed, users can dump out the ETDump buffer. If users are on a device which has a file-system, they could just write it out to the fileystem. For more constrained embedded devices, users will have to extract the ETDump buffer from the device through a mechanism that best suits them (e.g. UART, JTAG etc.)
24+
25+
```C++
26+
etdump_result result = etdump_gen.get_etdump_data();
27+
if (result.buf != nullptr && result.size > 0) {
28+
// On a device with a file system users can just write it out
29+
// to the file-system.
30+
FILE* f = fopen(FLAGS_etdump_path.c_str(), "w+");
31+
fwrite((uint8_t*)result.buf, 1, result.size, f);
32+
fclose(f);
33+
free(result.buf);
34+
}
35+
```
36+
37+
4. ***Compile*** your binary with the flags that enable events to be traced and logged into ETDump inside the ExecuTorch runtime. The pre-processor flag that controls this is `ET_EVENT_TRACER_ENABLED`.
38+
39+
i). ***CMake***
40+
41+
In CMake users can add this to their compile flags:
42+
```
43+
-DET_EVENT_TRACER_ENABLED
44+
```
45+
46+
ii). ***Buck***
47+
48+
In Buck users can simply depend on the etdump target which is:
49+
```
50+
//executorch/sdk/etdump:etdump_flatcc
51+
```
52+
When compiling their binary through Buck, users can pass in this buck config which will enable this pre-processor flag:
53+
```
54+
buck build -c executorch.event_tracer_enabled=true your_binary_target
55+
```
56+
57+
TODO : Point to sample runner in examples here.
58+
59+
## Using an ETDump:
60+
61+
1. Pass this ETDump into the [Inspector API](./sdk-inspector.rst) for access to this data and to do post-run analysis on this data.

0 commit comments

Comments
 (0)