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

Function _table_name_to_opcode

backends/mlx/serialization/generate.py:1050–1062  ·  view source on GitHub ↗

Convert table name like 'AddNode' to opcode like 'ADD'. Uses regex-based camelCase → UPPER_SNAKE_CASE conversion with a small override dict for names whose conventional opcode doesn't follow the normal camelCase splitting rules (e.g. Conv1D → CONV1D, not CONV1_D).

(name: str)

Source from the content-addressed store, hash-verified

1048
1049
1050def _table_name_to_opcode(name: str) -> str:
1051 """Convert table name like 'AddNode' to opcode like 'ADD'.
1052
1053 Uses regex-based camelCase → UPPER_SNAKE_CASE conversion with a small
1054 override dict for names whose conventional opcode doesn't follow the
1055 normal camelCase splitting rules (e.g. Conv1D → CONV1D, not CONV1_D).
1056 """
1057 name = name.removesuffix("Node")
1058 if name in _OPCODE_OVERRIDES:
1059 return _OPCODE_OVERRIDES[name]
1060 s = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name)
1061 s = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1_\2", s)
1062 return s.upper()
1063
1064
1065def generate_cpp_loader_cpp(schema: FBSSchema) -> str:

Callers 2

generate_cpp_loader_hFunction · 0.85
_generate_loader_caseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected