(self, dev)
| 939 | self._Sinh_helper(gpu_dev) |
| 940 | |
| 941 | def _Asin_helper(self, dev): |
| 942 | X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 943 | 0.9]).reshape(3, 2).astype(np.float32) |
| 944 | XT = np.arcsin(X) |
| 945 | DY = np.ones((3, 2), dtype=np.float32) |
| 946 | |
| 947 | x = tensor.from_numpy(X) |
| 948 | dy = tensor.from_numpy(DY) |
| 949 | x.to_device(dev) |
| 950 | dy.to_device(dev) |
| 951 | |
| 952 | result = autograd.asin(x) |
| 953 | dx = result.creator.backward(dy.data) |
| 954 | |
| 955 | G = 1.0 / np.sqrt(1.0 - np.square(X)) |
| 956 | DX = np.multiply(G, DY) |
| 957 | |
| 958 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 959 | XT, |
| 960 | decimal=5) |
| 961 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 962 | tensor.from_raw_tensor(dx)), |
| 963 | DX, |
| 964 | decimal=5) |
| 965 | |
| 966 | def test_Asin_cpu(self): |
| 967 | self._Asin_helper(cpu_dev) |
no test coverage detected