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

Fuse quantized matmul subgraphs for dynamic quantization #540

Open
robertknight opened this issue Jan 16, 2025 · 0 comments
Open

Fuse quantized matmul subgraphs for dynamic quantization #540

robertknight opened this issue Jan 16, 2025 · 0 comments

Comments

@robertknight
Copy link
Owner

Quantizing a model using dynamic quantization will produce subgraphs like this for quantized matmuls:

Image

In text:

Y, Y_zero, Y_scale = DynamicQuantizeLinear(X)
Y = MatMulInteger(Y, W_quant, Y_zero, W_zero)
Y = Cast(Y, to: f32)
Z = Mul(Y_scale, W_scale)
Y = Mul(Y, Z)

Where the W_* values are constants.

The Cast here can obviously be fused into the MatMulInteger op, as could the final Mul op of the float matrix by Z scale vector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant