提交 5c80ccc7 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: Caglar

Fix an opt as T.extract_constant don't always return the same type. I made issue…

Fix an opt as T.extract_constant don't always return the same type. I made issue gh-4188 to fix that more generally.
上级 22105f78
...@@ -3736,7 +3736,8 @@ def local_useless_switch(node): ...@@ -3736,7 +3736,8 @@ def local_useless_switch(node):
isinstance(node.op.scalar_op, scalar.basic.Switch)): isinstance(node.op.scalar_op, scalar.basic.Switch)):
cond = T.extract_constant(node.inputs[0], elemwise=False, cond = T.extract_constant(node.inputs[0], elemwise=False,
only_process_constants=True) only_process_constants=True)
if type(cond) is numpy.ndarray and cond.ndim == 0: if ((type(cond) is numpy.ndarray and cond.ndim == 0) or
isinstance(cond, numpy.number)):
if cond == 0: if cond == 0:
correct_out = node.inputs[2] correct_out = node.inputs[2]
else: else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论