Skip to content

MLAS: optimize QuantizeLinear - #2660

Merged
tracysh merged 4 commits into
masterfrom
tracysh/quantize
Dec 16, 2019
Merged

MLAS: optimize QuantizeLinear#2660
tracysh merged 4 commits into
masterfrom
tracysh/quantize

Conversation

@tracysh

@tracysh tracysh commented Dec 15, 2019

Copy link
Copy Markdown
Contributor

Description:
This adds MLAS support to quantize a buffer using vector instructions for x86/x64/ARM64. This helper is now used for the QuantizeLinear and DynamicQuantizeLinear ops.

Motivation and Context
The old implementation had a significant cost from using the C runtime to do rounding and also didn't benefit from SIMD access. The new version should be bit identical to the old version. On x64 Windows, a sample quantized resnet50 model goes from 420ms->130ms.

The ARM32 build continues to the use the C runtime. A vectorized implementation is possible here too, but stick in ARMv7A NEON, such an implementation would require dropping to assembly and that's not worth it at this point.

An AVX+ implementation is also possible, but also not worth it at this point as the test quantized models are now dominated by GEMM and MlasQuantizeLinear is a small % of the runtime.

@tracysh
tracysh requested a review from askhade December 15, 2019 20:22
@tracysh
tracysh requested a review from a team as a code owner December 15, 2019 20:22

@snnn snnn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome!

@tracysh
tracysh merged commit c907881 into master Dec 16, 2019
@tracysh
tracysh deleted the tracysh/quantize branch December 16, 2019 18:56
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

Successfully merging this pull request may close these issues.

2 participants