(self, dev)
| 2021 | self._not_helper(gpu_dev) |
| 2022 | |
| 2023 | def _xor_helper(self, dev): |
| 2024 | x0 = np.array([0, -0.3, -0.1, 0.1, 0.5, |
| 2025 | 9.0]).reshape(3, 2).astype(np.float32) |
| 2026 | x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3, |
| 2027 | 2).astype(np.float32) |
| 2028 | |
| 2029 | y = np.logical_xor(x0, x1) |
| 2030 | x0 = tensor.from_numpy(x0) |
| 2031 | x1 = tensor.from_numpy(x1) |
| 2032 | x0.to_device(dev) |
| 2033 | x1.to_device(dev) |
| 2034 | |
| 2035 | result = autograd._xor(x0, x1) |
| 2036 | |
| 2037 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 2038 | y, |
| 2039 | decimal=5) |
| 2040 | |
| 2041 | def test_xor_cpu(self): |
| 2042 | self._xor_helper(cpu_dev) |
no test coverage detected