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

[CRASH] we where returning a python int while this was reused in…

[CRASH] we where returning a python int while this was reused in Elemwise.perform that expect ndarray.
上级 567b2db8
...@@ -547,7 +547,9 @@ get_scalar_constant_value_elemwises = ( ...@@ -547,7 +547,9 @@ get_scalar_constant_value_elemwises = (
def get_scalar_constant_value(orig_v, elemwise=True): def get_scalar_constant_value(orig_v, elemwise=True):
"""return the constant scalar(0-D) value underlying variable `v` """return the constant scalar(0-D) value underlying variable `v`
If v is the output of dimshuffles, fills, allocs, rebroadcasts, cast If v is the output of dimshuffles, fills, allocs, rebroadcasts,
cast, OutputGuard, DeepCopyOp, ScalarFromTensor, ScalarOp,
Elemwise and some pattern with Subtensor,
this function digs through them. this function digs through them.
If `v` is not some view of constant scalar data, then raise a If `v` is not some view of constant scalar data, then raise a
...@@ -587,7 +589,7 @@ def get_scalar_constant_value(orig_v, elemwise=True): ...@@ -587,7 +589,7 @@ def get_scalar_constant_value(orig_v, elemwise=True):
continue continue
elif isinstance(v.owner.op, theano.compile.ops.Shape_i): elif isinstance(v.owner.op, theano.compile.ops.Shape_i):
if isinstance(v.owner.inputs[0], Constant): if isinstance(v.owner.inputs[0], Constant):
return v.owner.inputs[0].data.shape[v.owner.op.i] return numpy.asarray(v.owner.inputs[0].data.shape[v.owner.op.i])
# Don't act as the constant_folding optimization here as this # Don't act as the constant_folding optimization here as this
# fct is used too early in the optimization phase. This would # fct is used too early in the optimization phase. This would
# mess with the stabilization optimization and be too slow. # mess with the stabilization optimization and be too slow.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论