提交 359d4feb authored 作者: sentient07's avatar sentient07

Cleanup #1

上级 c46741e0
...@@ -130,7 +130,6 @@ class GpuFromHost(GpuOp): ...@@ -130,7 +130,6 @@ class GpuFromHost(GpuOp):
def __str__(self): def __str__(self):
return 'GpuFromHost' return 'GpuFromHost'
def make_node(self, x): def make_node(self, x):
if not isinstance(x.type, tensor.TensorType): if not isinstance(x.type, tensor.TensorType):
raise TypeError("Expected a Theano variable with type " raise TypeError("Expected a Theano variable with type "
...@@ -583,6 +582,14 @@ class GpuCAReduce(GpuOp): ...@@ -583,6 +582,14 @@ class GpuCAReduce(GpuOp):
if not hasattr(self, "pre_scalar_op"): if not hasattr(self, "pre_scalar_op"):
self.pre_scalar_op = None self.pre_scalar_op = None
def __str__(self):
pre = ""
if self.pre_scalar_op:
pre = "pre=%s,red=" % str(self.pre_scalar_op)
return "GpuCAReduce{%s%s}{%s}" % (
pre, str(self.scalar_op),
','.join(str(i) for i in self.reduce_mask))
def make_node(self, x): def make_node(self, x):
x = as_cuda_ndarray_variable(x) x = as_cuda_ndarray_variable(x)
if (x.type.ndim != len(self.reduce_mask)): if (x.type.ndim != len(self.reduce_mask)):
...@@ -3634,6 +3641,7 @@ class GpuAllocEmpty(GpuOp): ...@@ -3634,6 +3641,7 @@ class GpuAllocEmpty(GpuOp):
Implement Alloc on the gpu, but without initializing memory. Implement Alloc on the gpu, but without initializing memory.
""" """
__props__ = ()
@staticmethod @staticmethod
def validate_shape(shape): def validate_shape(shape):
...@@ -3832,6 +3840,7 @@ class CopyOnNegativeStrides(GpuOp): ...@@ -3832,6 +3840,7 @@ class CopyOnNegativeStrides(GpuOp):
If it does, returns a c contiguous copy. If it does, returns a c contiguous copy.
""" """
__props__ = ()
view_map = {0: [0]} view_map = {0: [0]}
check_input = False check_input = False
......
...@@ -898,7 +898,6 @@ class BaseGpuCorrMM(GpuOp): ...@@ -898,7 +898,6 @@ class BaseGpuCorrMM(GpuOp):
return self.border_mode return self.border_mode
return (0, 0) return (0, 0)
def flops(self, inp, outp): def flops(self, inp, outp):
""" """
Useful with the hack in profilemode to print the MFlops. Useful with the hack in profilemode to print the MFlops.
...@@ -2194,14 +2193,12 @@ class GpuDownsampleFactorMax(GpuOp): ...@@ -2194,14 +2193,12 @@ class GpuDownsampleFactorMax(GpuOp):
Implement downsample with max on the gpu. Implement downsample with max on the gpu.
""" """
__props__ = ('ds', 'ignore_border') __props__ = ('ds', 'ignore_border')
def __init__(self, ds, ignore_border=False): def __init__(self, ds, ignore_border=False):
self.ds = tuple(ds) self.ds = tuple(ds)
self.ignore_border = ignore_border self.ignore_border = ignore_border
def make_node(self, x): def make_node(self, x):
if not isinstance(x.type, CudaNdarrayType): if not isinstance(x.type, CudaNdarrayType):
raise TypeError() raise TypeError()
......
...@@ -1127,9 +1127,9 @@ def local_gpu_advanced_incsubtensor1(node): ...@@ -1127,9 +1127,9 @@ def local_gpu_advanced_incsubtensor1(node):
compute_capability = device_properties(active_device_no)['major'] compute_capability = device_properties(active_device_no)['major']
if (compute_capability < 2 or y.ndim != 2 or x.ndim != 2): if (compute_capability < 2 or y.ndim != 2 or x.ndim != 2):
gpu_op = GpuAdvancedIncSubtensor1(set_instead_of_inc=set_instead_of_inc) gpu_op = GpuAdvancedIncSubtensor1(**node.op._props_dict())
else: else:
gpu_op = theano.sandbox.cuda.basic_ops.GPUAdvancedIncSubtensor1_dev20(**node.op._props_dict()) gpu_op = GpuAdvancedIncSubtensor1_dev20(**node.op._props_dict())
return [gpu_op(as_cuda_ndarray_variable(x), return [gpu_op(as_cuda_ndarray_variable(x),
as_cuda_ndarray_variable(y), *coords)] as_cuda_ndarray_variable(y), *coords)]
...@@ -1912,7 +1912,7 @@ def local_gpu_downsample_factor_max(node): ...@@ -1912,7 +1912,7 @@ def local_gpu_downsample_factor_max(node):
if (pad) != (0, 0) or node.op.mode != 'max' or stride != ws: if (pad) != (0, 0) or node.op.mode != 'max' or stride != ws:
return return
if (x.owner and isinstance(x.owner.op, HostFromGpu)): if (x.owner and isinstance(x.owner.op, HostFromGpu)):
gpu_ds = GpuDownsampleFactorMax(node.op.ds, node.op.ignore_border) gpu_ds = GpuDownsampleFactorMax(**node.op._props_dict())
return [host_from_gpu(gpu_ds(x.owner.inputs[0]))] return [host_from_gpu(gpu_ds(x.owner.inputs[0]))]
...@@ -1929,7 +1929,7 @@ def local_gpu_downsample_factor_max_grad(node): ...@@ -1929,7 +1929,7 @@ def local_gpu_downsample_factor_max_grad(node):
if pad != (0, 0) or node.op.mode != 'max' or stride != ws: if pad != (0, 0) or node.op.mode != 'max' or stride != ws:
return return
if (x.owner and isinstance(x.owner.op, HostFromGpu)): if (x.owner and isinstance(x.owner.op, HostFromGpu)):
gpu_ds_grad = GpuDownsampleFactorMaxGrad(ws, node.op.ignore_border) gpu_ds_grad = GpuDownsampleFactorMaxGrad(**node.op._props_dict())
return [host_from_gpu(gpu_ds_grad(x.owner.inputs[0], return [host_from_gpu(gpu_ds_grad(x.owner.inputs[0],
as_cuda_ndarray_variable(z), as_cuda_ndarray_variable(z),
as_cuda_ndarray_variable(gz)))] as_cuda_ndarray_variable(gz)))]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论