(self, dev)
| 875 | self._Acosh_helper(gpu_dev) |
| 876 | |
| 877 | def _Sin_helper(self, dev): |
| 878 | X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, |
| 879 | 0.5]).reshape(3, 2).astype(np.float32) |
| 880 | XT = np.sin(X) |
| 881 | DY = np.ones((3, 2), dtype=np.float32) |
| 882 | |
| 883 | x = tensor.from_numpy(X) |
| 884 | dy = tensor.from_numpy(DY) |
| 885 | x.to_device(dev) |
| 886 | dy.to_device(dev) |
| 887 | |
| 888 | result = autograd.sin(x) |
| 889 | dx = result.creator.backward(dy.data) |
| 890 | |
| 891 | G = np.cos(X) |
| 892 | DX = np.multiply(G, DY) |
| 893 | |
| 894 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 895 | XT, |
| 896 | decimal=5) |
| 897 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 898 | tensor.from_raw_tensor(dx)), |
| 899 | DX, |
| 900 | decimal=5) |
| 901 | |
| 902 | def test_Sin_cpu(self): |
| 903 | self._Sin_helper(cpu_dev) |
no test coverage detected