(self, dev)
| 2138 | self._and_broadcast_helper(gpu_dev) |
| 2139 | |
| 2140 | def _or_broadcast_helper(self, dev): |
| 2141 | cases = [ |
| 2142 | ([3, 4, 5], [5]), # 3d vs 1d |
| 2143 | ([3, 4, 5], [4, 5]), # 3d vs 2d |
| 2144 | ([3, 4, 5, 6], [5, 6]), # 4d vs 2d |
| 2145 | ([3, 4, 5, 6], [4, 5, 6]), # 4d vs 3d |
| 2146 | ([1, 4, 1, 6], [3, 1, 5, 6]) # 4d vs 4d |
| 2147 | ] |
| 2148 | for in1, in2 in cases: |
| 2149 | x = (np.random.randn(*in1) > 0).astype(np.float32) |
| 2150 | x1 = (np.random.randn(*in2) > 0).astype(np.float32) |
| 2151 | y = np.logical_or(x, x1) |
| 2152 | |
| 2153 | x = tensor.from_numpy(x) |
| 2154 | x1 = tensor.from_numpy(x1) |
| 2155 | x.to_device(dev) |
| 2156 | x1.to_device(dev) |
| 2157 | |
| 2158 | result = autograd._or(x, x1) |
| 2159 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 2160 | y, |
| 2161 | decimal=5) |
| 2162 | |
| 2163 | def test_or_broadcast_cpu(self): |
| 2164 | self._or_broadcast_helper(cpu_dev) |
no test coverage detected