Skip to content

Conversation

andrey-churkin
Copy link
Contributor

@andrey-churkin andrey-churkin commented Sep 11, 2025

Changes

Add support for the MatMul operation in the Fast Bias/Bias Correction algorithm.

Reason for changes

The Fast Bias/Bias Correction algorithm is not applied to the MatMul->Add subgraph in which one of the inputs to the Add operation is a constant. In this case, the MatMul operation is not considered as having a bias, so the algorithm is not applied.

Related tickets

Ref: 135433

Tests

  • test_update_bias_in_matmul_add
  • text_examples: build

@andrey-churkin andrey-churkin requested a review from a team as a code owner September 11, 2025 09:55
@andrey-churkin andrey-churkin marked this pull request as draft September 11, 2025 09:55
@github-actions github-actions bot added the NNCF PTQ Pull requests that updates NNCF PTQ label Sep 22, 2025
@andrey-churkin andrey-churkin marked this pull request as ready for review October 15, 2025 09:47
op_names = ["MatMul"]
hw_config_names = [HWConfigOpName.MATMUL]
weight_channel_axis = -1 # For port_id=1
bias_port_id = 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not apply to the MatMul ONNX operation, as it does not accept a bias input. Reference: https://onnx.ai/onnx/operators/onnx__MatMul.html

Comment on lines -178 to -181
if bias_value.ndim > 1:
# Make index positive
output_channel_axis = range(bias_value.ndim)[output_channel_axis]
input_channel_axis = range(bias_value.ndim)[input_channel_axis]
Copy link
Contributor Author

@andrey-churkin andrey-churkin Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was moved into create_input_data() because this method does not work properly with a negative channel_axis. The output_channel_axis is converted to positive inside mean_per_channel() method.

@github-actions github-actions bot added the NNCF ONNX Pull requests that updates NNCF ONNX label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Freeze NNCF ONNX Pull requests that updates NNCF ONNX NNCF PTQ Pull requests that updates NNCF PTQ

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants