提交 acad83a3 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Make sure not to use the descriptor op if not available.

上级 171aa1d7
...@@ -1406,6 +1406,7 @@ class GpuDnnPool(DnnBase): ...@@ -1406,6 +1406,7 @@ class GpuDnnPool(DnnBase):
or desc.type.ctype != 'cudnnPoolingDescriptor_t': or desc.type.ctype != 'cudnnPoolingDescriptor_t':
raise TypeError('desc must be cudnnPoolingDescriptor_t') raise TypeError('desc must be cudnnPoolingDescriptor_t')
if desc.owner is not None:
dop = desc.owner.op dop = desc.owner.op
e_ndim = dop.get_ndim() + 2 # 4 or 5 e_ndim = dop.get_ndim() + 2 # 4 or 5
...@@ -1572,17 +1573,19 @@ class GpuDnnPoolGrad(DnnBase): ...@@ -1572,17 +1573,19 @@ class GpuDnnPoolGrad(DnnBase):
or desc.type.ctype != 'cudnnPoolingDescriptor_t': or desc.type.ctype != 'cudnnPoolingDescriptor_t':
raise TypeError('desc must be cudnnPoolingDescriptor_t') raise TypeError('desc must be cudnnPoolingDescriptor_t')
inp = as_cuda_ndarray_variable(inp)
inp_grad = as_cuda_ndarray_variable(inp_grad)
out = as_cuda_ndarray_variable(out)
if desc.owner is not None:
nd = desc.owner.op.get_ndim() + 2 # 4 or 5 nd = desc.owner.op.get_ndim() + 2 # 4 or 5
inp = as_cuda_ndarray_variable(inp)
if inp.type.ndim != nd: if inp.type.ndim != nd:
raise TypeError('inp must be %dD tensor' % (nd,)) raise TypeError('inp must be %dD tensor' % (nd,))
inp_grad = as_cuda_ndarray_variable(inp_grad)
if inp_grad.type.ndim != nd: if inp_grad.type.ndim != nd:
raise TypeError('inp_grad must be %dD tensor' % (nd,)) raise TypeError('inp_grad must be %dD tensor' % (nd,))
out = as_cuda_ndarray_variable(out)
if out.type.ndim != nd: if out.type.ndim != nd:
raise TypeError('out must be %dD tensor' % (nd,)) raise TypeError('out must be %dD tensor' % (nd,))
......
...@@ -945,6 +945,7 @@ class GpuDnnPool(DnnBase): ...@@ -945,6 +945,7 @@ class GpuDnnPool(DnnBase):
def make_node(self, img, desc): def make_node(self, img, desc):
img = as_gpuarray_variable(img) img = as_gpuarray_variable(img)
if desc.owner is not None:
e_ndim = desc.owner.op.get_ndim() + 2 e_ndim = desc.owner.op.get_ndim() + 2
if img.type.ndim != e_ndim: if img.type.ndim != e_ndim:
...@@ -1010,17 +1011,19 @@ class GpuDnnPoolGrad(DnnBase): ...@@ -1010,17 +1011,19 @@ class GpuDnnPoolGrad(DnnBase):
"APPLY_SPECIFIC(dnn_pool_grad)") "APPLY_SPECIFIC(dnn_pool_grad)")
def make_node(self, inp, out, out_grad, desc): def make_node(self, inp, out, out_grad, desc):
inp = as_gpuarray_variable(inp)
out_grad = as_gpuarray_variable(out_grad)
out = as_gpuarray_variable(out)
if desc.owner is not None:
nd = desc.owner.op.get_ndim() + 2 nd = desc.owner.op.get_ndim() + 2
inp = as_gpuarray_variable(inp)
if inp.type.ndim != nd: if inp.type.ndim != nd:
raise TypeError('inp must be %dD tensor' % (nd,)) raise TypeError('inp must be %dD tensor' % (nd,))
out_grad = as_gpuarray_variable(out_grad)
if out_grad.type.ndim != nd: if out_grad.type.ndim != nd:
raise TypeError('out_grad must be %dD tensor' % (nd,)) raise TypeError('out_grad must be %dD tensor' % (nd,))
out = as_gpuarray_variable(out)
if out.type.ndim != nd: if out.type.ndim != nd:
raise TypeError('out must be %dD tensor' % (nd,)) raise TypeError('out must be %dD tensor' % (nd,))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论