(
*,
native_functions: Sequence[NativeFunction],
kernel_index: ETKernelIndex,
native_function_decl_gen: Callable[
[
NativeFunctionsGroup | NativeFunction,
ETKernelIndex,
],
list[str],
],
)
| 445 | |
| 446 | |
| 447 | def get_ns_grouped_kernels( |
| 448 | *, |
| 449 | native_functions: Sequence[NativeFunction], |
| 450 | kernel_index: ETKernelIndex, |
| 451 | native_function_decl_gen: Callable[ |
| 452 | [ |
| 453 | NativeFunctionsGroup | NativeFunction, |
| 454 | ETKernelIndex, |
| 455 | ], |
| 456 | list[str], |
| 457 | ], |
| 458 | ) -> dict[str, list[str]]: |
| 459 | ns_grouped_kernels: dict[str, list[str]] = defaultdict(list) |
| 460 | for f in native_functions: |
| 461 | native_function_namespaces = set() |
| 462 | op_kernels = kernel_index.get_kernels(f) |
| 463 | for backend_metadata in op_kernels.values(): |
| 464 | if backend_metadata: |
| 465 | namespace = backend_metadata.cpp_namespace |
| 466 | native_function_namespaces.add(namespace) |
| 467 | else: |
| 468 | namespace = DEFAULT_KERNEL_NAMESPACE |
| 469 | assert ( |
| 470 | len(native_function_namespaces) <= 1 |
| 471 | ), f"Codegen only supports one namespace per operator, got {native_function_namespaces}" |
| 472 | ns_grouped_kernels[namespace].extend( |
| 473 | native_function_decl_gen(f, kernel_index) |
| 474 | ) |
| 475 | return ns_grouped_kernels |
| 476 | |
| 477 | |
| 478 | def gen_headers( |
no test coverage detected