(self, dev)
| 3350 | self.pad_helper(gpu_dev) |
| 3351 | |
| 3352 | def upsample_helper(self, dev): |
| 3353 | X = np.array([[[ |
| 3354 | [1, 2], |
| 3355 | [3, 4], |
| 3356 | ]]], dtype=np.float32) |
| 3357 | x = tensor.from_numpy(X) |
| 3358 | x.to_device(dev) |
| 3359 | |
| 3360 | scales = np.array([1.0, 1.0, 2.0, 3.0], dtype=np.float32) |
| 3361 | y_t = np.array([[[ |
| 3362 | [1, 1, 1, 2, 2, 2], |
| 3363 | [1, 1, 1, 2, 2, 2], |
| 3364 | [3, 3, 3, 4, 4, 4], |
| 3365 | [3, 3, 3, 4, 4, 4], |
| 3366 | ]]], |
| 3367 | dtype=np.float32) |
| 3368 | dy = tensor.from_numpy(y_t) |
| 3369 | dy.to_device(dev) |
| 3370 | |
| 3371 | y = autograd.upsample(x, "nearest", scales) |
| 3372 | dx = y.creator.backward(dy.data) |
| 3373 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), y_t) |
| 3374 | self.check_shape(dx.shape(), tuple(X.shape)) |
| 3375 | |
| 3376 | def test_upsample_cpu(self): |
| 3377 | self.upsample_helper(cpu_dev) |
no test coverage detected