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)
def g(x): return cupy.frexp(x)
def decompose_cupy(tensor): mantissa, exponent = cupy.frexp(torch2cupy(tensor.float())) return cupy2torch(mantissa).half(), cupy2torch(exponent).to(torch.int8)