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

Method _max_1inputs_helper

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

Source from the content-addressed store, hash-verified

1609 self._max_3inputs_helper(gpu_dev)
1610
1611 def _max_1inputs_helper(self, dev):
1612 data_0 = np.array([3, 2, 1]).astype(np.float32)
1613 XT = np.array([3, 2, 1]).astype(np.float32)
1614
1615 DY = np.array([1, 1, 1]).astype(np.float32)
1616 x0 = tensor.from_numpy(data_0)
1617 dy = tensor.from_numpy(DY)
1618 x0.to_device(dev)
1619 dy.to_device(dev)
1620
1621 result = autograd.max(x0)
1622 dx0 = result.creator.backward(dy.data)
1623
1624 DX0 = np.array([1, 1, 1]).astype(np.float32)
1625
1626 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
1627 XT,
1628 decimal=5)
1629
1630 def test_max_1inputs_cpu(self):
1631 self._max_1inputs_helper(cpu_dev)

Callers 2

test_max_1inputs_cpuMethod · 0.95
test_max_1inputs_gpuMethod · 0.95

Calls 2

to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected