File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1111import torch
1212import torch .nn as nn
1313import torch .nn .functional as F
14-
1514from executorch .exir .scalar_type import ScalarType
1615from torch .library import impl , Library
1716
1817m = Library ("cadence" , "IMPL" , "CompositeExplicitAutograd" )
19- torch .ops .load_library ("//executorch/kernels/quantized:custom_ops_generated_lib" )
18+
19+ try :
20+ torch .ops .load_library ("//executorch/kernels/quantized:custom_ops_generated_lib" )
21+ except (OSError , RuntimeError ):
22+ # Fall back to path-based loading for CMake/OSS builds
23+ from pathlib import Path
24+
25+ custom_libs : list [Path ] = list (
26+ Path (__file__ )
27+ .parent .parent .parent .resolve ()
28+ .glob ("**/kernels/quantized/**/*custom_ops_generated_lib.*" )
29+ )
30+ if custom_libs :
31+ torch .ops .load_library (str (custom_libs [0 ]))
32+ del Path
2033
2134# Registry to track all ops with reference implementations
2235_REGISTERED_REF_IMPLEMENTATIONS : set [str ] = set ()
You can’t perform that action at this time.
0 commit comments