提交 8186a4f0 authored 作者: Frederic Bastien's avatar Frederic Bastien

Added comment and be more specifix when catching exception.

上级 8c878ce3
...@@ -377,6 +377,9 @@ class ScanSaveMem(gof.Optimizer): ...@@ -377,6 +377,9 @@ class ScanSaveMem(gof.Optimizer):
if hasattr(env, 'shape_feature'): if hasattr(env, 'shape_feature'):
shape_of = node.env.shape_feature.shape_of shape_of = node.env.shape_feature.shape_of
else: else:
# Each call site of shape_of is in a try..except
# That use a default version when the variable is not
# in the dictionary
shape_of = {} shape_of = {}
# 1. Initialization of variables # 1. Initialization of variables
# Note 1) We do not actually care about outputs representing shared # Note 1) We do not actually care about outputs representing shared
...@@ -475,12 +478,12 @@ class ScanSaveMem(gof.Optimizer): ...@@ -475,12 +478,12 @@ class ScanSaveMem(gof.Optimizer):
if i > op.n_mit_mot: if i > op.n_mit_mot:
try: try:
length = shape_of[out][0] length = shape_of[out][0]
except Exception: except KeyError:
length = node.inputs[0] + init_l[i] length = node.inputs[0] + init_l[i]
else: else:
try: try:
length = shape_of[out][0] length = shape_of[out][0]
except Exception: except KeyError:
length = out.shape[0] length = out.shape[0]
cf_slice = tensor.basic.get_canonical_form_slice( cf_slice = tensor.basic.get_canonical_form_slice(
this_slice[0], length) this_slice[0], length)
...@@ -578,7 +581,7 @@ class ScanSaveMem(gof.Optimizer): ...@@ -578,7 +581,7 @@ class ScanSaveMem(gof.Optimizer):
else: else:
try: try:
length = shape_of[out][0] length = shape_of[out][0]
except Exception: except KeyError:
length = out.shape[0] length = out.shape[0]
cf_slice = tensor.basic.get_canonical_form_slice( cf_slice = tensor.basic.get_canonical_form_slice(
this_slice[0], length) this_slice[0], length)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论