| 196 | |
| 197 | |
| 198 | def create_kernel_key(maybe_kernel_key: str) -> str: |
| 199 | # It is a kernel key. |
| 200 | if maybe_kernel_key.lstrip().startswith("v1"): |
| 201 | return maybe_kernel_key |
| 202 | # It is a dtype. |
| 203 | else: |
| 204 | # Generate a kernel key based on the dtype provided. |
| 205 | # Note: no dim order is included in this kernel key. |
| 206 | # For a description of the kernel key format, see |
| 207 | # executorch/blob/main/runtime/kernel/operator_registry.h#L97-L123 |
| 208 | try: |
| 209 | dtype = ScalarType[maybe_kernel_key] |
| 210 | return "v1/" + str(dtype.value) + ";" |
| 211 | except KeyError: |
| 212 | raise Exception(f"Unknown dtype: {maybe_kernel_key}") |
| 213 | |
| 214 | |
| 215 | def gen_oplist( |