@testinfo()
def test_type_param_dtype_not_dense(self):
    shape_list = [(16, 32, 2, 30), (2, 3, 4, 32), (24, 26, 112, 64), (2, 3, 24, 30), (1, 1, 1, 30)]
    cast_map = {torch.float: {torch.half, torch.int, torch.short, torch.int8, torch.bool}, torch.half: {torch.float, torch.int, torch.short, torch.int8, torch.bool}, torch.long: {torch.float, torch.half, torch.short, torch.int8}, torch.int: {torch.float, torch.half, torch.short, torch.int8}, torch.short: {torch.float, torch.half, torch.int}, torch.int8: {torch.float, torch.half, torch.int}, torch.uint8: {torch.float, torch.half}, torch.bool: {torch.float, torch.half, torch.int}}
    for (shape, src_type) in product(shape_list, cast_map.keys()):
        for dst_type in cast_map[src_type]:
            if (src_type in [torch.half, torch.float]):
                x = torch.randn(shape, dtype=src_type)[:, :, :, :15]
            elif (src_type == torch.uint8):
                x = torch.randint(0, 255, shape).to(src_type)[:, :, :, :15]
            else:
                x = torch.randint((- 128), 128, shape).to(src_type)[:, :, :, :15]
            for is_async in [False, True]:
                out_cpu = x.type(dst_type, non_blocking=is_async)
                out_mlu = x.to(ct.mlu_device()).type(dst_type, non_blocking=is_async)
                self.assertEqual(out_mlu.dtype, dst_type)
                self.assertEqual(out_cpu, out_mlu.cpu())
@testinfo()
def test_type_param_dtype_not_dense(self):
    shape_list = [(16, 32, 2, 30), (2, 3, 4, 32), (24, 26, 112, 64), (2, 3, 24, 30), (1, 1, 1, 30)]
    cast_map = {torch.float: {torch.half, torch.int, torch.short, torch.int8, torch.bool}, torch.half: {torch.float, torch.int, torch.short, torch.int8, torch.bool}, torch.long: {torch.float, torch.half, torch.short, torch.int8}, torch.int: {torch.float, torch.half, torch.short, torch.int8}, torch.short: {torch.float, torch.half, torch.int}, torch.int8: {torch.float, torch.half, torch.int}, torch.uint8: {torch.float, torch.half}, torch.bool: {torch.float, torch.half, torch.int}}
    for (shape, src_type) in product(shape_list, cast_map.keys()):
        for dst_type in cast_map[src_type]:
            if (src_type in [torch.half, torch.float]):
                x = torch.randn(shape, dtype=src_type)[:, :, :, :15]
            elif (src_type == torch.uint8):
                x = torch.randint(0, 255, shape).to(src_type)[:, :, :, :15]
            else:
                x = torch.randint((- 128), 128, shape).to(src_type)[:, :, :, :15]
            for is_async in [False, True]:
                out_cpu = x.type(dst_type, non_blocking=is_async)
                out_mlu = x.to(ct.mlu_device()).type(dst_type, non_blocking=is_async)
                self.assertEqual(out_mlu.dtype, dst_type)
                self.assertEqual(out_cpu, out_mlu.cpu())