Slide 53
Slide 53 text
Function CPU/GPU Branching
!53
Red Chainer Integration
class Convolution2DFunction < Chainer::Function
def forward_cpu(inputs)
x, w, b = inputs
kh, kw = w.shape[2], w.shape[3]
@col = Chainer::Utils::Conv.im2col(x, ...)
y = Chainer::Utils::Math.tensordot(@col, ...)
y += b if b
[y.transpose(0, 3, 1, 2)]
end
def forward_gpu(inputs)
x, w, b = inputs
[x.conv(w, b, ...)]
end
end