Ejemplo n.º 1
0
    def test_sanity_check(self):
        mySymbolicMatricesList = TypedListType(
            TensorType(aesara.config.floatX, (False, False)))()

        z = Reverse()(mySymbolicMatricesList)

        f = aesara.function([mySymbolicMatricesList], z)

        x = rand_ranged_matrix(-1000, 1000, [100, 101])

        y = rand_ranged_matrix(-1000, 1000, [100, 101])

        assert np.array_equal(f([x, y]), [y, x])
Ejemplo n.º 2
0
    def test_inplace(self):
        mySymbolicMatricesList = TypedListType(
            tt.TensorType(aesara.config.floatX, (False, False)))()

        z = Reverse(True)(mySymbolicMatricesList)

        f = aesara.function([mySymbolicMatricesList], 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]), [y, x])
Ejemplo n.º 3
0
    def test_reverse_inplace(self):
        mySymbolicMatricesList = TypedListType(
            TensorType(aesara.config.floatX, (False, False)))()

        z = Reverse()(mySymbolicMatricesList)
        m = aesara.compile.mode.get_default_mode().including(
            "typed_list_inplace_opt")
        f = aesara.function(
            [In(mySymbolicMatricesList, 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]), [y, x])