Winograd 卷积计算

winograd的论文:arxiv.org/pdf/1509.0930

[论文PPT]

https://www.slideshare.net/embeddedvision/even-faster-cnns-exploring-the-new-class-of-winograd-algorithms-a-presentation-from-arm?from_action=save

参考腾讯开源的NNCN对winograd的实现,NCNN的[开源地址]

Tencent/ncnn

一维F(2,3)实现代码:

        import numpy

x0 = 1
x1 = 2
x2 = 3
x3 = 4
x = numpy.matrix([[x0, x1, x2],[x1, x2, x3]])

w0 = 7
w1 = 8
w2 = 9
w = numpy.matrix([w0, w1, w2]).T
# 普通的x*w^T 矩阵乘法, 乘法的次数 2*3 = 6次,6次加法
y = x*w
print(y)


# 一维winograd, 4次乘法, 8次加法 ,跟w相关的加减乘除可以在初始化的时候
# 计算好,所以不占用计算量
# µ(F(m, r)) = m + r - 1
m1 = (x0 - x2) * w0
m2 = (x1 + x2) * (w0 + w1 + w2)/2
m4 = (x1 - x3) * w2
m3 = (x2 - x1) * (w0 - w1 + w2) /2

y = numpy.matrix([m1+m2+m3, m2-m3-m4]).T
print(y)
      

二维卷积f(2,3)实现

图片出自论文[Sparse Winograd Convolutional neural networks on small-scale systolic arrays((PDF) Sparse Winograd Convolutional neural networks on small-scale systolic arrays)


Winograd 卷积计算_第1张图片

你可能感兴趣的:(Winograd 卷积计算)