提交 bbc8b519 authored 作者: Frederic's avatar Frederic

fix gh-1122 It is a crash fix reported by abalkin

上级 c3eef3db
......@@ -731,7 +731,12 @@ class ShapeFeature(object):
return self.lscalar_one
else:
# Do not call make_node for test_value
return Shape_i(i)(r)
s = Shape_i(i)(r)
try:
s = get_scalar_constant_value(s)
except NotScalarConstantError:
pass
return s
def shape_tuple(self, r):
"""Return a tuple of symbolic shape vars for tensor variable r"""
......
......@@ -2571,6 +2571,15 @@ class test_shapeoptimizer(unittest.TestCase):
f = theano.function([], out, mode=mode)
f()
def test_constant_merge(self):
"""This test the error in gh-1122 that is a caused by the
combination of merge optimizer and ShapeFeature.
"""
x = tensor.constant([0, 0])
y = x[1:]
x1 = x - tensor.join(0, y, y)
x1.eval()
def test_local_track_shape_i(self):
class IdentityNoShape(gof.Op):
'''Op that does not infer the output shape from the input one'''
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论