提交 d6cf5c83 authored 作者: Olivier Mastropietro's avatar Olivier Mastropietro

pep8 fixes, condition if input is an alloc node, small fix in test

上级 0326fe54
......@@ -157,8 +157,7 @@ def local_dimshuffle_alloc(node):
dimshuffle{x, 0, 1}(alloc([3 4], 3, 2) => alloc([3 4], 1, 3, 2)
"""
if isinstance(node.op, T.DimShuffle):
#import ipdb ; ipdb.set_trace()
if isinstance(node.op, T.DimShuffle) and isinstance(node.inputs[0], T.Alloc):
# check if it only adds dimension to the left
new_order = node.op.new_order
expected_new_order = ('x',) * (len(new_order) - node.inputs[0].ndim) + \
......
......@@ -153,9 +153,9 @@ def test_local_reshape_dimshuffle():
reshape_dimshuffle = out2in(local_dimshuffle_alloc)
x = tensor.matrix('x')
x = tensor.vector('x')
out = tensor.alloc(x, 3, 2).dimshuffle('x','x',0,1)
out = tensor.alloc(x, 3, 2).dimshuffle('x', 'x', 0, 1)
g = FunctionGraph([x], [out])
reshape_dimshuffle(g)
......@@ -164,7 +164,7 @@ def test_local_reshape_dimshuffle():
l.accept(g)
f=l.make_function()
assert f([3,4]).ndim == 4
assert f([3, 4]).ndim == 4
topo = g.toposort()
assert any([not isinstance(x, DimShuffle) for x in topo])
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论