PTQ4ViT icon indicating copy to clipboard operation
PTQ4ViT copied to clipboard

SwinTransformer3D

Open wangjingg opened this issue 3 years ago • 3 comments

Does this framework support SwinTransformer3D quantification?

wangjingg avatar Dec 07 '21 08:12 wangjingg

Currently that's not available, sorry for that.

Some slight modification could get things work, if:

  1. You have calibration dataset for the model and you know how to preprocess the pictures.
  2. You'll need to manually substitude matrix multiplication, from an operation to a torch.nn.module, so that the framework can set quantization parameters in activation's quantization. But if you just want to quantize weights, you can skip this step.

SuperVan-Young avatar Dec 10 '21 07:12 SuperVan-Young

我使用该框架成功量化了Swin3D的matmul和Linear算子, 但无法量化conv3D, 请问, 我需要如何修改才能让它工作?

wangjingg avatar Jan 17 '22 08:01 wangjingg

我们这篇工作主要考虑Vision transformer,所以没有实现conv3D算子的量化和封装。ViT的embedding操作是使用conv2D实现的,这部分代码在layers.conv里,您可以考虑仿照conv2D实现conv3D,从代码的核心逻辑上二者没有什么区别,只要把相关操作的维度增加一下就好了。conv2d当中每一步操作的维度如何变换,我在注释中逐行写出来了,可以用作参考。如果您已经实现了conv3D算子,您还要在utils.net_wrap里加上对conv3D的封装操作。

SuperVan-Young avatar Jan 18 '22 14:01 SuperVan-Young