Esempio n. 1
0
    def test_values_correctly_set(self):
        self.check_vals(self.scalars, [], 0, pt.format())
        self.check_vals(self.order2, self.shape2, len(self.format2), self.format2)
        self.check_vals(self.order5, self.shape5, len(self.format5), self.format5)
        self.assertEqual(self.implicit_scalar[0], 0)
        self.assertFalse(self.false_bool_tensor[0])

        for i, tensor in enumerate(self.setScalar):
            self.assertEqual(tensor[0], i)
Esempio n. 2
0
 def test_format_methods(self):
     mfs = [pt.dense, pt.compressed, pt.compressed]
     mf_ordering = [2, 0, 1]
     fmt = pt.format(mfs, mf_ordering)
     self.assertEqual(fmt.order, len(mf_ordering))
     self.assertEqual(fmt.mode_formats, mfs)
     self.assertEqual(fmt.mode_ordering, mf_ordering)
     self.assertTrue(pt.csr != fmt)
     self.assertTrue(fmt == fmt)
     self.assertTrue(pt.csc == pt.csc)
     self.assertFalse(pt.is_dense(pt.csc))
Esempio n. 3
0
 def einsum(subscripts,
            *operands,
            optimize=True,
            out_format=formats.DenseFormat()):
     if isinstance(out_format, formats.DenseFormat):
         return pt.einsum(subscripts, *operands)
     pt_mode_formats = [
         TacoBackend.pt_format_dict[fmt] for fmt in out_format.mode_formats
     ]
     pt_format = pt.format(pt_mode_formats, out_format.mode_order)
     return pt.einsum(subscripts, *operands, out_format=pt_format)
Esempio n. 4
0
    def setUp(self):
        self.shape2 = [10, 10]
        self.shape5 = [4, 4, 4, 4, 4]

        self.format2 = pt.csr
        self.format5 = pt.format([pt.compressed]*5)

        self.implicit_scalar = pt.tensor([])
        self.false_bool_tensor = pt.tensor(False)

        self.scalars = [pt.tensor(dtype=dt) for dt in types]
        self.order2 = [pt.tensor(self.shape2, self.format2, dtype=dt) for dt in types]
        self.order5 = [pt.tensor(self.shape5, pt.compressed, dt) for dt in types]

        self.setScalar = [pt.tensor(i, dtype=dt) for i, dt in enumerate(types)]

        self.c_array = np.array(np.arange(100).reshape([10, 10]), order='C')
        self.f_array = np.array(np.arange(100).reshape([10, 10]), order='F')