提交 0b7329dc authored 作者: Frederic Bastien's avatar Frederic Bastien

Make get_scalar_constant_value investigate Second as Alloc (so elemwise=False…

Make get_scalar_constant_value investigate Second as Alloc (so elemwise=False still check it). This fix tests in travis in FAST_COMPILE.
上级 fc25440d
...@@ -590,6 +590,8 @@ def get_scalar_constant_value(orig_v, elemwise=True, ...@@ -590,6 +590,8 @@ def get_scalar_constant_value(orig_v, elemwise=True,
---------- ----------
elemwise : bool elemwise : bool
If False, we won't try to go into elemwise. So this call is faster. If False, we won't try to go into elemwise. So this call is faster.
But we still investigate in Second Elemwise (as this is a substitute
for Alloc)
only_process_constants : bool only_process_constants : bool
If True, we only attempt to obtain the value of `orig_v` if it's If True, we only attempt to obtain the value of `orig_v` if it's
directly constant and don't try to dig through dimshuffles, fills, directly constant and don't try to dig through dimshuffles, fills,
...@@ -650,13 +652,16 @@ def get_scalar_constant_value(orig_v, elemwise=True, ...@@ -650,13 +652,16 @@ def get_scalar_constant_value(orig_v, elemwise=True,
ret = [[None]] ret = [[None]]
v.owner.op.perform(v.owner, const, ret) v.owner.op.perform(v.owner, const, ret)
return ret[0][0].copy() return ret[0][0].copy()
elif elemwise and isinstance(v.owner.op, Elemwise): # In fast_compile, we don't enable local_fill_to_alloc, so
# we need to investigate Second as Alloc. So elemwise
# don't disable the check for Second.
elif isinstance(v.owner.op, Elemwise):
if isinstance(v.owner.op.scalar_op, scal.Second): if isinstance(v.owner.op.scalar_op, scal.Second):
# We don't need both input to be constant for second # We don't need both input to be constant for second
shp, val = v.owner.inputs shp, val = v.owner.inputs
v = val v = val
continue continue
elif isinstance(v.owner.op.scalar_op, elif elemwise and isinstance(v.owner.op.scalar_op,
get_scalar_constant_value_elemwises): get_scalar_constant_value_elemwises):
const = [get_scalar_constant_value(i) const = [get_scalar_constant_value(i)
for i in v.owner.inputs] for i in v.owner.inputs]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论