Given a loaded yaml representing a list of operators, for each op extract the mapping of `kernel keys` to `BackendMetadata` (the latter representing the kernel instance that should be used by the kernel key).
(es: object)
| 72 | |
| 73 | |
| 74 | def parse_et_yaml_struct(es: object) -> ETKernelIndex: |
| 75 | """Given a loaded yaml representing a list of operators, for each op extract the mapping |
| 76 | of `kernel keys` to `BackendMetadata` (the latter representing the kernel instance |
| 77 | that should be used by the kernel key). |
| 78 | """ |
| 79 | indices: Dict[OperatorName, Dict[ETKernelKey, BackendMetadata]] = {} |
| 80 | for ei in es: # type: ignore[attr-defined] |
| 81 | e = ei.copy() |
| 82 | |
| 83 | funcs = e.pop("func") |
| 84 | assert isinstance(funcs, str), f"not a str: {funcs}" |
| 85 | namespace_helper = NamespaceHelper.from_namespaced_entity( |
| 86 | namespaced_entity=funcs, max_level=1 |
| 87 | ) |
| 88 | opname = FunctionSchema.parse(namespace_helper.entity_name).name |
| 89 | |
| 90 | assert opname not in indices, f"Duplicate func found in yaml: {opname} already" |
| 91 | |
| 92 | if len(index := parse_from_yaml(e)) != 0: |
| 93 | indices[opname] = index |
| 94 | |
| 95 | return ETKernelIndex(indices) |
| 96 | |
| 97 | |
| 98 | def extract_kernel_fields(es: object) -> Dict[OperatorName, Dict[str, Any]]: |
no test coverage detected
searching dependent graphs…