提交 9a9e873b authored 作者: sentient07's avatar sentient07

Generalized filter dialation parameter and reverted a change

上级 6701568f
...@@ -973,22 +973,7 @@ def empty_like(var): ...@@ -973,22 +973,7 @@ def empty_like(var):
return GpuAllocEmpty(var.type.dtype, var.type.context_name)(*var.shape) return GpuAllocEmpty(var.type.dtype, var.type.context_name)(*var.shape)
def gpu_alloc_empty(ctx, **kwargs): def gpu_alloc_empty(ctx, dtype):
'''
This is the cache method of GpuAllocEmpty class.
This takes the parameters of context name and props_dict
and retrieves the dtype key from the dictionary
Parameters
----------
ctx : String
The context name.
kwargs : Dict
The props_dict of the Op
'''
dtype = kwargs.get('dtype')
key = (dtype, ctx) key = (dtype, ctx)
if key not in gpu_alloc_empty.cache: if key not in gpu_alloc_empty.cache:
gpu_alloc_empty.cache[key] = GpuAllocEmpty(dtype, ctx) gpu_alloc_empty.cache[key] = GpuAllocEmpty(dtype, ctx)
......
...@@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division ...@@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division
import os import os
from theano import Apply, Op from theano import Apply, Op
from theano.tensor.extra_ops import CumsumOp from theano.tensor.extra_ops import CumsumOp
from .type import GpuArrayType
from .basic_ops import infer_context_name from .basic_ops import infer_context_name
try: try:
from pygpu import gpuarray from pygpu import gpuarray
...@@ -42,6 +41,7 @@ class GpuCumsum(GpuKernelBase, Op): ...@@ -42,6 +41,7 @@ class GpuCumsum(GpuKernelBase, Op):
assert x.type.dtype == 'float32', "Only float32 supported for GpuCumSum" assert x.type.dtype == 'float32', "Only float32 supported for GpuCumSum"
context_name = infer_context_name(x) context_name = infer_context_name(x)
x = as_gpuarray_variable(x, context_name) x = as_gpuarray_variable(x, context_name)
if x.ndim > GpuCumsum.SUPPORTED_NDIMS: if x.ndim > GpuCumsum.SUPPORTED_NDIMS:
......
...@@ -591,8 +591,7 @@ def local_gpuaalloc(op, context_name, inputs, outputs): ...@@ -591,8 +591,7 @@ def local_gpuaalloc(op, context_name, inputs, outputs):
def local_gpuaallocempty(op, context_name, inputs, outputs): def local_gpuaallocempty(op, context_name, inputs, outputs):
# We use _props_dict() to make sure that the GPU op know all the # We use _props_dict() to make sure that the GPU op know all the
# CPU op props. # CPU op props.
dtype = op._props_dict().get('dtype') return gpu_alloc_empty(context_name, **op._props_dict())(*inputs)
return gpu_alloc_empty(context_name, dtype=dtype)(*inputs)
@register_opt() @register_opt()
...@@ -960,7 +959,7 @@ def local_gpua_incsubtensor(op, context_name, inputs, outputs): ...@@ -960,7 +959,7 @@ def local_gpua_incsubtensor(op, context_name, inputs, outputs):
op.set_instead_of_inc, op.set_instead_of_inc,
op.destroyhandler_tolerate_aliased) op.destroyhandler_tolerate_aliased)
ret = op(*inputs) ret = op(*inputs)
val = getattr(op.make_node(*inputs).outputs[0].tag, 'nan_guard_mode_check', True) val = getattr(outputs[0].tag, 'nan_guard_mode_check', True)
ret.tag.nan_guard_mode_check = val ret.tag.nan_guard_mode_check = val
return ret return ret
......
...@@ -26,9 +26,11 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d): ...@@ -26,9 +26,11 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
if not dnn_available(test_ctx_name): if not dnn_available(test_ctx_name):
raise SkipTest(dnn_available.msg) raise SkipTest(dnn_available.msg)
mode = mode_with_gpu mode = mode_with_gpu
if fd != (1, 1): if fd != (1, 1):
raise SkipTest("Doesn't have CUDNN implementation") raise SkipTest("Doesn't have CUDNN implementation")
o = self.get_output_shape(i, f, s, b, fd) o = self.get_output_shape(i, f, s, b, fd)
self.run_fwd(inputs_shape=i, filters_shape=f, subsample=s, self.run_fwd(inputs_shape=i, filters_shape=f, subsample=s,
verify_grad=True, mode=mode, verify_grad=True, mode=mode,
provide_shape=provide_shape, border_mode=b, provide_shape=provide_shape, border_mode=b,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论