提交 b44d2bf6 authored 作者: Frederic Bastien's avatar Frederic Bastien

Fix and revert stuff in this PR.

上级 c260ecf4
......@@ -319,7 +319,6 @@ class GpuDimShuffle(GpuOp):
input_broadcastable = tuple(input_broadcastable)
self.input_broadcastable = input_broadcastable
self.new_order = tuple(new_order)
self.inplace = True
for i, b in enumerate(input_broadcastable):
if i not in new_order:
......@@ -347,7 +346,6 @@ class GpuDimShuffle(GpuOp):
def __setstate__(self, d):
self.__dict__.update(d)
self._rehash()
def make_node(self, input):
ib = tuple(input.type.broadcastable)
......@@ -375,12 +373,6 @@ class GpuDimShuffle(GpuOp):
ob.append(ib[value])
return Apply(self, [input], [CudaNdarrayType(broadcastable=ob)()])
def _rehash(self):
self._hashval = (hash(type(self).__name__) ^
hash(type(self).__module__) ^
hash(self.new_order) ^
hash(self.input_broadcastable))
def __str__(self):
return "GpuDimShuffle{%s}" % ",".join(str(x) for x in self.new_order)
......@@ -3731,6 +3723,14 @@ class GpuAlloc(GpuAllocEmpty):
def __init__(self, memset_0=False):
self.memset_0 = memset_0
def __str__(self):
# Hide the memset parameter when not used to prevent confusion.
if self.memset_0:
s = "%s{memset_0=%s}" % (self.__class__.__name__, self.memset_0)
else:
s = self.__class__.__name__
return s
def make_node(self, value, *shape):
# if there is unneeded transfert generated by the next line
# the optimizer will remove them.
......
......@@ -898,6 +898,13 @@ class BaseGpuCorrMM(GpuOp):
return self.border_mode
return (0, 0)
def __str__(self):
return '%s{%s, %s, %s}' % (
self.__class__.__name__,
self.border_mode,
str(self.subsample),
str(self.filter_dilation))
def flops(self, inp, outp):
"""
Useful with the hack in profilemode to print the MFlops.
......@@ -1406,6 +1413,13 @@ class BaseGpuCorr3dMM(GpuOp):
raise ValueError("pad must be 'half', 'full', or have three elements")
self.pad = pad
def __str__(self):
return '%s{%s, %s, pad=%r}' % (
self.__class__.__name__,
self.border_mode,
str(self.subsample),
self.pad)
def flops(self, inp, outp):
""" Useful with the hack in profilemode to print the MFlops"""
# if the output shape is correct, then this gives the correct
......@@ -2199,6 +2213,11 @@ class GpuDownsampleFactorMax(GpuOp):
self.ds = tuple(ds)
self.ignore_border = ignore_border
def __str__(self):
return '%s{%s,%s}' % (self.__class__.__name__,
self.ds,
self.ignore_border)
def make_node(self, x):
if not isinstance(x.type, CudaNdarrayType):
raise TypeError()
......
......@@ -399,10 +399,7 @@ def local_gpu_dimshuffle_0(node):
if input.owner and isinstance(input.owner.op, HostFromGpu):
# move the add to a GpuAdd
p_dict = node.op._props_dict()
try:
p_dict.pop('inplace')
except KeyError:
pass
p_dict.pop('inplace', None)
new_op = GpuDimShuffle(**p_dict)
return [host_from_gpu(new_op(as_cuda_ndarray_variable(input)))]
if isinstance(node.op, GpuFromHost):
......@@ -411,10 +408,7 @@ def local_gpu_dimshuffle_0(node):
tensor.DimShuffle):
dimshuffle_node = host_input.owner
p_dict = dimshuffle_node.op._props_dict()
try:
p_dict.pop('inplace')
except KeyError:
pass
p_dict.pop('inplace', None)
new_op = GpuDimShuffle(**p_dict)
return [new_op(
as_cuda_ndarray_variable(dimshuffle_node.inputs[0]))]
......@@ -1189,6 +1183,7 @@ def local_gpu_incsubtensor(node):
host_output = node.inputs[0]
if host_output.owner and \
type(host_output.owner.op) == tensor.IncSubtensor:
incsubt = host_output.owner.op
x, y = host_output.owner.inputs[0:2]
coords = host_output.owner.inputs[2:]
if x.dtype != "float32":
......@@ -1197,7 +1192,7 @@ def local_gpu_incsubtensor(node):
# The IncSubtensor upcast to float32 y, so we do it
# explicitly to move it to the GPU.
y = y.astype('float32')
ret = GpuIncSubtensor(**node.op._props_dict())(as_cuda_ndarray_variable(x),
ret = GpuIncSubtensor(**incsubt._props_dict())(as_cuda_ndarray_variable(x),
as_cuda_ndarray_variable(y),
*coords)
ret.tag.nan_guard_mode_check = getattr(
......@@ -1922,7 +1917,7 @@ def local_gpu_downsample_factor_max(node):
if (pad) != (0, 0) or node.op.mode != 'max' or stride != ws:
return
if (x.owner and isinstance(x.owner.op, HostFromGpu)):
gpu_ds = GpuDownsampleFactorMax(**node.op._props_dict())
gpu_ds = GpuDownsampleFactorMax(ws, node.op.ignore_border)
return [host_from_gpu(gpu_ds(x.owner.inputs[0]))]
......@@ -1939,7 +1934,7 @@ def local_gpu_downsample_factor_max_grad(node):
if pad != (0, 0) or node.op.mode != 'max' or stride != ws:
return
if (x.owner and isinstance(x.owner.op, HostFromGpu)):
gpu_ds_grad = GpuDownsampleFactorMaxGrad(node.op.ds, node.op.ignore_border)
gpu_ds_grad = GpuDownsampleFactorMaxGrad(ws, node.op.ignore_border)
return [host_from_gpu(gpu_ds_grad(x.owner.inputs[0],
as_cuda_ndarray_variable(z),
as_cuda_ndarray_variable(gz)))]
......
......@@ -142,7 +142,6 @@ class DimShuffle(Op):
self.new_order = new_order
if inplace is True:
self.inplace = inplace
self._props_dict().pop('inplace')
else:
raise ValueError("DimShuffle is inplace by default and hence the inplace for DimShuffle must be true")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论