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

Method push

backends/qualcomm/export_utils.py:366–426  ·  view source on GitHub ↗
(  # noqa: C901
        self,
        inputs=None,
        files=None,
        backends: Optional[Set[QnnExecuTorchBackendType]] = None,
        init_env=True,
    )

Source from the content-addressed store, hash-verified

364 raise RuntimeError(f"adb command failed: {cmds}")
365
366 def push( # noqa: C901
367 self,
368 inputs=None,
369 files=None,
370 backends: Optional[Set[QnnExecuTorchBackendType]] = None,
371 init_env=True,
372 ):
373 # Assume all required files are on device already
374 if self.skip_push:
375 return
376
377 artifacts = [*self.pte_path, f"{self.build_path}/{self.runner}"]
378 if init_env:
379 self._adb(["shell", f"rm -rf {self.workspace}"])
380 self._adb(["shell", f"mkdir -p {self.workspace}"])
381
382 if backends is None:
383 backends = {self.qnn_config.backend}
384
385 # backend libraries
386 for backend in backends:
387 artifacts.extend(self.backend_library_paths[backend])
388
389 # Ensure that all necessary library artifacts exists.
390 missing = [path for path in artifacts if not os.path.exists(path)]
391 assert not missing, "Missing the following libraries:\n" + "\n".join(
392 f" {p}" for p in missing
393 )
394 with tempfile.TemporaryDirectory() as tmp_dir:
395 input_list_file, input_files = generate_inputs(
396 tmp_dir, self.input_list_filename, inputs
397 )
398
399 if input_list_file is not None:
400 # prepare input list
401 artifacts.append(input_list_file)
402
403 for artifact in artifacts:
404 self._adb(["push", artifact, self.workspace])
405
406 # input data
407 for file_name in input_files:
408 self._adb(["push", file_name, self.workspace])
409
410 # dynamic shape related
411 if self.expected_input_shape and self.expected_output_shape:
412 shape_info = {
413 "input_shape": self.expected_input_shape,
414 "output_shape": self.expected_output_shape,
415 }
416 for name, shapes in shape_info.items():
417 with open(f"{tmp_dir}/{name}.txt", "w") as f:
418 for s in shapes:
419 f.write(str(tuple(s)).strip("()") + "\n")
420 self._adb(["push", f"{tmp_dir}/{name}.txt", self.workspace])
421 self.extra_cmds += f" --{name}_path {name}.txt"
422
423 # custom files

Callers 15

setUpClassMethod · 0.95
verify_outputMethod · 0.95
executeFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 5

_adbMethod · 0.95
generate_inputsFunction · 0.85
itemsMethod · 0.80
writeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected