One: [circle-quantizer] Support quantization for more operators

Created on 31 Mar 2021  路  7Comments  路  Source: Samsung/ONE

Let's support more operators in circle-quantizer

Q8: q8 quantization logic
Q16: q16 quantization logic
Verifier: Verifies the type/granularity of the quantized Op

First milestone (4/6)

Operator | Q8 | Q16 | Verifier
-- | -- | -- | --
sigmoid | o | o | 聽o
softmax | o | o | 聽o
tanh | o | o | o聽
permute (transpose) | o | o | o
reshape | o | o | o
slice | o聽| o聽| o聽
argmax | o | o | o聽

Second milestone (4/12)

Operator | Q8 | Q16 | Verifier | Assignee
-- | -- | -- | -- | --
floor | o | o | o | @dayo09
div | o | o | o聽| @dayo09
floor_div | o | o | o聽| @dayo09
greater | o聽 | o聽 | o聽| @jinevening
greater_equal | o聽 | o聽 | o聽| @jinevening
logical_or | o聽 | o | o聽| @jinevening
not_equal | o | o | o聽| @jinevening
concat | o | o | o聽| @jinevening
pad | o | o | o聽| @jinevening

Third milestone (4/16)

Operator | Q8 | Q16 | Verifier| Assignee
-- | -- | -- | -- | --
elu | o | o | o聽| @dayo09
rsqrt | o | o | o聽| @dayo09
sqrt | o | o | o聽| @dayo09
pow | o | o | o聽| @dayo09
resize_bilinear | o | o | o聽| @dayo09
resize_nearestneighbor | o | o | 聽| @dayo09
yuv_rgb_scale (FC+Reshape) | - | - | -聽| -
instance_normalize | o | o | o聽| @jinevening
local_response_normalize | 聽 | 聽 | 聽| need discussion
batch_to_space | o聽 | o聽 | o聽| @jinevening
depth_to_space | 聽o | o聽 | o聽| @jinevening
space_to_batch | o聽 | o聽 | o聽| @jinevening
space_to_depth | o聽 | o聽 | o聽| @jinevening
split | o | o | o聽| @jinevening
strided_slice | o聽 | o聽 | o聽| @jinevening

CC @lemmaa

arequant

Most helpful comment

All done. Thanks @dayo09 :)

All 7 comments

@jinevening I will start with not_equal 馃槃

@jinevening It seems compiler/luci/pass/src/test/TestIOGraph.h is staled and moved to compiler/luci/testhelper. https://github.com/Samsung/ONE/pull/6335

May I replace it?

May I replace it?

Of course :)

May I replace it?

If you like please go ahead :)
It would be nice to add an issue for this task.

By the offline conversation with @jinevening

Note

  • Quantization Type (lwq, cwq) doesn't mean all the nodes in the graph are the attributes.
  • If a graph's quantization type is lwq

    • lwq: most of the node's quantization type are lwq

    • except for



      • bool type node (ex: output of comparison)


      • scalar node (ex: stride of StridedSlice)


      • certain type of parameter node



  • If a graph's quantization type is cwq

    • cwq: only the nodes supports cwq quantization type are cwq

    • (ex: Weight/Bias of Conv/DConv/TConv/FC, Parameter of PReLU, Parameter of InstanceNorm)

    • lwq: most of the node's quantization type are lwq

    • except for



      • bool type node (ex: output of comparison)


      • scalar node (ex: stride of StridedSlice)


      • certain type of parameter node



Test Spec

(1) Positive Test

  • TEST_WITH_GRAPH

    • Test if quantization with the given op, type and granularity runs without error.

| Type | Granularity |
| ---- | ----------- |
| U8 | LayerWise |
| U8 | ChannelWise |
| S16 | ChannelWise |

(2) Negative Test

  • TEST_WITH_WRONG_TYPE

    • Quantize F32 model to Type by QuantizeWithMinMaxPass

    • Set the quantized model's output as WrongType

    • Expect the Verifier throws exception

Type | Granularity | WrongType
-- | -- | --
U8 | LayerWise | S16
U8 | ChannelWise | S16
S16 | ChannelWise | S16

  • TEST_WITH_WRONG_GRANULARITY

    • Quantize F32 model to Type by QuantizeWithMinMaxPass

    • Set the quantized model's output's quantization param invalid - specifically, by adding one more zerop/scale parameter

    • Expect the Verifier throws exception

| Type | Granularity |
| ---- | ----------- |
| U8 | LayerWise |
| U8 | ChannelWise |
| S16 | ChannelWise |

record-minmax currently does not support bool-type input.

Real world model's input is hardly bool type. But in the viewpoint of CI, we will need bool-type input for testing.

I made a draft to support bool type input in record-minmax #6526.

All done. Thanks @dayo09 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YongseopKim picture YongseopKim  路  3Comments

seanshpark picture seanshpark  路  3Comments

kishcs picture kishcs  路  3Comments

mhs4670go picture mhs4670go  路  3Comments

mhs4670go picture mhs4670go  路  4Comments