def testCosOrderExecution(self): data = np.asfortranarray(np.random.rand(3, 5)) x = tensor(data, chunk_size=2) t = cos(x) res = self.executor.execute_tensor(t, concat=True)[0] np.testing.assert_allclose(res, np.cos(data)) self.assertFalse(res.flags['C_CONTIGUOUS']) self.assertTrue(res.flags['F_CONTIGUOUS']) t2 = cos(x, order='C') res2 = self.executor.execute_tensor(t2, concat=True)[0] np.testing.assert_allclose(res2, np.cos(data, order='C')) self.assertTrue(res2.flags['C_CONTIGUOUS']) self.assertFalse(res2.flags['F_CONTIGUOUS'])
def test_cos_order_execution(setup): data = np.asfortranarray(np.random.rand(3, 5)) x = tensor(data, chunk_size=2) t = cos(x) res = t.execute().fetch() np.testing.assert_allclose(res, np.cos(data)) assert res.flags['C_CONTIGUOUS'] is False assert res.flags['F_CONTIGUOUS'] is True t2 = cos(x, order='C') res2 = t2.execute().fetch() np.testing.assert_allclose(res2, np.cos(data, order='C')) assert res2.flags['C_CONTIGUOUS'] is True assert res2.flags['F_CONTIGUOUS'] is False
def testCupyExecution(self): a_data = np.random.rand(10, 10) b_data = np.random.rand(10, 10) a = tensor(a_data, gpu=True, chunk_size=3) b = tensor(b_data, gpu=True, chunk_size=3) res_binary = self.executor.execute_tensor((a + b), concat=True)[0] np.testing.assert_array_equal(res_binary.get(), (a_data + b_data)) res_unary = self.executor.execute_tensor(cos(a), concat=True)[0] np.testing.assert_array_almost_equal(res_unary.get(), np.cos(a_data))
def test_cupy_execution(setup): a_data = np.random.rand(10, 10) b_data = np.random.rand(10, 10) a = tensor(a_data, gpu=True, chunk_size=3) b = tensor(b_data, gpu=True, chunk_size=3) res_binary = (a + b).execute().fetch() np.testing.assert_array_equal(res_binary.get(), (a_data + b_data)) res_unary = cos(a).execute().fetch() np.testing.assert_array_almost_equal(res_unary.get(), np.cos(a_data))
def testCos(self): t1 = tensor([[0, 1, 0], [1, 0, 0]], chunk_size=2).tosparse() t = cos(t1) self.assertTrue(t.issparse()) self.assertIs(type(t), SparseTensor)
def test_cos(): t1 = tensor([[0, 1, 0], [1, 0, 0]], chunk_size=2).tosparse() t = cos(t1) assert t.issparse() is True assert type(t) is SparseTensor