1515
1616try :
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- )
2618except 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
3923from torchgen .gen import LineLoader , parse_native_yaml_struct
4024from 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
125104def _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 :
0 commit comments