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

Function execute

examples/qualcomm/util_scripts/cli.py:293–436  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

291
292
293def execute(args):
294 logger = get_logger()
295
296 pte_name = Path(args.artifact).stem
297
298 # get input order
299 from executorch.runtime import Runtime, Verification
300
301 et_runtime = Runtime.get()
302 program = et_runtime.load_program(
303 args.artifact,
304 verification=Verification.Minimal,
305 )
306 try:
307 input_order_func = program.load_method(INPUT_ORDER)
308 except Exception:
309 logger.error(
310 "Missing INPUT_ORDER in the .pte. The CLI execute command only supports .pte files generated by the CLI compile command, which preserves the input order."
311 )
312 exit(1)
313 input_order = input_order_func.execute([])
314
315 # load input files
316 logger.info("loading user inputs")
317 input_list_parser = InputListParser(args.input_list)
318 user_inputs = []
319 for inputs in input_list_parser:
320 if isinstance(inputs, dict):
321 ordered_inputs = []
322 # since io_info is dict and it is ordered in python
323 # we use it to reorder input assignments here
324 for name in input_order:
325 ordered_inputs.append(inputs[name])
326 user_inputs.append(ordered_inputs)
327 else:
328 user_inputs.append(inputs)
329 if args.profile:
330 break
331
332 logger.info("retrieving graph I/O")
333 # setup compiler spec
334 backend_type = get_backend_type(args.backend)
335 match backend_type:
336 case QnnExecuTorchBackendType.kHtpBackend:
337 backend_options = generate_htp_compiler_spec(use_fp16=True)
338 case QnnExecuTorchBackendType.kLpaiBackend:
339 backend_options = generate_lpai_compiler_spec(
340 target_env=QnnExecuTorchLpaiTargetEnv.kArm
341 )
342 case _:
343 raise ValueError("Backend is not implemented yet")
344 # setup general compiler spec for QNN
345 compiler_specs = generate_qnn_executorch_compiler_spec(
346 soc_model=getattr(QcomChipset, args.soc_model),
347 backend_options=backend_options,
348 )
349 io_info = get_io_info(args.artifact, compiler_specs)
350 logger.info("preparing ADB connection")

Callers

nothing calls this directly

Calls 15

pushMethod · 0.95
executeMethod · 0.95
pull_etdumpMethod · 0.95
pullMethod · 0.95
get_backend_typeFunction · 0.90
QnnConfigClass · 0.90
SimpleADBClass · 0.90
InputListParserClass · 0.85
load_programMethod · 0.80

Tested by

no test coverage detected