学术
模块更新于 2026-11-20· 浏览 0· 下载 0

PConv 部分卷积

省算又省访存:只对前一段连续通道(典型 1/4)做常规 3×3 卷积,其余直通;r = 1/4 时 FLOPs 仅为常规卷积的 1/16,访存约为 1/4

计算机视觉计算机视觉轻量级网络PConvFasterNet模型加速

结构图

PConv 部分卷积结构图
PConv 部分卷积结构图

省算又省访存:只对前一段连续通道(典型 1/4)做常规 3×3 卷积,其余直通;r = 1/4 时 FLOPs 仅为常规卷积的 1/16,访存约为 1/4

论文信息

  • 论文:Run, Don’t Walk: Chasing Higher FLOPS for Faster Neural Networks
  • 出处:arXiv 2023

核心痛点

轻量网络都在降 FLOPs,但延迟 = FLOPs / FLOPS:DWConv / GConv 访存频繁,有效 FLOPS 甚至不如 ResNet50,CycleMLP-B1 只有一半 FLOPs,CPU 上反而更慢(116.1ms vs 73.0ms)。

模块亮点

  • 省算又省访存:只对前一段连续通道(典型 1/4)做常规 3×3 卷积,其余直通;r = 1/4 时 FLOPs 仅为常规卷积的 1/16,访存约为 1/4
  • 有效算力拉满:FLOPS 比 DWConv 在 GPU / CPU / ARM 上高 10.5×、6.2×、22.8×;后接 PWConv 平均测试损失仅 0.0123
  • 整体模型提速:FasterNet 的 T0 比 MobileViT-XXS 在 GPU / CPU / ARM 上快 2.8× / 3.3× / 2.4×,精度高 2.9%;FasterNet-L 达 83.5% top-1

适用场景

领域为轻量级网络 / 模型加速;原文验证了 ImageNet-1k 分类、COCO 目标检测与实例分割;也适合用 DWConv / GConv 的模型,如 MobileNet、MobileViT。

插入位置建议

  • 替换 MobileNet、ConvNeXt 等网络的 DWConv 层
  • 后接两层 1×1 PWConv,组成 FasterNet Block
  • 放进 ViT / MLP 混合模型中 DWConv 的位置,如 MobileViT

适用任务

  • 轻量级网络
  • 模型加速

完整代码

pconv.py
from torch import nn
import torch


class Partial_conv3(nn.Module):

    def __init__(self, dim, n_div, forward):
        super().__init__()
        self.dim_conv3 = dim // n_div
        self.dim_untouched = dim - self.dim_conv3
        self.partial_conv3 = nn.Conv2d(self.dim_conv3, self.dim_conv3, 3, 1, 1, bias=False)

        if forward == 'slicing':
            self.forward = self.forward_slicing
        elif forward == 'split_cat':
            self.forward = self.forward_split_cat
        else:
            raise NotImplementedError

    def forward_slicing(self, x):
        # only for inference
        x = x.clone()  # !!! Keep the original input intact for the residual connection later
        x[:, :self.dim_conv3, :, :] = self.partial_conv3(x[:, :self.dim_conv3, :, :])

        return x

    def forward_split_cat(self, x):
        # for training/inference
        x1, x2 = torch.split(x, [self.dim_conv3, self.dim_untouched], dim=1)
        x1 = self.partial_conv3(x1)
        x = torch.cat((x1, x2), 1)

        return x


if __name__ == '__main__':
    block = Partial_conv3(128, 2, 'split_cat')
    input = torch.rand(32, 128, 64, 64)
    output = block(input)
    print(input.size())
    print(output.size())

环境与依赖

Python 3.9+

继续浏览

下一篇PDM 历史可分解混合先分解、再分向混合:过去序列先经平均池化下采样成多尺度,再逐尺度分解出季节项和趋势项,季节项自底向上由细到粗混合,趋势项自顶向下由粗到细混合,两类信息各走各的聚合路径

相关资源