(self, dev)
| 843 | self._Acos_helper(gpu_dev) |
| 844 | |
| 845 | def _Acosh_helper(self, dev): |
| 846 | X = np.array([1.1, 1.5, 1.9, 2.2, 2.5, |
| 847 | 2.8]).reshape(3, 2).astype(np.float32) |
| 848 | XT = np.arccosh(X) |
| 849 | DY = np.ones((3, 2), dtype=np.float32) |
| 850 | |
| 851 | x = tensor.from_numpy(X) |
| 852 | dy = tensor.from_numpy(DY) |
| 853 | x.to_device(dev) |
| 854 | dy.to_device(dev) |
| 855 | |
| 856 | result = autograd.acosh(x) |
| 857 | dx = result.creator.backward(dy.data) |
| 858 | |
| 859 | G = 1.0 / np.multiply(np.sqrt(X - 1.0), np.sqrt(X + 1.0)) |
| 860 | DX = np.multiply(G, DY) |
| 861 | |
| 862 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 863 | XT, |
| 864 | decimal=5) |
| 865 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 866 | tensor.from_raw_tensor(dx)), |
| 867 | DX, |
| 868 | decimal=5) |
| 869 | |
| 870 | def test_Acosh_cpu(self): |
| 871 | self._Acosh_helper(cpu_dev) |
no test coverage detected