Prerequisite | ETRecord - ExecuTorch Record¶
Overview¶
ETRecord
is intended to be the debug artifact that is generated by
users ahead of time (when they export their model to run on ExecuTorch).
To draw a rough equivalent to conventional software development,
ETRecord
can be considered as the binary built with debug symbols
that is used for debugging in GNU Debugger (gdb). It is expected that
the user will supply this to the ExecuTorch SDK tooling in order for
them to debug and visualize their model.
ETRecord
contains numerous components such as:
Edge dialect graph with debug handles
Delegate debug handle maps
The ETRecord
object itself is intended to be transparent to users and they should not access any components inside it directly.
It should be provided to the Inspector API to link back performance and debug data sourced from the runtime back to the Python source code.
APIs¶
There are two important APIs users must be aware of when dealing with
ETRecord
: generate_etrecord()
and parse_etrecord()
.
Generating an ETRecord
File¶
The user should use the following API to generate an ETRecord
file. They
will be expected to provide the Edge Dialect program (returned by the call to to_edge()
),
the ExecuTorch program (returned by the call to to_executorch()
), and optional models that
they are interested in working with via our tooling.
- sdk.etrecord._etrecord.generate_etrecord(etrecord_path, edge_dialect_program, executorch_program, export_modules=None)[source]¶
Generates an ETRecord from the given objects, serializes it and saves it to the given path. The objects that will be serialized to an ETRecord are all the graph modules present in the export_modules dict, the graph module present in the edge dialect program object, and also the graph module present in the ExecuTorch program object, which is the closest graph module representation of what is eventually run on the device. In addition to all the graph modules, we also serialize the program buffer, which the users can provide to the ExecuTorch runtime to run the model, and the debug handle map for SDK tooling usage.
- Parameters
etrecord_path – Path to where the ETRecord file will be saved to.
edge_dialect_program – ExirExportedProgram for this model returned by the call to to_edge()
executorch_program – ExecutorchProgram or MultiMethodExecutorchProgram for this model returned by the call to to_executorch()
export_modules – A dictionary of graph modules with the key being the user provided name and the value being the corresponding exported module. The exported graph modules can be either the output of capture() or to_edge().
- Returns
None
Parsing an ETRecord
¶
- sdk.etrecord._etrecord.parse_etrecord(etrecord_path)[source]¶
Parses an ETRecord file and returns an ETRecord object that contains the deserialized graph modules, program buffer, and a debug handle map. In the graph map in the returned ETRecord object if a model with multiple entry points was provided originally by the user during ETRecord generation then each entry point will be stored as a separate graph module in the ETRecord object with the name being the original module name + “/” + the name of the entry point.
- Parameters
etrecord_path – Path to the ETRecord file.
- Returns
ETRecord object.