Created
May 23, 2018 07:27
-
-
Save sonots/e49f567530c06088fe7b7211f2416d4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dtype = numpy.float32 | |
batch_size = 2 | |
in_channels = 3 | |
out_channels =2 | |
kernel_size = (3, 3, 1) | |
stride = (1, 1, 1) | |
pad = (0, 0, 0) | |
in_dims = (1000, 768, 3) | |
out_dims = (998, 766, 3) | |
x_shape = (batch_size, in_channels) + in_dims | |
w_shape = (out_channels, in_channels) + kernel_size | |
b_shape = (out_channels,) | |
y_shape = (batch_size, out_channels) + out_dims | |
def total_size(shape): | |
return functools.reduce(operator.mul, shape, 1) | |
x = cupy.arange(start=-total_size(x_shape)//2, stop=total_size(x_shape)//2, dtype=dtype).reshape(x_shape) | |
W = cupy.arange(start=-total_size(w_shape)//2, stop=total_size(w_shape)//2, dtype=dtype).reshape(w_shape) | |
b = cupy.array([-0.2, 1.3], dtype=dtype) | |
y = cupy.empty(y_shape, dtype=dtype) | |
cudnn.convolution_forward( | |
x, W, b, y, | |
pad, stride, None, 1, | |
auto_tune=True, tensor_core='never') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment