def test_sanity_check(self): mySymbolicMatricesList = TypedListType( TensorType(aesara.config.floatX, (False, False)))() myMatrix = matrix() z = Append()(mySymbolicMatricesList, myMatrix) f = aesara.function([mySymbolicMatricesList, myMatrix], z) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) assert np.array_equal(f([x], y), [x, y])
def test_inplace(self): mySymbolicMatricesList = TypedListType( tt.TensorType(aesara.config.floatX, (False, False)))() myMatrix = tt.matrix() z = Append(True)(mySymbolicMatricesList, myMatrix) f = aesara.function([mySymbolicMatricesList, myMatrix], z, accept_inplace=True) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) assert np.array_equal(f([x], y), [x, y])
def test_append_inplace(self): mySymbolicMatricesList = TypedListType( TensorType(aesara.config.floatX, (False, False)))() mySymbolicMatrix = matrix() z = Append()(mySymbolicMatricesList, mySymbolicMatrix) m = aesara.compile.mode.get_default_mode().including( "typed_list_inplace_opt") f = aesara.function( [ In(mySymbolicMatricesList, borrow=True, mutable=True), In(mySymbolicMatrix, borrow=True, mutable=True), ], z, accept_inplace=True, mode=m, ) assert f.maker.fgraph.toposort()[0].op.inplace x = random_ranged(-1000, 1000, [100, 101]) y = random_ranged(-1000, 1000, [100, 101]) assert np.array_equal(f([x], y), [x, y])