| 219 | self.assertEqual(np.sum(a - b), 0.) |
| 220 | |
| 221 | def test_transpose(self): |
| 222 | a = np.array( |
| 223 | [1.1, 1.1, 1.1, 1.1, 1.4, 1.3, 1.1, 1.6, 1.1, 1.1, 1.1, 1.2]) |
| 224 | a = np.reshape(a, (2, 3, 2)) |
| 225 | ta = tensor.from_numpy(a) |
| 226 | |
| 227 | A1 = np.transpose(a) |
| 228 | tA1 = tensor.transpose(ta) |
| 229 | TA1 = tensor.to_numpy(tA1) |
| 230 | A2 = np.transpose(a, [0, 2, 1]) |
| 231 | tA2 = tensor.transpose(ta, [0, 2, 1]) |
| 232 | TA2 = tensor.to_numpy(tA2) |
| 233 | |
| 234 | np.testing.assert_array_almost_equal(TA1, A1) |
| 235 | np.testing.assert_array_almost_equal(TA2, A2) |
| 236 | |
| 237 | @unittest.skipIf(not singa_api.USE_CUDA, 'CUDA is not enabled') |
| 238 | def test_gpu_6d_transpose(self,dev=gpu_dev): |