提交 c741196e authored 作者: nouiz's avatar nouiz

Merge pull request #215 from goodfeli/no_initial_inplace

No initial inplace
...@@ -3015,7 +3015,8 @@ def get_canonical_form_slice(theslice, length): ...@@ -3015,7 +3015,8 @@ def get_canonical_form_slice(theslice, length):
def transpose(x, **kwargs): def transpose(x, **kwargs):
dims = range(x.ndim-1, -1, -1) dims = range(x.ndim-1, -1, -1)
return DimShuffle(x.broadcastable, dims, inplace=True)(tensor_copy(x))
return DimShuffle(x.broadcastable, dims, inplace=False)(x)
class AdvancedIndexingError(TypeError): class AdvancedIndexingError(TypeError):
......
...@@ -1500,7 +1500,7 @@ class test_local_subtensor_lift(unittest.TestCase): ...@@ -1500,7 +1500,7 @@ class test_local_subtensor_lift(unittest.TestCase):
def test7(self): def test7(self):
# test that Subtensor(Rebroadcast(x)) gets optimized into # test that Subtensor(Rebroadcast(x)) gets optimized into
# Rebroadcast(Subtensor(x)). # Rebroadcast(Subtensor(x)).
# test basic case # test basic case
x = tensor.matrix('x') x = tensor.matrix('x')
xval = numpy.random.rand(1,10).astype(config.floatX) xval = numpy.random.rand(1,10).astype(config.floatX)
...@@ -1526,7 +1526,7 @@ class test_local_subtensor_lift(unittest.TestCase): ...@@ -1526,7 +1526,7 @@ class test_local_subtensor_lift(unittest.TestCase):
assert isinstance(prog[0].op, tensor.Subtensor) assert isinstance(prog[0].op, tensor.Subtensor)
assert isinstance(prog[1].op, tensor.Rebroadcast) assert isinstance(prog[1].op, tensor.Rebroadcast)
assert (f2(yval) == yval[:,3,0,:]).all() assert (f2(yval) == yval[:,3,0,:]).all()
# corner case 2: subtensor idx_list is shorter than resulting broadcast pattern # corner case 2: subtensor idx_list is shorter than resulting broadcast pattern
f3 = function([y], newy[:,3,0], mode=mode_opt) f3 = function([y], newy[:,3,0], mode=mode_opt)
prog=f3.maker.env.toposort() prog=f3.maker.env.toposort()
...@@ -3244,7 +3244,7 @@ class Test_lift_transpose_through_dot(unittest.TestCase): ...@@ -3244,7 +3244,7 @@ class Test_lift_transpose_through_dot(unittest.TestCase):
def test_matrix_matrix(self): def test_matrix_matrix(self):
a, b = matrices('ab') a, b = matrices('ab')
g = self.simple_optimize(Env([a, b], [tensor.dot(a, b).T])) g = self.simple_optimize(Env([a, b], [tensor.dot(a, b).T]))
sg = '[dot(InplaceDimShuffle{1,0}(b), InplaceDimShuffle{1,0}(a))]' sg = '[dot(DimShuffle{1,0}(b), DimShuffle{1,0}(a))]'
assert str(g) == sg assert str(g) == sg
def test_row_matrix(self): def test_row_matrix(self):
......
...@@ -72,10 +72,10 @@ def test_min_informative_str(): ...@@ -72,10 +72,10 @@ def test_min_informative_str():
mis = min_informative_str(G).replace("\t", " ") mis = min_informative_str(G).replace("\t", " ")
reference = """A. Elemwise{add,no_inplace} reference = """A. Elemwise{add,no_inplace}
B. C B. C
C. Elemwise{add,no_inplace} C. Elemwise{add,no_inplace}
D. D D. D
E. E""" E. E"""
if mis != reference: if mis != reference:
print '--' + mis + '--' print '--' + mis + '--'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论