|
8 | 8 | from typing import Any, Callable, TextIO, TYPE_CHECKING
|
9 | 9 |
|
10 | 10 | import yaml
|
11 |
| -from executorch.codegen.api import et_cpp |
12 |
| -from executorch.codegen.api.custom_ops import ( |
13 |
| - ComputeNativeFunctionStub, |
14 |
| - gen_custom_ops_registration, |
15 |
| -) |
16 |
| -from executorch.codegen.api.types import contextArg, ExecutorchCppSignature |
17 |
| -from executorch.codegen.api.unboxing import Unboxing |
18 |
| -from executorch.codegen.model import ETKernelIndex, ETKernelKey, ETParsedYaml |
19 |
| -from executorch.codegen.parse import ET_FIELDS, parse_et_yaml, parse_et_yaml_struct |
| 11 | + |
| 12 | +try: |
| 13 | + from executorch.codegen.api import et_cpp |
| 14 | + from executorch.codegen.api.custom_ops import ( |
| 15 | + ComputeNativeFunctionStub, |
| 16 | + gen_custom_ops_registration, |
| 17 | + ) |
| 18 | + from executorch.codegen.api.types import contextArg, ExecutorchCppSignature |
| 19 | + from executorch.codegen.api.unboxing import Unboxing |
| 20 | + from executorch.codegen.model import ETKernelIndex, ETKernelKey, ETParsedYaml |
| 21 | + from executorch.codegen.parse import ET_FIELDS, parse_et_yaml, parse_et_yaml_struct |
| 22 | +except ImportError: |
| 23 | + # If we build from source, executorch.codegen is not available. |
| 24 | + from .api import et_cpp # type: ignore[no-redef] |
| 25 | + from .api.custom_ops import ( # type: ignore |
| 26 | + ComputeNativeFunctionStub, |
| 27 | + gen_custom_ops_registration, |
| 28 | + ) |
| 29 | + from .api.types import contextArg, ExecutorchCppSignature # type: ignore |
| 30 | + from .api.unboxing import Unboxing # type: ignore |
| 31 | + from .model import ETKernelIndex, ETKernelKey, ETParsedYaml # type: ignore |
| 32 | + from .parse import ( # type: ignore[no-redef] |
| 33 | + ET_FIELDS, |
| 34 | + parse_et_yaml, |
| 35 | + parse_et_yaml_struct, |
| 36 | + ) |
20 | 37 |
|
21 | 38 | # Parse native_functions.yaml into a sequence of NativeFunctions and Backend Indices.
|
22 | 39 | from torchgen import dest
|
|
0 commit comments