Some tool drawio and sequence diagram
This commit is contained in:
@@ -285,6 +285,7 @@ def load_effective_hardware(args: argparse.Namespace) -> dict[str, int]:
|
||||
|
||||
|
||||
def select_pimsim_config(args: argparse.Namespace, hardware: dict[str, int]) -> Path:
|
||||
fallback: Path | None = None
|
||||
for path in sorted(PIMSIM_CONFIG_DIR.glob(f"*/{args.pimsim_mode}_config.json")):
|
||||
with open(path, encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
@@ -297,15 +298,44 @@ def select_pimsim_config(args: argparse.Namespace, hardware: dict[str, int]) ->
|
||||
and matrix["xbar_size"] == [hardware["crossbar_size"]] * 2
|
||||
and network["layout"] == [hardware["mesh_rows"], hardware["mesh_cols"]]
|
||||
and config["sim_config"]["sim_mode"] == (1 if args.pimsim_mode == "latency" else 0)
|
||||
and config["sim_config"]["sim_time"] == args.pimsim_time_ms
|
||||
):
|
||||
return path
|
||||
if config["sim_config"]["sim_time"] == args.pimsim_time_ms:
|
||||
return path
|
||||
fallback = fallback or path
|
||||
if fallback is not None:
|
||||
return fallback
|
||||
raise ValueError(
|
||||
f"No pre-generated {args.pimsim_mode} pimsim-nn config matches "
|
||||
f"{hardware} with sim_time={args.pimsim_time_ms}"
|
||||
f"No pre-generated {args.pimsim_mode} pimsim-nn config matches {hardware}"
|
||||
)
|
||||
|
||||
|
||||
def prepare_pimsim_config(
|
||||
args: argparse.Namespace,
|
||||
hardware: dict[str, int],
|
||||
out_dir: Path,
|
||||
) -> Path:
|
||||
source = select_pimsim_config(args, hardware)
|
||||
with open(source, encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
if config["sim_config"]["sim_time"] == args.pimsim_time_ms:
|
||||
return source
|
||||
|
||||
config["sim_config"]["sim_time"] = args.pimsim_time_ms
|
||||
target = out_dir / "pimsim_config.json"
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")
|
||||
|
||||
network_path = Path(config["chip_config"]["network_config"]["net_config_file_path"])
|
||||
if not network_path.is_absolute():
|
||||
network_path = source.parent / network_path
|
||||
target_network = target.parent / Path(
|
||||
config["chip_config"]["network_config"]["net_config_file_path"]
|
||||
)
|
||||
target_network.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(network_path, target_network)
|
||||
return target
|
||||
|
||||
|
||||
def compile_reference(
|
||||
args: argparse.Namespace,
|
||||
model_path: Path,
|
||||
@@ -1221,6 +1251,8 @@ def main():
|
||||
help="Return a non-zero status if a stage or semantic validation fails.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.pimsim_time_ms <= 0:
|
||||
parser.error("--pimsim-time-ms must be positive")
|
||||
if args.pimcomp_pipeline is None:
|
||||
args.pimcomp_pipeline = "element" if args.pimsim_mode == "latency" else "batch"
|
||||
|
||||
@@ -1485,10 +1517,11 @@ def main():
|
||||
if not args.skip_pimsim_nn and hardware["core_count"] > 0:
|
||||
written_config = try_stage(
|
||||
failures,
|
||||
"Select pimsim-nn config",
|
||||
select_pimsim_config,
|
||||
"Prepare pimsim-nn config",
|
||||
prepare_pimsim_config,
|
||||
args,
|
||||
hardware,
|
||||
out_dir,
|
||||
)
|
||||
if written_config is not None:
|
||||
pimsim_config = written_config
|
||||
@@ -1593,8 +1626,11 @@ def main():
|
||||
"model": str(model_path),
|
||||
"hardware": hardware,
|
||||
"pimsim_mode": args.pimsim_mode,
|
||||
"pimsim_time_ms": args.pimsim_time_ms,
|
||||
"pimcomp_pipeline": args.pimcomp_pipeline,
|
||||
"pimcomp_replication": args.pimcomp_replication,
|
||||
"pimcomp_config": str(args.pimcomp_config),
|
||||
"raptor_extra_args": args.raptor_extra_arg,
|
||||
"reused_raptor_report": optional_path(args.reuse_raptor_report.resolve()) if reuse_raptor else None,
|
||||
"failures": failures,
|
||||
"steps": [asdict(step) for step in steps],
|
||||
|
||||
Reference in New Issue
Block a user