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

Method _less_broadcast_helper

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

Source from the content-addressed store, hash-verified

2228 self._greater_broadcast_helper(gpu_dev)
2229
2230 def _less_broadcast_helper(self, dev):
2231 dev = cpu_dev
2232 cases = [
2233 ([3, 4, 5], [5]), # 3d vs 1d
2234 ([3, 4, 5], [4, 5]), # 3d vs 2d
2235 ([3, 4, 5, 6], [5, 6]), # 4d vs 2d
2236 ([3, 4, 5, 6], [4, 5, 6]), # 4d vs 3d
2237 ([1, 4, 1, 6], [3, 1, 5, 6]) # 4d vs 4d
2238 ]
2239 for in1, in2 in cases:
2240 x = np.random.randn(*in1).astype(np.float32)
2241 x1 = np.random.randn(*in2).astype(np.float32)
2242 y = np.less(x, x1)
2243
2244 x = tensor.from_numpy(x)
2245 x1 = tensor.from_numpy(x1)
2246 x.to_device(dev)
2247 x1.to_device(dev)
2248
2249 result = autograd.less(x, x1)
2250 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
2251 y,
2252 decimal=5)
2253
2254 def test_less_broadcast_cpu(self):
2255 self._less_broadcast_helper(cpu_dev)

Callers 2

Calls 1

to_deviceMethod · 0.45

Tested by

no test coverage detected