提交 7dae6a7f authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Split and move comment following code review

上级 84ef2c9d
...@@ -904,10 +904,16 @@ class ShapeFeature(object): ...@@ -904,10 +904,16 @@ class ShapeFeature(object):
# Merge other_shape with r_shape, giving the priority to other_shape # Merge other_shape with r_shape, giving the priority to other_shape
merged_shape = [] merged_shape = []
for i, ps in enumerate(other_shape): for i, ps in enumerate(other_shape):
if (ps.owner
and isinstance(getattr(ps.owner, 'op', None), Shape_i)
and ps.owner.op.i == i
and ps.owner.inputs[0] in (r, other_r)):
# If other_shape[i] is uninformative, use r_shape[i]. # If other_shape[i] is uninformative, use r_shape[i].
# For now, we consider 2 cases of uninformative other_shape[i]: # For now, we consider 2 cases of uninformative other_shape[i]:
# - Shape_i(i)(other_r); # - Shape_i(i)(other_r);
# - Shape_i(i)(r). # - Shape_i(i)(r).
merged_shape.append(r_shape[i])
elif r_shape[i] in theano.gof.graph.ancestors([other_shape[i]]):
# Another case where we want to use r_shape[i] is when # Another case where we want to use r_shape[i] is when
# other_shape[i] actually depends on r_shape[i]. In that case, # other_shape[i] actually depends on r_shape[i]. In that case,
# we do not want to substitute an expression with another that # we do not want to substitute an expression with another that
...@@ -915,12 +921,6 @@ class ShapeFeature(object): ...@@ -915,12 +921,6 @@ class ShapeFeature(object):
# to cycles: if (in the future) r_shape[i] gets replaced by an # to cycles: if (in the future) r_shape[i] gets replaced by an
# expression of other_shape[i], other_shape[i] may end up # expression of other_shape[i], other_shape[i] may end up
# depending on itself. # depending on itself.
if (ps.owner
and isinstance(getattr(ps.owner, 'op', None), Shape_i)
and ps.owner.op.i == i
and ps.owner.inputs[0] in (r, other_r)):
merged_shape.append(r_shape[i])
elif r_shape[i] in theano.gof.graph.ancestors([other_shape[i]]):
merged_shape.append(r_shape[i]) merged_shape.append(r_shape[i])
else: else:
merged_shape.append(other_shape[i]) merged_shape.append(other_shape[i])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论