MCPcopy Create free account
hub / github.com/pytorch/executorch / ETRecord

Class ETRecord

devtools/etrecord/_etrecord.py:60–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class ETRecord:
61 def __init__(
62 self,
63 exported_program: Optional[ExportedProgram] = None,
64 export_graph_id: Optional[int] = None,
65 edge_dialect_program: Optional[
66 Union[ExportedProgram, Dict[str, ExportedProgram]]
67 ] = None,
68 graph_map: Optional[Dict[str, ExportedProgram]] = None,
69 _debug_handle_map: Optional[Dict[int, Union[int, List[int]]]] = None,
70 _delegate_map: Optional[
71 Dict[str, Dict[int, Dict[str, Union[str, _DelegateDebugIdentifierMap]]]]
72 ] = None,
73 _instruction_id_to_num_outs_map: Optional[
74 Dict[str, Dict[int, Union[int, List[int]]]]
75 ] = None,
76 _reference_outputs: Optional[Dict[str, List[ProgramOutput]]] = None,
77 _representative_inputs: Optional[List[ProgramInput]] = None,
78 ):
79 """
80 Please do not construct an ETRecord object directly.
81
82 If you want to create an ETRecord for logging AOT information to further analysis, please mark `generate_etrecord`
83 as True in your export api, and get the ETRecord object from the `ExecutorchProgramManager`.
84 For exmaple:
85 ```python
86 exported_program = torch.export.export(model, inputs)
87 edge_program = to_edge_transform_and_lower(exported_program, generate_etrecord=True)
88 executorch_program = edge_program.to_executorch()
89 etrecord = executorch_program.get_etrecord()
90 ```
91
92 If user need to create an ETRecord manually, please use the `create_etrecord` function.
93
94 **EXPERIMENTAL**: This API supports multiple methods. For example:
95 ```python
96 lowered_and_edge = to_edge_transform_and_lower(
97 {
98 "vision_encoder": vision_encoder_ep,
99 "token_embedding": token_embedding_ep,
100 "text_decoder": causal_llm_ep,
101 },
102 partitioner={
103 "vision_encoder": [XnnpackPartitioner()],
104 "token_embedding": [XnnpackPartitioner()],
105 "text_decoder": [
106 XnnpackPartitioner(
107 config_precisions=ConfigPrecisionType.DYNAMIC_QUANT,
108 per_op_mode=True,
109 ),
110 XnnpackPartitioner(),
111 ],
112 },
113 compile_config=EdgeCompileConfig(_check_ir_validity=False),
114 constant_methods=manager.metadata,
115 generate_etrecord=True, # Enable ETRecord generation for all 3 methods
116 )
117 ```

Calls

no outgoing calls