提交 280cb21b authored 作者: Frederic's avatar Frederic

small code clean up following code review

上级 b6307757
...@@ -577,19 +577,15 @@ def get_scalar_constant_value(v): ...@@ -577,19 +577,15 @@ def get_scalar_constant_value(v):
scal.NEQ, scal.EQ, scal.NEQ, scal.EQ,
scal.LT, scal.GT, scal.LE, scal.GE, scal.LT, scal.GT, scal.LE, scal.GE,
scal.Sub, scal.Add, scal.Mod, scal.Mul, scal.Sub, scal.Add, scal.Mod, scal.Mul,
scal.IntDiv, scal.TrueDiv, scal.IntDiv, scal.TrueDiv)
scal.Second)
if (isinstance(v.owner.op, Elemwise) and if (isinstance(v.owner.op, Elemwise) and
len(v.owner.outputs) == 1 and len(v.owner.outputs) == 1 and
(isinstance(v.owner.op.scalar_op, elemwises) or (isinstance(v.owner.op.scalar_op, elemwises) or
isinstance(v.owner.op, elemwises))): isinstance(v.owner.op, elemwises))):
try: const = [get_scalar_constant_value(i) for i in v.owner.inputs]
const = [get_scalar_constant_value(i) for i in v.owner.inputs] ret = [[None]]
ret = [[None]] v.owner.op.perform(v.owner, const, ret)
v.owner.op.perform(v.owner, const, ret) return ret[0][0]
return ret[0][0]
except NotScalarConstantError:
pass
if isinstance(v.owner.op, theano.tensor.subtensor.Subtensor) and v.ndim == 0: if isinstance(v.owner.op, theano.tensor.subtensor.Subtensor) and v.ndim == 0:
# This condition depends on Subtensor always embedding constant # This condition depends on Subtensor always embedding constant
# indices in the Op rather than making them inputs to the Apply # indices in the Op rather than making them inputs to the Apply
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论