Skip to content

Commit c4a8c77

Browse files
Kaihui-intelpre-commit-ci[bot]XuehaoSun
authored
Add update_g_idx flag for setting qweight&g_idx (#2143)
Signed-off-by: Kaihui-intel <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sun, Xuehao <[email protected]>
1 parent ae65c0d commit c4a8c77

File tree

1 file changed

+7
-0
lines changed
  • neural_compressor/transformers/quantization

1 file changed

+7
-0
lines changed

neural_compressor/transformers/quantization/utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,16 @@ def _replace_linear(
238238
dtype=torch.int32,
239239
device=torch.device(device),
240240
)
241+
242+
# Note: update_g_idx is only applicable for ipex versions >=2.7
241243
model._modules[name].set_weights_bias(
242244
module.qweight.data if hasattr(module, "qweight") else weight,
243245
None if module.bias is None else module.bias.data,
246+
**(
247+
{"update_g_idx": not empty_weights}
248+
if "update_g_idx" in model._modules[name].set_weights_bias.__code__.co_varnames
249+
else {}
250+
),
244251
)
245252
else:
246253
raise Exception("{} device Unsupported weight only quantization!".format(device))

0 commit comments

Comments
 (0)