File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 30
30
TORCHGEN_DIR = Path (torchgen .__path__ [0 ]).resolve ()
31
31
TORCH_MLIR_DIR = Path (__file__ ).resolve ().parent .parent
32
32
33
+ # Safely load fast C Yaml loader if it is are available
34
+ try :
35
+ from yaml import CSafeLoader as Loader
36
+ except ImportError :
37
+ from yaml import SafeLoader as Loader #type:ignore[assignment, misc]
33
38
34
39
def reindent (text , prefix = "" ):
35
40
return indent (dedent (text ), prefix )
@@ -175,7 +180,7 @@ def generate_native_functions(self):
175
180
)
176
181
ts_native_yaml = None
177
182
if ts_native_yaml_path .exists ():
178
- ts_native_yaml = yaml .load (ts_native_yaml_path .read_text (), yaml . CLoader )
183
+ ts_native_yaml = yaml .load (ts_native_yaml_path .read_text (), Loader )
179
184
else :
180
185
logging .warning (
181
186
f"Could not find `ts_native_functions.yaml` at { ts_native_yaml_path } "
@@ -208,7 +213,7 @@ def get_opnames(ops):
208
213
)
209
214
210
215
with self .config_path .open () as f :
211
- config = yaml .load (f , yaml . CLoader )
216
+ config = yaml .load (f , Loader )
212
217
213
218
# List of unsupported ops in LTC autogen because of some error
214
219
blacklist = set (config .get ("blacklist" , []))
You can’t perform that action at this time.
0 commit comments