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

Generalized filter dialation parameter and reverted a change

上级 6701568f
......@@ -973,22 +973,7 @@ def empty_like(var):
return GpuAllocEmpty(var.type.dtype, var.type.context_name)(*var.shape)
def gpu_alloc_empty(ctx, **kwargs):
'''
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')
def gpu_alloc_empty(ctx, dtype):
key = (dtype, ctx)
if key not in gpu_alloc_empty.cache:
gpu_alloc_empty.cache[key] = GpuAllocEmpty(dtype, ctx)
......
......@@ -956,8 +956,8 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
shape2 = shape_i(img, 2, fgraph) + shape_i(kerns, 2, fgraph) - 1
shape3 = shape_i(img, 3, fgraph) + shape_i(kerns, 3, fgraph) - 1
out = gpu_alloc_empty(ctx_name, dtype=img.dtype)(shape_i(img, 0, fgraph),
shape_i(kerns, 1, fgraph),
shape2, shape3)
shape_i(kerns, 1, fgraph),
shape2, shape3)
desc = GpuDnnConvDesc(border_mode='valid', subsample=(1, 1),
conv_mode=conv_mode, precision=precision)(kerns.shape)
return gpu_dnn_conv_gradI()(kerns, img, out, desc)
......
......@@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division
import os
from theano import Apply, Op
from theano.tensor.extra_ops import CumsumOp
from .type import GpuArrayType
from .basic_ops import infer_context_name
try:
from pygpu import gpuarray
......@@ -42,6 +41,7 @@ class GpuCumsum(GpuKernelBase, Op):
assert x.type.dtype == 'float32', "Only float32 supported for GpuCumSum"
context_name = infer_context_name(x)
x = as_gpuarray_variable(x, context_name)
if x.ndim > GpuCumsum.SUPPORTED_NDIMS:
......
......@@ -591,8 +591,7 @@ def local_gpuaalloc(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
# CPU op props.
dtype = op._props_dict().get('dtype')
return gpu_alloc_empty(context_name, dtype=dtype)(*inputs)
return gpu_alloc_empty(context_name, **op._props_dict())(*inputs)
@register_opt()
......@@ -960,7 +959,7 @@ def local_gpua_incsubtensor(op, context_name, inputs, outputs):
op.set_instead_of_inc,
op.destroyhandler_tolerate_aliased)
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
return ret
......
......@@ -26,9 +26,11 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
if not dnn_available(test_ctx_name):
raise SkipTest(dnn_available.msg)
mode = mode_with_gpu
if fd != (1, 1):
raise SkipTest("Doesn't have CUDNN implementation")
o = self.get_output_shape(i, f, s, b, fd)
self.run_fwd(inputs_shape=i, filters_shape=f, subsample=s,
verify_grad=True, mode=mode,
provide_shape=provide_shape, border_mode=b,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论