This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F28P550SG:量化破坏模型的性能

Guru**** 2609775 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1578585/tms320f28p550sg-quantization-destroy-performance-of-model

器件型号:TMS320F28P550SG


您好:

我有一个预训练的模型、想在 NPU 上使用。

问题是当使用 TINPUTinyMLQATFxModule 量化它时,性能有很大的下降(损耗从 0.25 到 0.34),当我使用 Torchao 量化它时,这个问题不会发生(损耗从 0.25 到 0.26 )。

您可以在 zip 文件中找到量化脚本以及量化的日志。 run_qat_ti.zip 

我使用的是一个非常简单的模型:  

        self.cnn_backbone = nn.Sequential(
            nn.Conv2d(in_channels=1, out_channels=8, kernel_size=(3, 1), padding=(1, 0), stride=(2, 1)),
            nn.BatchNorm2d(num_features=8),
            nn.ReLU(),

            nn.Conv2d(in_channels=8, out_channels=16, kernel_size=(3, 1), padding=(1, 0), stride=(2, 1)),
            nn.BatchNorm2d(num_features=16),
            nn.ReLU(),

            nn.Conv2d(in_channels=16, out_channels=32, kernel_size=(3, 1), padding=(1, 0), stride=(1, 1)),
            nn.BatchNorm2d(num_features=32),
            nn.ReLU()
        )
        
        self.flatten = nn.Flatten()

        dummy_input = torch.randn(1, 1, input_size, 1)
        conv_output_size = self.cnn_backbone(dummy_input).view(1, -1).size(1)

        # MLP Head
        self.mlp_head = nn.Sequential(
            nn.Linear(conv_output_size, 64),
            nn.ReLU(),
            nn.Dropout(0.2),
            nn.Linear(64, output_size)
        )

一些损耗较低的模型在使用 TI 库进行量化时、性能损失甚至更大。 你有一个想法为什么会发生?

此致、

加尔帕斯库尔