fix cudnn call condition for readability
@@ -36,7 +36,9 @@ class SpatialTransformerSampler(function.Function):
return self._forward(inputs)
def forward_gpu(self, inputs):
- if cuda.cudnn_enabled and self.use_cudnn and _cudnn_version >= 5000:
+ if not (cuda.cudnn_enabled and self.use_cudnn and
+ _cudnn_version >= 5000):
+ return self._forward(inputs)
x, grid = inputs
out_shape = x.shape[:2] + grid.shape[2:]
y = cuda.cupy.empty(out_shape, dtype=x.dtype)
@@ -60,7 +62,6 @@ class SpatialTransformerSampler(function.Function):
x_desc.value, x.data.ptr, grid_t.data.ptr, zero.data,
y_desc.value, y.data.ptr)
return y,
- return self._forward(inputs)
def _forward(self, inputs):
x, grid = inputs
@@ -115,7 +116,9 @@ class SpatialTransformerSampler(function.Function):
return self._backward(inputs, grad_outputs)
def backward_gpu(self, inputs, grad_outputs):
- if cuda.cudnn_enabled and self.use_cudnn and _cudnn_version >= 5000:
+ if not (cuda.cudnn_enabled and self.use_cudnn and
+ _cudnn_version >= 5000):
+ return self._backward(inputs, grad_outputs)
x, grid = inputs
gy, = grad_outputs
@@ -142,7 +145,6 @@ class SpatialTransformerSampler(function.Function):
grid_t.data.ptr, zero.data, ggrid_t.data.ptr)
ggrid = cuda.cupy.transpose(ggrid_t, axes=(0, 3, 1, 2))
return gx, ggrid
- return self._backward(inputs, grad_outputs)
def _backward(self, inputs, grad_outputs):
x, grid = inputs
