提交 1c2f0f4a authored 作者: Pascal Lamblin's avatar Pascal Lamblin 提交者: sentient07

Make get_scalar_constant_value handle shape_i of broadcastable dimensions

上级 ea0d37ec
......@@ -630,9 +630,14 @@ def get_scalar_constant_value(orig_v, elemwise=True,
v = v.owner.inputs[0]
continue
elif isinstance(v.owner.op, theano.compile.ops.Shape_i):
if isinstance(v.owner.inputs[0], Constant):
return numpy.asarray(
v.owner.inputs[0].data.shape[v.owner.op.i])
i = v.owner.op.i
inp = v.owner.inputs[0]
if isinstance(inp, Constant):
return numpy.asarray(inp.data.shape[i])
# The shape of a broadcastable dimension is 1
if inp.type.broadcastable[i]:
return numpy.asarray(1)
# Don't act as the constant_folding optimization here as this
# fct is used too early in the optimization phase. This would
# mess with the stabilization optimization and be too slow.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论