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

Exclude nodes for quantization #2114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions neural_compressor/adaptor/ox_utils/weight_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def rtn_quantize(
ratios={},
accuracy_level=0,
providers=["CPUExecutionProvider"],
nodes_to_exclude=[],
):
"""Quant the model with round to nearst method.

Expand All @@ -323,6 +324,7 @@ def rtn_quantize(
2 (fp16 compute type of jblas kernel), 3 (bf16 compute type of jblas kernel),
4 (int8 compute type of jblas kernel)
providers (list): providers to use
nodes_to_exclude (list): nodes to exclude quantization.

Returns:
model: fake quantized ONNXModel
Expand All @@ -334,6 +336,8 @@ def rtn_quantize(
total_num = len([i for i in model.nodes() if i.op_type in ["MatMul"]])
curr_id = 0
for node in model.nodes():
if node.name in nodes_to_exclude:
continue
if node.op_type in ["MatMul"]:
curr_id += 1
simple_progress_bar(total_num, curr_id)
Expand Down
Loading