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

Function _format_arg

exir/print_program.py:191–209  ·  view source on GitHub ↗
(evalue_idx: int)

Source from the content-addressed store, hash-verified

189 values: List[EValue] = execution_plan.values
190
191 def _format_arg(evalue_idx: int) -> str:
192 def _get_io_index(iolist: List[int], target_evalue_idx: int) -> int:
193 """
194 The list is short enough so linear scan is proper.
195 """
196 for io_idx, evalue_idx in enumerate(iolist):
197 if evalue_idx == target_evalue_idx:
198 return io_idx
199 return -1
200
201 argstr = str(evalue_idx)
202 if (input_idx := _get_io_index(inputs, evalue_idx)) >= 0:
203 argstr += f"\033[31mI{input_idx}\033[0m"
204 if (output_idx := _get_io_index(outputs, evalue_idx)) >= 0:
205 argstr += f"\033[31mO{output_idx}\033[0m"
206
207 # EValue type
208 evalue = values[evalue_idx]
209 return argstr + _format_evalue(evalue, show_meminfo, mark_dynamic_shape_tensor)
210
211 print(
212 f"The program contains the following {len(instructions)} instructions", file=out

Callers 1

print_programFunction · 0.85

Calls 2

_get_io_indexFunction · 0.85
_format_evalueFunction · 0.85

Tested by

no test coverage detected