Exemplo n.º 1
0
    def test_frexp(self, dtype):
        numpy_a = numpy.array([-300, -20, -10, -1, 0, 1, 10, 20, 300], dtype=dtype)
        numpy_b, numpy_c = numpy.frexp(numpy_a)

        cupy_a = cupy.array(numpy_a)
        cupy_b, cupy_c = cupy.frexp(cupy_a)

        testing.assert_allclose(cupy_b, numpy_b)
        testing.assert_array_equal(cupy_c, numpy_c)
Exemplo n.º 2
0
    def test_frexp(self, dtype):
        numpy_a = numpy.array([-300, -20, -10, -1, 0, 1, 10, 20, 300],
                              dtype=dtype)
        numpy_b, numpy_c = numpy.frexp(numpy_a)

        cupy_a = cupy.array(numpy_a)
        cupy_b, cupy_c = cupy.frexp(cupy_a)

        testing.assert_allclose(cupy_b, numpy_b)
        testing.assert_array_equal(cupy_c, numpy_c)
Exemplo n.º 3
0
 def g(x):
     return cupy.frexp(x)
Exemplo n.º 4
0
def decompose_cupy(tensor):
    mantissa, exponent = cupy.frexp(torch2cupy(tensor.float()))
    return cupy2torch(mantissa).half(), cupy2torch(exponent).to(torch.int8)
Exemplo n.º 5
0
 def g(x):
     return cupy.frexp(x)