def max(self, x): ''' _elem(float* x, uint i, float* result, ulong x_size) ''' idx = cublas.cublasIsamax(self.handle, x.size, x.gpudata, 1) value = gpuarray.to_gpu(np.zeros(0).astype(np.float32)) self._elem_kernel(x.gpudata, np.uint32(idx), \ value.gpudata, np.uint64(x.size), \ block = self._1d_block, \ grid = self._1d_grid(x.size) \ ) return value.get()[0], idx
def test_cublasIsamax(self): x = np.random.rand(5).astype(np.float32) x_gpu = gpuarray.to_gpu(x) result = cublas.cublasIsamax(x_gpu.size, x_gpu.gpudata, 1) assert np.allclose(result, np.argmax(x))
def test_cublasIsamax(self): x = np.random.rand(5).astype(np.float32) x_gpu = gpuarray.to_gpu(x) result = cublas.cublasIsamax(self.cublas_handle, x_gpu.size, x_gpu.gpudata, 1) assert np.allclose(result, np.argmax(x))