Ejemplo n.º 1
0
    def setup(self):
        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        # Summation of all the entries of a vector
        self.register_output('einsum_summ1',
                             ot.einsum_new_api(vec, operation=[(33, )]))
Ejemplo n.º 2
0
    def setup(self):
        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        self.register_output(
            'einsum_summ1_sparse_derivs',
            ot.einsum_new_api(vec, operation=[(33, )],
                              partial_format='sparse'))
Ejemplo n.º 3
0
    def setup(self):
        shape2 = (5, 4)
        b = np.arange(20).reshape(shape2)
        mat = self.declare_input('b', val=b)

        # reorder of a matrix
        self.register_output(
            'einsum_reorder1',
            ot.einsum_new_api(mat, operation=[(46, 99), (99, 46)]))
Ejemplo n.º 4
0
    def setup(self):
        a = np.arange(4)

        vec = self.declare_input('a', val=a)

        # Inner Product of 2 vectors
        self.register_output(
            'einsum_inner1',
            ot.einsum_new_api(vec, vec, operation=[(0, ), (0, )]))
Ejemplo n.º 5
0
    def setup(self):

        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        # Special operation: sum all the entries of the first and second
        # vector to a single scalar
        self.register_output(
            'einsum_special2',
            ot.einsum_new_api(vec, vec, operation=[(1, ), (2, )]))
Ejemplo n.º 6
0
    def setup(self):
        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        self.register_output(
            'einsum_outer1',
            ot.einsum_new_api(
                vec,
                vec,
                operation=[('rows', ), ('cols', ), ('rows', 'cols')],
            ))
Ejemplo n.º 7
0
    def setup(self):

        shape2 = (5, 4)
        b = np.arange(20).reshape(shape2)
        mat = self.declare_input('b', val=b)

        self.register_output(
            'einsum_reorder1_sparse_derivs',
            ot.einsum_new_api(mat,
                              operation=[(46, 99), (99, 46)],
                              partial_format='sparse'))
Ejemplo n.º 8
0
    def setup(self):
        # Shape of Tensor
        shape3 = (2, 4, 3)
        c = np.arange(24).reshape(shape3)

        # Declaring tensor
        tens = self.declare_input('c', val=c)

        self.register_output(
            'einsum_summ2_sparse_derivs',
            ot.einsum_new_api(tens,
                              operation=[(33, 66, 99)],
                              partial_format='sparse'))
Ejemplo n.º 9
0
    def setup(self):
        # Shape of Tensor
        shape3 = (2, 4, 3)
        c = np.arange(24).reshape(shape3)

        # Declaring tensor
        tens = self.declare_input('c', val=c)

        # Summation of all the entries of a tensor
        self.register_output(
            'einsum_summ2', ot.einsum_new_api(
                tens,
                operation=[(33, 66, 99)],
            ))
Ejemplo n.º 10
0
    def setup(self):

        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        # Special operation: summation of all the entries of first
        # vector and scalar multiply the second vector with the computed
        # sum
        self.register_output(
            'einsum_special1',
            ot.einsum_new_api(
                vec,
                vec,
                operation=[(1, ), (2, ), (2, )],
            ))
Ejemplo n.º 11
0
    def setup(self):

        # Shape of Tensor
        shape3 = (2, 4, 3)
        c = np.arange(24).reshape(shape3)

        # Declaring tensor
        tens = self.declare_input('c', val=c)

        # reorder of a tensor
        self.register_output(
            'einsum_reorder2',
            ot.einsum_new_api(
                tens,
                operation=[(33, 66, 99), (99, 66, 33)],
            ))
Ejemplo n.º 12
0
    def setup(self):
        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        # Shape of Tensor
        shape3 = (2, 4, 3)
        c = np.arange(24).reshape(shape3)

        # Declaring tensor
        tens = self.declare_input('c', val=c)

        # Outer Product of a tensor and a vector
        self.register_output(
            'einsum_outer2',
            ot.einsum_new_api(
                tens,
                vec,
                operation=[(0, 1, 30), (2, ), (0, 1, 30, 2)],
            ))
Ejemplo n.º 13
0
    def setup(self):

        a = np.arange(4)
        vec = self.declare_input('a', val=a)

        # Shape of Tensor
        shape3 = (2, 4, 3)
        c = np.arange(24).reshape(shape3)

        # Declaring tensor
        tens = self.declare_input('c', val=c)

        self.register_output(
            'einsum_outer2_sparse_derivs',
            ot.einsum_new_api(tens,
                              vec,
                              operation=[
                                  (0, 1, 30),
                                  (2, ),
                                  (0, 1, 30, 2),
                              ],
                              partial_format='sparse'))