(self, dev)
| 1677 | self._Div_helper(gpu_dev) |
| 1678 | |
| 1679 | def _squeeze_helper(self, dev): |
| 1680 | x = np.random.randn(3, 1, 2, 1, 1) |
| 1681 | y = x.reshape(3, 2) |
| 1682 | dy = np.random.randn(3, 2) |
| 1683 | grad = dy.reshape(3, 1, 2, 1, 1) |
| 1684 | |
| 1685 | x = tensor.from_numpy(x) |
| 1686 | dy = tensor.from_numpy(dy) |
| 1687 | x.to_device(dev) |
| 1688 | dy.to_device(dev) |
| 1689 | |
| 1690 | result = autograd.squeeze(x, [1, 3, 4]) |
| 1691 | dx = result.creator.backward(dy.data) |
| 1692 | |
| 1693 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 1694 | y, |
| 1695 | decimal=5) |
| 1696 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 1697 | tensor.from_raw_tensor(dx)), |
| 1698 | grad, |
| 1699 | decimal=5) |
| 1700 | |
| 1701 | def test_squeeze_cpu(self): |
| 1702 | self._squeeze_helper(cpu_dev) |
no test coverage detected