(self, dev)
| 907 | self._Sin_helper(gpu_dev) |
| 908 | |
| 909 | def _Sinh_helper(self, dev): |
| 910 | X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, |
| 911 | 0.5]).reshape(3, 2).astype(np.float32) |
| 912 | XT = np.sinh(X) |
| 913 | DY = np.ones((3, 2), dtype=np.float32) |
| 914 | |
| 915 | x = tensor.from_numpy(X) |
| 916 | dy = tensor.from_numpy(DY) |
| 917 | x.to_device(dev) |
| 918 | dy.to_device(dev) |
| 919 | |
| 920 | result = autograd.sinh(x) |
| 921 | dx = result.creator.backward(dy.data) |
| 922 | |
| 923 | G = np.cosh(X) |
| 924 | DX = np.multiply(G, DY) |
| 925 | |
| 926 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 927 | XT, |
| 928 | decimal=5) |
| 929 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 930 | tensor.from_raw_tensor(dx)), |
| 931 | DX, |
| 932 | decimal=5) |
| 933 | |
| 934 | def test_Sinh_cpu(self): |
| 935 | self._Sinh_helper(cpu_dev) |
no test coverage detected