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

Function run_cpp_test_runner

backends/mlx/test/test_utils.py:601–656  ·  view source on GitHub ↗

Run the C++ op_test_runner binary. Args: pte_path: Path to the .pte model file. input_path: Path to input .bin file. output_path: Path to write output .bin file. verbose: Whether to print verbose output. timeout: Timeout in seconds. None means use DE

(
    pte_path: Path,
    input_path: Path,
    output_path: Path,
    verbose: bool = False,
    timeout: Optional[int] = None,
)

Source from the content-addressed store, hash-verified

599
600
601def run_cpp_test_runner(
602 pte_path: Path,
603 input_path: Path,
604 output_path: Path,
605 verbose: bool = False,
606 timeout: Optional[int] = None,
607) -> bool:
608 """
609 Run the C++ op_test_runner binary.
610
611 Args:
612 pte_path: Path to the .pte model file.
613 input_path: Path to input .bin file.
614 output_path: Path to write output .bin file.
615 verbose: Whether to print verbose output.
616 timeout: Timeout in seconds. None means use DEFAULT_TEST_TIMEOUT.
617
618 Returns:
619 True if execution succeeded, False otherwise.
620 """
621 if timeout is None:
622 timeout = DEFAULT_TEST_TIMEOUT
623
624 runner = find_op_test_runner()
625
626 cmd = [
627 str(runner),
628 "--pte",
629 str(pte_path),
630 "--input",
631 str(input_path),
632 "--output",
633 str(output_path),
634 ]
635 if verbose:
636 cmd.append("--verbose")
637
638 print(f"Running: {' '.join(cmd)}")
639 try:
640 result = subprocess.run(
641 cmd,
642 capture_output=True,
643 text=True,
644 timeout=timeout,
645 )
646 except subprocess.TimeoutExpired:
647 print(f"TIMEOUT: C++ runner exceeded {timeout}s timeout")
648 return False
649
650 if result.returncode != 0:
651 print(f"FAILED: {result.stderr}")
652 print(f"stdout: {result.stdout}")
653 return False
654
655 print(f"C++ binary output: {result.stdout.strip()}")
656 return True
657
658

Callers 1

run_testMethod · 0.85

Calls 3

find_op_test_runnerFunction · 0.85
appendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected