MCPcopy Create free account
hub / github.com/apache/singa / _xor_helper

Method _xor_helper

test/python/test_operation.py:2023–2039  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

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)

Callers 2

test_xor_cpuMethod · 0.95
test_xor_gpuMethod · 0.95

Calls 2

reshapeMethod · 0.45
to_deviceMethod · 0.45

Tested by

no test coverage detected