fix relative paths in validation scripts
This commit is contained in:
@@ -244,6 +244,7 @@ def gen_network_runner(network_onnx, network_so, onnx_include_dir, entry="run_ma
|
||||
ins, outs = onnx_io(network_onnx)
|
||||
out_c = out or "runner.c"
|
||||
so_abs = os.path.abspath(network_so)
|
||||
onnx_include_dir = str(onnx_include_dir)
|
||||
|
||||
csrc = gen_c(ins, outs, entry, pathlib.Path(so_abs).name)
|
||||
pathlib.Path(out_c).write_text(csrc)
|
||||
|
||||
@@ -7,10 +7,6 @@ from colorama import Style, Fore
|
||||
from validate_one import validate_network
|
||||
|
||||
|
||||
def discover_onnx_files(operations_dir):
|
||||
return sorted(operations_dir.rglob("*.onnx"))
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Validate all ONNX operations under the operations/ directory.")
|
||||
ap.add_argument("--raptor-path", required=True, help="Path to the Raptor compiler binary.")
|
||||
@@ -24,8 +20,8 @@ def main():
|
||||
a = ap.parse_args()
|
||||
|
||||
script_dir = Path(__file__).parent.resolve()
|
||||
operations_dir = Path(a.operations_dir) if a.operations_dir else script_dir / "operations"
|
||||
simulator_dir = Path(a.simulator_dir) if a.simulator_dir else (
|
||||
operations_dir = Path(a.operations_dir).resolve() if a.operations_dir else script_dir / "operations"
|
||||
simulator_dir = Path(a.simulator_dir).resolve() if a.simulator_dir else (
|
||||
script_dir / ".." / "backend-simulators" / "pim" / "pim-simulator"
|
||||
)
|
||||
|
||||
@@ -33,7 +29,7 @@ def main():
|
||||
print(Fore.RED + f"Operations directory not found: {operations_dir}" + Style.RESET_ALL)
|
||||
sys.exit(1)
|
||||
|
||||
onnx_files = discover_onnx_files(operations_dir)
|
||||
onnx_files = sorted(operations_dir.rglob("*.onnx"))
|
||||
if not onnx_files:
|
||||
print(Fore.YELLOW + f"No .onnx files found under {operations_dir}" + Style.RESET_ALL)
|
||||
sys.exit(1)
|
||||
@@ -46,15 +42,11 @@ def main():
|
||||
header = f"{'=' * 60}\n Validating: {rel}\n{'=' * 60}"
|
||||
print(Style.BRIGHT + Fore.CYAN + header + Style.RESET_ALL)
|
||||
|
||||
try:
|
||||
passed = validate_network(
|
||||
onnx_path, a.raptor_path, a.onnx_include_dir, simulator_dir,
|
||||
crossbar_size=a.crossbar_size, crossbar_count=a.crossbar_count,
|
||||
threshold=a.threshold,
|
||||
)
|
||||
except Exception as e:
|
||||
print(Fore.RED + f" ERROR: {e}" + Style.RESET_ALL)
|
||||
passed = False
|
||||
passed = validate_network(
|
||||
onnx_path, a.raptor_path, a.onnx_include_dir, simulator_dir,
|
||||
crossbar_size=a.crossbar_size, crossbar_count=a.crossbar_count,
|
||||
threshold=a.threshold,
|
||||
)
|
||||
|
||||
results[str(rel)] = passed
|
||||
|
||||
|
||||
@@ -78,7 +78,11 @@ def validate_outputs(sim_arrays, runner_out_dir, outputs_descriptor, threshold=1
|
||||
|
||||
def validate_network(network_onnx_path, raptor_path, onnx_include_dir,
|
||||
simulator_dir, crossbar_size=64, crossbar_count=8, threshold=1e-3):
|
||||
network_onnx_path = Path(network_onnx_path).absolute()
|
||||
network_onnx_path = Path(network_onnx_path).resolve()
|
||||
raptor_path = Path(raptor_path).resolve()
|
||||
onnx_include_dir = Path(onnx_include_dir).resolve()
|
||||
simulator_dir = Path(simulator_dir).resolve()
|
||||
|
||||
workspace_dir = network_onnx_path.parent
|
||||
raptor_dir = workspace_dir / "raptor"
|
||||
runner_dir = workspace_dir / "runner"
|
||||
@@ -95,7 +99,7 @@ def validate_network(network_onnx_path, raptor_path, onnx_include_dir,
|
||||
|
||||
print(Style.BRIGHT + "\nGenerating random inputs:" + Style.RESET_ALL)
|
||||
inputs_descriptor, outputs_descriptor = onnx_io(network_onnx_path)
|
||||
inputs_list, inputs_dict = gen_random_inputs(inputs_descriptor)
|
||||
inputs_list, _inputs_dict = gen_random_inputs(inputs_descriptor)
|
||||
flags, _files = save_inputs_to_files(network_onnx_path, inputs_list, out_dir=workspace_dir / "inputs")
|
||||
|
||||
print(Style.BRIGHT + "\nRunning inference with the runner:" + Style.RESET_ALL)
|
||||
|
||||
Reference in New Issue
Block a user