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

Function get_mlx_node_counts

backends/mlx/test/test_utils.py:401–419  ·  view source on GitHub ↗

Get a count of each MLX op node type in a serialized .pte file. Args: pte_path: Path to the .pte file Returns: Dictionary mapping op name (e.g. "SdpaNode", "SliceUpdateNode") to count.

(pte_path: Union[str, Path])

Source from the content-addressed store, hash-verified

399
400
401def get_mlx_node_counts(pte_path: Union[str, Path]) -> Dict[str, int]:
402 """
403 Get a count of each MLX op node type in a serialized .pte file.
404
405 Args:
406 pte_path: Path to the .pte file
407
408 Returns:
409 Dictionary mapping op name (e.g. "SdpaNode", "SliceUpdateNode") to count.
410 """
411 data = inspect_pte_file(pte_path)
412 graph = data.get("graph", {})
413 counts: Dict[str, int] = {}
414 for chain_info in graph.get("instruction_chains", []):
415 for instr in chain_info.get("instructions", []):
416 op_name = instr.get("op_name")
417 if op_name:
418 counts[op_name] = counts.get(op_name, 0) + 1
419 return counts
420
421
422def compare_outputs(

Callers 1

run_testMethod · 0.85

Calls 2

inspect_pte_fileFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected