提交 0aa5ff77 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #4018 from abergeron/fix_buildbot

Move the AbstractConv tests with the implementation
...@@ -31,6 +31,7 @@ from .bn import batch_normalization ...@@ -31,6 +31,7 @@ from .bn import batch_normalization
import warnings import warnings
from .abstract_conv import conv2d as abstract_conv2d from .abstract_conv import conv2d as abstract_conv2d
def conv2d(input, filters, input_shape=None, filter_shape=None, def conv2d(input, filters, input_shape=None, filter_shape=None,
border_mode='valid', subsample=(1, 1), filter_flip=True, border_mode='valid', subsample=(1, 1), filter_flip=True,
image_shape=None, **kwargs): image_shape=None, **kwargs):
...@@ -139,5 +140,3 @@ def conv2d(input, filters, input_shape=None, filter_shape=None, ...@@ -139,5 +140,3 @@ def conv2d(input, filters, input_shape=None, filter_shape=None,
return abstract_conv2d(input, filters, input_shape, filter_shape, return abstract_conv2d(input, filters, input_shape, filter_shape,
border_mode, subsample, filter_flip) border_mode, subsample, filter_flip)
...@@ -408,7 +408,7 @@ class BaseAbstractConv2d(Op): ...@@ -408,7 +408,7 @@ class BaseAbstractConv2d(Op):
if len(subsample) != 2: if len(subsample) != 2:
raise ValueError("subsample must have two elements") raise ValueError("subsample must have two elements")
self.subsample = subsample self.subsample = tuple(subsample)
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"""
......
...@@ -52,7 +52,7 @@ class BaseCorrMM(gof.Op): ...@@ -52,7 +52,7 @@ class BaseCorrMM(gof.Op):
self.border_mode = border_mode self.border_mode = border_mode
if len(subsample) != 2: if len(subsample) != 2:
raise ValueError("subsample must have two elements") raise ValueError("subsample must have two elements")
self.subsample = subsample self.subsample = tuple(subsample)
@property @property
def pad(self): def pad(self):
...@@ -177,13 +177,13 @@ class BaseCorrMM(gof.Op): ...@@ -177,13 +177,13 @@ class BaseCorrMM(gof.Op):
if ((direction != 0) and (dH != 1)) or ((direction == 1) and (padH == -1)): if ((direction != 0) and (dH != 1)) or ((direction == 1) and (padH == -1)):
if not height: if not height:
raise ValueError("height must be given for backprop with vertical sampling or border_mode='half'") raise ValueError("height must be given for backprop with vertical sampling or border_mode='half'")
height = '(*(npy_int*)(PyArray_DATA(%s)))' % height height = '(*(npy_int64 *)(PyArray_DATA(%s)))' % height
else: else:
height = '-1' height = '-1'
if ((direction != 0) and (dW != 1)) or ((direction == 1) and (padW == -1)): if ((direction != 0) and (dW != 1)) or ((direction == 1) and (padW == -1)):
if not width: if not width:
raise ValueError("width must be given for backprop with horizontal sampling or border_mode='half'") raise ValueError("width must be given for backprop with horizontal sampling or border_mode='half'")
width = '(*(npy_int*)(PyArray_DATA(%s)))' % width width = '(*(npy_int64 *)(PyArray_DATA(%s)))' % width
else: else:
width = '-1' width = '-1'
sub = sub.copy() sub = sub.copy()
...@@ -314,8 +314,8 @@ class BaseCorrMM(gof.Op): ...@@ -314,8 +314,8 @@ class BaseCorrMM(gof.Op):
if (NULL == %(out)s) if (NULL == %(out)s)
{ {
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
"BaseCorrMM: Failed to allocate output of %%d x %%d x %%d x %%d", "BaseCorrMM: Failed to allocate output of %%lld x %%lld x %%lld x %%lld",
out_dim[0], out_dim[1], out_dim[2], out_dim[3]); (long long)out_dim[0], (long long)out_dim[1], (long long)out_dim[2], (long long)out_dim[3]);
%(fail)s %(fail)s
} }
} }
...@@ -424,7 +424,7 @@ class CorrMM_gradWeights(BaseCorrMM): ...@@ -424,7 +424,7 @@ class CorrMM_gradWeights(BaseCorrMM):
if shape is None: if shape is None:
raise ValueError('shape must be given if subsample != (1, 1)' raise ValueError('shape must be given if subsample != (1, 1)'
' or border_mode == "half"') ' or border_mode == "half"')
height_width = [shape[0], shape[1]] height_width = [as_tensor_variable(shape[0]).astype('int64'), as_tensor_variable(shape[1]).astype('int64')]
else: else:
height_width = [] height_width = []
...@@ -519,7 +519,7 @@ class CorrMM_gradInputs(BaseCorrMM): ...@@ -519,7 +519,7 @@ class CorrMM_gradInputs(BaseCorrMM):
raise TypeError('topgrad must be 4D tensor') raise TypeError('topgrad must be 4D tensor')
if self.subsample != (1, 1) and shape is None: if self.subsample != (1, 1) and shape is None:
raise ValueError('shape must be given if subsample != (1, 1)') raise ValueError('shape must be given if subsample != (1, 1)')
height_width = [shape[0], shape[1]] if self.subsample != (1, 1) else [] height_width = [as_tensor_variable(shape[0]).astype('int64'), as_tensor_variable(shape[1]).astype('int64')] if self.subsample != (1, 1) else []
broadcastable = [topgrad.type.broadcastable[0], kern.type.broadcastable[1], broadcastable = [topgrad.type.broadcastable[0], kern.type.broadcastable[1],
False, False] False, False]
......
...@@ -162,7 +162,7 @@ PyArrayObject* corrMM(PyArrayObject* bottom, ...@@ -162,7 +162,7 @@ PyArrayObject* corrMM(PyArrayObject* bottom,
"CorrMM shape inconsistency:\n" "CorrMM shape inconsistency:\n"
" bottom shape: %%d %%d %%d %%d\n" " bottom shape: %%d %%d %%d %%d\n"
" weight shape: %%d %%d %%d %%d\n" " weight shape: %%d %%d %%d %%d\n"
" top shape: %%d %%d %%d %%d (expected %%d %%d %%d %%d)\n", " top shape: %%ld %%ld %%ld %%ld (expected %%d %%d %%d %%d)\n",
batchSize, nChannels, bottomHeight, bottomWidth, batchSize, nChannels, bottomHeight, bottomWidth,
nFilters, nChannels, kH, kW, nFilters, nChannels, kH, kW,
PyArray_DIMS(top)[0], PyArray_DIMS(top)[1], PyArray_DIMS(top)[0], PyArray_DIMS(top)[1],
...@@ -182,7 +182,7 @@ PyArrayObject* corrMM(PyArrayObject* bottom, ...@@ -182,7 +182,7 @@ PyArrayObject* corrMM(PyArrayObject* bottom,
if (NULL == col) if (NULL == col)
{ {
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
"CorrMM failed to allocate working memory of %%d x %%d\n", "CorrMM failed to allocate working memory of %%ld x %%ld\n",
col_dim[0], col_dim[1]); col_dim[0], col_dim[1]);
return NULL; return NULL;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论