Skip to content

Commit a4286cd

Browse files
committed
Adding documentation for ETDump
1 parent 86449bf commit a4286cd

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

docs/source/index.rst

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

163163
sdk-overview
164164
sdk-profiling
165-
sdk-debugging
166165
sdk-bundled-io
167166
sdk-delegate-integration
168167
sdk-etdump

docs/source/sdk-debugging.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/source/sdk-etdump.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
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 pretty trivial. 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.
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 you've completed your inference iterations 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+
In Buck users can simply depend on the etdump target which is:
48+
```
49+
//executorch/sdk/etdump:etdump_flatcc
50+
```
51+
When compiling their binary through Buck users can pass in this buck config which will enable this pre-processor flag:
52+
```
53+
buck build -c executorch.event_tracer_enabled=true your_binary_target
54+
```
55+
56+
TODO : Point to sample runner in examples here.
57+
58+
59+
5. Pass this ETDump into the [Inspector API](./sdk-inspector.md) for access to this data and to do post-run analysis on this data.

0 commit comments

Comments
 (0)