Samsung / ONE

On-device Neural Engine
Other
440 stars 157 forks source link

[circle-quantizer] Update CWQ algorithm for some Ops (PRelu, InstanceNorm) #5121

Closed jinevening closed 4 years ago

jinevening commented 4 years ago

Let's support new CWQ algorithms for the following Ops.

1. PRelu

Alpha is quantized per-channel. Alpha has a single value per channel, so its fp value is exactly restored from quantized value.

uint8

Elem Input Alpha Output
Dtype uint8 uint8 uint8
Granularity per-tensor per-channel per-tensor

int16

Elem Input Alpha Output
Dtype int16 int16 int16
Granularity per-tensor per-channel per-tensor

2. Instance Normalization

gamma and beta are quantized per-channel. Epsilon is saved as-is (fp32). Gamma (and beta) has a single value per channel, so its fp value is exactly restored from quantized value.

uint8

Elem Input Gamma Beta Epsilon Output
Dtype uint8 uint8 uint8 fp32 uint8
Granularity per-tensor per-channel per-channel scalar per-tensor

int16

Elem Input Gamma Beta Epsilon Output
Dtype int16 int16 int16 fp32 int16
Granularity per-tensor per-channel per-channel scalar per-tensor
jinevening commented 4 years ago

Commit order (based on module name)

DRAFT luci (quantization algorithm) common-artifacts (exclude.lst) res (recipe) pota-quantization-value-test (test data + test.lst)

jinevening commented 4 years ago

All done.