提交 d3a15ad8 authored 作者: Frederic's avatar Frederic

Make Alloc generate an error at build time instead of run time.

上级 ac1557ac
......@@ -2801,6 +2801,10 @@ class Alloc(gof.Op):
v = as_tensor_variable(value)
sh = [as_tensor_variable(s) for s in shape]
bcast = []
if v.ndim > len(sh):
raise TypeError("Alloc value to use have more dimensions"
" then the specified dimensions",
v.ndim, len(sh))
for i, s in enumerate(sh):
if s.type.dtype[:3] not in ('int', 'uin'):
if config.exception_verbosity == 'high':
......
......@@ -1239,11 +1239,17 @@ AllocTester = makeBroadcastTester(
correct23 = (rand(4,7), numpy.int32(2), numpy.int32(4), numpy.int32(7)),
),
bad_runtime = dict(
bad_shape12 = (rand(7), numpy.int32(7), numpy.int32(5)),
too_big32 = (rand(6,2,4), numpy.int32(6), numpy.int32(2)),
too_big32b = (rand(6,2,4), numpy.int32(2), numpy.int32(4)),
),
)
bad_shape12 = (rand(7), numpy.int32(7), numpy.int32(5)),
),
bad_build = dict(
too_big32 = (rand(6,2,4), numpy.int32(6), numpy.int32(2)),
too_big32b = (rand(6,2,4), numpy.int32(6), numpy.int32(4)),
too_big32c = (rand(6,2,4), numpy.int32(2), numpy.int32(4)),
too_big32d = (rand(6,2,4), numpy.int32(2), numpy.int32(6)),
too_big32e = (rand(6,2,4), numpy.int32(4), numpy.int32(6)),
too_big32f = (rand(6,2,4), numpy.int32(4), numpy.int32(2)),
),
)
# Since not all inputs of Alloc are differentiable, we need different testers
s1, s2, s3 = randint_ranged(1, 13, (3,))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论