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

Force shape inputs to int64 in CorrMM to avoid having something that does not…

Force shape inputs to int64 in CorrMM to avoid having something that does not match the 'int' assumed type of before.
上级 c3b54b9b
...@@ -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 = [as_tensor_variable(shape[0]), as_tensor_variable(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 = [as_tensor_variable(shape[0]), as_tensor_variable(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]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论