(self, dev)
| 1774 | self._min_helper(gpu_dev) |
| 1775 | |
| 1776 | def _min_3inputs_helper(self, dev): |
| 1777 | data_0 = np.array([3, 2, 1]).astype(np.float32) |
| 1778 | data_1 = np.array([1, 4, 4]).astype(np.float32) |
| 1779 | data_2 = np.array([2, 5, 0]).astype(np.float32) |
| 1780 | XT = np.array([1, 2, 0]).astype(np.float32) |
| 1781 | |
| 1782 | DY = np.array([1, 1, 1]).astype(np.float32) |
| 1783 | x0 = tensor.from_numpy(data_0) |
| 1784 | x1 = tensor.from_numpy(data_1) |
| 1785 | x2 = tensor.from_numpy(data_2) |
| 1786 | dy = tensor.from_numpy(DY) |
| 1787 | x0.to_device(dev) |
| 1788 | x1.to_device(dev) |
| 1789 | x2.to_device(dev) |
| 1790 | dy.to_device(dev) |
| 1791 | |
| 1792 | result = autograd.min(x0, x1, x2) |
| 1793 | dx0, dx1, dx2 = result.creator.backward(dy.data) |
| 1794 | |
| 1795 | DX0 = np.array([0, 1, 0]).astype(np.float32) |
| 1796 | DX1 = np.array([1, 0, 0]).astype(np.float32) |
| 1797 | DX2 = np.array([0, 0, 1]).astype(np.float32) |
| 1798 | |
| 1799 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 1800 | XT, |
| 1801 | decimal=5) |
| 1802 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 1803 | tensor.from_raw_tensor(dx0)), |
| 1804 | DX0, |
| 1805 | decimal=5) |
| 1806 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 1807 | tensor.from_raw_tensor(dx1)), |
| 1808 | DX1, |
| 1809 | decimal=5) |
| 1810 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 1811 | tensor.from_raw_tensor(dx2)), |
| 1812 | DX2, |
| 1813 | decimal=5) |
| 1814 | |
| 1815 | def test_min_3inputs_cpu(self): |
| 1816 | self._min_3inputs_helper(cpu_dev) |
no test coverage detected