提交 df1176a3 authored 作者: Pierre Luc Carrier's avatar Pierre Luc Carrier

Refactor local_useless_subtensor to allow earlier exiting of the function

上级 b9bfe165
...@@ -1947,15 +1947,17 @@ def local_useless_subtensor(node): ...@@ -1947,15 +1947,17 @@ def local_useless_subtensor(node):
# is not a useless subtensor # is not a useless subtensor
return False return False
length_pos_data = maxsize for pos, idx in enumerate(cdata):
length_pos = shape_of[node.inputs[0]][pos] length_pos = shape_of[node.inputs[0]][pos]
if isinstance(idx.stop, (int, numpy.integer)):
length_pos_data = maxsize
try: try:
length_pos_data = get_scalar_constant_value(length_pos) length_pos_data = get_scalar_constant_value(length_pos)
except NotScalarConstantError: except NotScalarConstantError:
pass pass
if isinstance(idx.stop, (int, numpy.integer)):
if idx.stop < length_pos_data: if idx.stop < length_pos_data:
return False return False
elif isinstance(idx.stop, gof.Variable): elif isinstance(idx.stop, gof.Variable):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论