import subprocess from pathlib import Path from colorama import Fore, Style def compile_with_raptor(network_path, raptor_onnx_path: Path, crossbar_size=64, crossbar_count=16): # Define the arguments, with the possibility to set crossbar size and count args = [ network_path, "--maccel=PIM", "--EmitPIMJSON", "--EmitPimCodegen", # "--use-experimental-conv-impl=true", f"--crossbar-size={crossbar_size}", f"--crossbar-count={crossbar_count}", ] # Run the executable with the arguments try: result = subprocess.run( [str(raptor_onnx_path)] + [str(arg) for arg in args], check=True, capture_output=True, text=True, ) print(result.stdout + Fore.GREEN + "Raptor execution successful" + Style.RESET_ALL) except subprocess.CalledProcessError as e: print(Fore.RED + "Error executing ONNX-MLIR:") print(e.stderr + Style.RESET_ALL)