def _oper_gpu(cls, x, in_shape, out_shape, karnel, stride, padding): N = x.shape[0] pool_desc = cu.PoolingDescriptor(karnel, padding, stride, pool_mode=1) y = GPUValue(shape=tuple([ N, ] + list(out_shape))) with cu.cudnn_handler() as handle: cu.cuPoolingForward(handle, pool_desc, get_gpu(x), y) ret = cls._create_node(y) ret.attrs._pool_desc = pool_desc ret.attrs._kernel = karnel ret.attrs._stride = stride ret.attrs._padding = padding ret.attrs._x = x return ret
def _oper_gpu(cls, x, karnel, stride, padding): pool_desc = cu.PoolingNDescriptor(karnel, padding, stride, pool_mode=1) output_shape = [x.shape[0], x.shape[1]] for i in range(len(x.shape[2:])): output_shape.append( (x.shape[i + 2] + padding[i] * 2 - karnel[i]) // stride[i] + 1) y = GPUValue(shape=tuple(output_shape)) with cu.cudnn_handler() as handle: cu.cuPoolingForward(handle, pool_desc, get_gpu(x), get_gpu(y)) ret = cls._create_node(y) ret.attrs._pool_desc = pool_desc ret.attrs._kernel = karnel ret.attrs._stride = stride ret.attrs._padding = padding ret.attrs._x = x return ret