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