Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions exir/operator/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def gen_out_variant_schema(func_op_schema: str) -> str:
torch.ops.quantized_decomposed.choose_qparams.tensor,
]
try:
import torchao # noqa: F401
# Import quant_primitives directly to ensure custom ops are registered
# before accessing them via torch.ops.torchao
import torchao.quantization.quant_primitives # noqa: F401

_QUANT_PRIMITIVES.extend(
[
Expand All @@ -64,5 +66,7 @@ def gen_out_variant_schema(func_op_schema: str) -> str:
torch.ops.torchao.choose_qparams_affine.default,
]
)
except ImportError:
except (ImportError, AttributeError):
# ImportError: torchao or quant_primitives not installed
# AttributeError: torchao installed but operators not registered (e.g., older version)
pass
Loading