Skip to content

Commit f252761

Browse files
committed
Testing hack
1 parent afef4fa commit f252761

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

codegen/tools/gen_oplist.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,10 @@
1515

1616
try:
1717
from executorch.codegen.parse import strip_et_fields
18-
from executorch.exir._serialize import _deserialize_pte_binary
19-
from executorch.exir.schema import (
20-
EValue,
21-
KernelCall,
22-
OptionalTensorList,
23-
Tensor,
24-
TensorList
25-
)
2618
except ImportError:
2719
# If we build from source, executorch.codegen is not available.
2820
# We can use relative import instead.
2921
from ..parse import strip_et_fields
30-
from ..exir._serialize import _deserialize_pte_binary
31-
from ..exir.schema import (
32-
EValue,
33-
KernelCall,
34-
OptionalTensorList,
35-
Tensor,
36-
TensorList
37-
)
3822

3923
from torchgen.gen import LineLoader, parse_native_yaml_struct
4024
from torchgen.selective_build.operator import SelectiveBuildOperator
@@ -105,6 +89,7 @@ def _get_operators(model_file: str) -> List[str]:
10589
with open(model_file, "rb") as f:
10690
buf = f.read()
10791

92+
from executorch.exir._serialize import _deserialize_pte_binary
10893
model = _deserialize_pte_binary(buf)
10994
operators = []
11095
for execution_plan in model.execution_plan:
@@ -114,19 +99,27 @@ def _get_operators(model_file: str) -> List[str]:
11499
return operators
115100

116101

117-
def _get_dtypes_from_non_list(evalue: EValue):
118-
kernel_key = ""
119-
if isinstance(evalue, Tensor):
120-
dim_order = ",".join(map(str, evalue.dim_order))
121-
kernel_key += f"{evalue.scalar_type};{dim_order}|"
122-
return kernel_key
123102

124103

125104
def _get_kernel_metadata_for_model(model_file: str) -> Dict[str, List[str]]:
126105
with open(model_file, "rb") as f:
127106
buf = f.read()
128107
op_kernel_key_list: Dict[str, List[str]] = {}
129108

109+
from executorch.exir._serialize import _deserialize_pte_binary
110+
from executorch.exir.schema import (
111+
EValue,
112+
KernelCall,
113+
OptionalTensorList,
114+
Tensor,
115+
TensorList
116+
)
117+
def _get_dtypes_from_non_list(evalue: EValue):
118+
kernel_key = ""
119+
if isinstance(evalue, Tensor):
120+
dim_order = ",".join(map(str, evalue.dim_order))
121+
kernel_key += f"{evalue.scalar_type};{dim_order}|"
122+
return kernel_key
130123
model = _deserialize_pte_binary(buf)
131124
for execution_plan in model.execution_plan:
132125
for chain in execution_plan.chains:

codegen/tools/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def define_common_targets(is_fbcode = False):
2828
main_module = "executorch.codegen.tools.gen_oplist",
2929
deps = [
3030
":gen_oplist_lib",
31-
] + [] if runtime.is_oss else ["//executorch/exir:lib"],
31+
] + [] if runtime.is_oss else ["//executorch/exir:lib"], # TODO This is a hack to run on fbcode. These targets depends on exir which is only available in fbcode.
3232
preload_deps = [] if runtime.is_oss else ["//executorch/codegen/tools/fb:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
3333
package_style = "inplace",
3434
visibility = [

0 commit comments

Comments
 (0)