提交 4b876df8 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

added a verbose exception for Alloc.make_node

上级 290805f7
...@@ -21,7 +21,7 @@ import elemwise ...@@ -21,7 +21,7 @@ import elemwise
from theano import scalar as scal from theano import scalar as scal
from theano.gof.python25 import partial, any, all from theano.gof.python25 import partial, any, all
from theano import compile, printing from theano import compile, printing
from theano.printing import pprint from theano.printing import pprint, min_informative_str
# We use these exceptions as well. # We use these exceptions as well.
from theano.scalar import ComplexError, IntegerDivisionError from theano.scalar import ComplexError, IntegerDivisionError
...@@ -2492,8 +2492,13 @@ class Alloc(gof.Op): ...@@ -2492,8 +2492,13 @@ class Alloc(gof.Op):
v = as_tensor_variable(value) v = as_tensor_variable(value)
sh = [as_tensor_variable(s) for s in shape] sh = [as_tensor_variable(s) for s in shape]
bcast = [] bcast = []
for s in sh: for i, s in enumerate(sh):
if s.type.dtype[:3] not in ('int', 'uin'): if s.type.dtype[:3] not in ('int', 'uin'):
if config.exception_verbosity == 'high':
raise TypeError('Shape arguments to Alloc must be integers,' + \
'but argument '+str(i)+' is not for apply node: '+\
min_informative_str(s))
else:
raise TypeError('Shape arguments must be integers', s) raise TypeError('Shape arguments must be integers', s)
# if s is constant 1, then we're broadcastable in that dim # if s is constant 1, then we're broadcastable in that dim
try: try:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论