提交 10535543 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Less redundant tests

上级 c04fb945
...@@ -1139,24 +1139,29 @@ def _get_preallocated_maps(node, thunk, prealloc_modes, def_val, ...@@ -1139,24 +1139,29 @@ def _get_preallocated_maps(node, thunk, prealloc_modes, def_val,
if 'wrong_size' in prealloc_modes or 'ALL' in prealloc_modes: if 'wrong_size' in prealloc_modes or 'ALL' in prealloc_modes:
# For each dimension, try size-1, size, size+1 # For each dimension, try size-1, size, size+1
for shape_diff in itertools_product((-1, 0, 1), repeat=max_ndim): for dim in xrange(max_ndim):
wrong_size = {} shape_diff = [0] * max_ndim
name = 'wrong_size%s' % str(tuple(shape_diff)) for diff in (-1, 1):
shape_diff[dim] = diff
for r in node.outputs: wrong_size = {}
if isinstance(r.type, (TensorType, CudaNdarrayType)): name = 'wrong_size%s' % str(tuple(shape_diff))
r_shape_diff = shape_diff[:r.ndim]
out_shape = [max((s + sd), 0) for r in node.outputs:
for s, sd in zip(r_vals[r].shape, r_shape_diff)] if isinstance(r.type, (TensorType, CudaNdarrayType)):
new_buf = numpy.zeros( r_shape_diff = shape_diff[:r.ndim]
shape=out_shape, out_shape = [max((s + sd), 0)
dtype=r.dtype) for s, sd in zip(r_vals[r].shape,
if isinstance(r.type, CudaNdarrayType): r_shape_diff)]
new_buf = CudaNdarray(new_buf) new_buf = numpy.zeros(
wrong_size[r] = new_buf shape=out_shape,
dtype=r.dtype)
yield (name, wrong_size) if isinstance(r.type, CudaNdarrayType):
del wrong_size new_buf = CudaNdarray(new_buf)
wrong_size[r] = new_buf
yield (name, wrong_size)
del wrong_size
def _check_preallocated_output(node, thunk, prealloc_modes, def_val, def _check_preallocated_output(node, thunk, prealloc_modes, def_val,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论