| 117 | self.mode = debug_mode |
| 118 | |
| 119 | def add(self, node: torch.fx.Node, tosa_op: Any, tosa_op_id: ts.Op) -> DebugSchema: |
| 120 | tosa_debug_info = None |
| 121 | |
| 122 | # If the debug data is being embedded into the TOSA flatbuffer |
| 123 | # do not collect TOSADebugSchema data, it's redundent |
| 124 | if self.mode != ArmCompileSpec.DebugMode.TOSA: |
| 125 | tosa_debug_info = TosaDebugSchema( |
| 126 | node_name=str(tosa_op), |
| 127 | operator_name=str(tosa_op_id), |
| 128 | operator_id=int(tosa_op_id), |
| 129 | ) |
| 130 | |
| 131 | aten_debug_info = ATenDebugSchema.from_node(node) |
| 132 | torch_debug_info = TorchDebugSchema.from_node(node) |
| 133 | |
| 134 | debug_info = DebugSchema( |
| 135 | event_id=len(self._debug_events), |
| 136 | aten_info=aten_debug_info, |
| 137 | tosa_info=tosa_debug_info, |
| 138 | torch_info=torch_debug_info, |
| 139 | ) |
| 140 | self._debug_events.append(debug_info) |
| 141 | |
| 142 | return debug_info |
| 143 | |
| 144 | def serialize(self) -> str: |
| 145 | return json.dumps([event.to_dict() for event in self._debug_events], indent=4) |