(self, dev)
| 3040 | self.gather_test(gpu_dev) |
| 3041 | |
| 3042 | def tile_test(self, dev): |
| 3043 | config_repeats = [ |
| 3044 | 2, |
| 3045 | [2, 2], |
| 3046 | [2, 1, 2], |
| 3047 | ] |
| 3048 | for repeats in config_repeats: |
| 3049 | X = np.array([0, 1, 2]).astype(np.float32) |
| 3050 | y = np.tile(X, repeats) |
| 3051 | DY = np.copy(y) |
| 3052 | |
| 3053 | x = tensor.from_numpy(X) |
| 3054 | dy = tensor.from_numpy(DY) |
| 3055 | x.to_device(dev) |
| 3056 | dy.to_device(dev) |
| 3057 | |
| 3058 | result = autograd.tile(x, repeats) |
| 3059 | dx = result.creator.backward(dy.data) |
| 3060 | DX = np.multiply(X, np.prod(repeats)) |
| 3061 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 3062 | y, |
| 3063 | decimal=5) |
| 3064 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 3065 | tensor.from_raw_tensor(dx)), |
| 3066 | DX, |
| 3067 | decimal=5) |
| 3068 | |
| 3069 | def test_tile_cpu(self): |
| 3070 | self.tile_test(cpu_dev) |
no test coverage detected