示例#1
0
文件: utils.py 项目: lhaippp/GyroFlow
def mesh_grid(B, H, W):
    # mesh grid
    x_base = F.arange(0, W)
    x_base = F.tile(x_base, (B, H, 1))

    y_base = F.arange(0, H)  # BHW
    y_base = F.tile(y_base, (B, W, 1)).transpose(0, 2, 1)

    base_grid = F.stack([x_base, y_base], 1)  # B2HW
    return base_grid
示例#2
0
def mesh_grid_mge(B, H, W):
    # mesh grid
    x_base = F.arange(0, W)
    x_base = F.tile(x_base, (B, H, 1))

    y_base = F.arange(0, H)  # BHW
    y_base = F.tile(y_base, (B, W, 1)).transpose(0, 2, 1)

    ones = F.ones_like(x_base)

    base_grid = F.stack([x_base, y_base, ones], 1)  # B3HW
    return base_grid
示例#3
0
 def tile_func(inp):
     return F.tile(inp=inp, reps=reps)
示例#4
0
     [(64, 512, 16, 16)],
     True,
     1000,
 ),
 (
     "topk",
     lambda x: MF.topk(x, 10),
     lambda x: torch.topk(x, 10),
     [(100, 100)],
     [(1000, 1000)],
     True,
     1000,
 ),
 (
     "tile",
     lambda x: MF.tile(x, (2, ) * len(x.shape)),
     lambda x: torch.tile(x, (2, ) * len(x.shape)),
     [(100, 100)],
     [(64, 512, 16, 16)],
     True,
     1000,
 ),
 (
     "transpose",
     lambda x: MF.transpose(x,
                            list(range(len(x.shape)))[::-1]),
     lambda x: torch.permute(x,
                             list(range(len(x.shape)))[::-1]),
     [(100, 100)],
     [(64, 512, 16, 16)],
     True,