Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RTN supported layer checking condition #1705

Merged
merged 3 commits into from
Apr 2, 2024
Merged
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
4 changes: 2 additions & 2 deletions neural_compressor/adaptor/torch_utils/weight_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def rtn_quantize(
model: fake quantized torch module
"""
assert isinstance(model, torch.nn.Module), "only support torch module"
supported_layers = ["Linear"]
supported_layers = (torch.nn.Linear,)
if return_int:
compression_dtype = kwargs.get("compression_dtype", torch.int32)
compression_dim = kwargs.get("compression_dim", 1)
Expand All @@ -407,7 +407,7 @@ def rtn_quantize(
use_optimum_format = kwargs.get("use_optimum_format", True)
with torch.no_grad():
for name, m in model.named_modules():
if m.__class__.__name__ not in supported_layers:
if not isinstance(m, supported_layers):
continue
orig_dtype = next(m.parameters()).dtype
if orig_dtype != torch.float:
Expand Down
Loading