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)
| 1048 | |
| 1049 | |
| 1050 | def _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 | |
| 1065 | def generate_cpp_loader_cpp(schema: FBSSchema) -> str: |
no outgoing calls
no test coverage detected