PaddlePaddle / PaddleSlim

PaddleSlim is an open-source library for deep model compression and architecture search.
https://paddleslim.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.56k stars 345 forks source link

如何固定Softmax这个op的量化参数 #1863

Closed Zheng-Bicheng closed 5 months ago

Zheng-Bicheng commented 6 months ago

如何固定softmax的quantized参数,我需要将scale固定为1/256,zp固定为-128。CMSIS-NN应该是只支持这种方式的,参考TFLite.

xiaoluomi commented 6 months ago

你好,目前Paddleslim还不支持对Softmax这个op做量化,目前支持的量化op为:['conv2d', 'depthwise_conv2d', 'conv2d_transpose', 'mul', 'matmul', 'matmul_v2'],目前仅支持在Softmax这个OP前插入量化和反量化节点。

Zheng-Bicheng commented 6 months ago

你好,目前Paddleslim还不支持对Softmax这个op做量化,目前支持的量化op为:['conv2d', 'depthwise_conv2d', 'conv2d_transpose', 'mul', 'matmul', 'matmul_v2'],目前仅支持在Softmax这个OP前插入量化和反量化节点。

大佬,那这个量化节点的信息有办法修改吗?我需要将scale和zp分别固定

xiaoluomi commented 6 months ago

很抱歉,目前Paddleslim是无法提供相应的接口的,无法满足你的特殊需求。

Zheng-Bicheng commented 6 months ago

很抱歉,目前Paddleslim是无法提供相应的接口的,无法满足你的特殊需求。

能帮忙给出一下插入softmax量化节点这个步骤是在哪个地方完成的吗?我可以自己进行修改

xiaoluomi commented 6 months ago

paddleslim会调用paddlepaddle框架下的量化,在https://github.com/PaddlePaddle/Paddle/blob/28920ca9ef1bf7761c4bd8a42af7d222423feb58/python/paddle/static/quantization/quant_config.py#L236 下表明支持其前面插入量化节点,量化器也在该文件下,具体插入节点等请参照https://github.com/PaddlePaddle/Paddle/tree/28920ca9ef1bf7761c4bd8a42af7d222423feb58/python/paddle/static/quantization