Beispiel #1
0
    def _impl_test_minmax(self, dtype):
        x = np.random.normal(scale=5.0, size=(3, 5))
        x = x.astype(dtype=dtype, order='C')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])

        x = x.astype(dtype=dtype, order='F')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
Beispiel #2
0
    def _impl_test_minmax(self, dtype):
        x = np.random.normal(scale=5.0, size=(3, 5))
        x = x.astype(dtype=dtype, order='C')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(),
                        x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(),
                        x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(),
                        x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(),
                        x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])

        x = x.astype(dtype=dtype, order='F')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(),
                        x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(),
                        x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(),
                        x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(),
                        x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])