(self, dev)
| 163 | self.assertEqual(tensor.average(y), 2.) |
| 164 | |
| 165 | def matmul_high_dim_helper(self, dev): |
| 166 | configs = [ |
| 167 | [(1, 12, 7, 64), (1, 12, 64, 7)], |
| 168 | [(1, 7, 768), (768, 768)], |
| 169 | ] |
| 170 | print() |
| 171 | for config in configs: |
| 172 | X = np.random.random(config[0]).astype(np.float32) |
| 173 | x = tensor.from_numpy(X) |
| 174 | x.to_device(dev) |
| 175 | |
| 176 | W = np.random.random(config[1]).astype(np.float32) |
| 177 | w = tensor.from_numpy(W) |
| 178 | w.to_device(dev) |
| 179 | |
| 180 | y_t = np.matmul(X, W) |
| 181 | y = autograd.matmul(x, w) |
| 182 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), y_t, 3) |
| 183 | |
| 184 | def test_matmul_high_dim_cpu(self): |
| 185 | self.matmul_high_dim_helper(cpu_dev) |
no test coverage detected