Yes the code you posted runs without errors. I added the .detach() function while selecting the tile from x, thinking it is required. That is when the error happens. Wanted to understand why detaching does not work.
The code below throws the error RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
class Tiling(nn.Module):
    # Tiling layer from original caffe-VPGNet
    def __init__(self, x_dim, tile_dim):
        super(Tiling, self).__init__()
        self.b, d, self.h, self.w = x_dim
        self.tile_dim = tile_dim
        self.out_d = int(d / (tile_dim ** 2))  # 4
        self.out_h = int(self.h * tile_dim)  # 15
        self.out_w = int(self.w * tile_dim)  # 20

    def forward(self, x):
        tiled_out = (
            torch.FloatTensor(self.b, self.out_d, self.out_h, self.out_w)
            .fill_(0.0)
        ).to(device)

        for ds in range(self.out_d):
            d_start = ds * (self.tile_dim ** 2)
            d_end = (ds + 1) * (self.tile_dim ** 2)
            for hs in range(self.h):
                for ws in range(self.w):
                    tile_select = x[:, d_start:d_end, hs, ws].detach()
                    out_tile = tile_select.view(self.b, self.tile_dim, self.tile_dim)
                    h_start = hs * self.tile_dim
                    h_end = (1 + hs) * self.tile_dim
                    w_start = ws * self.tile_dim
                    w_end = (1 + ws) * self.tile_dim
                    tiled_out[:, ds, h_start:h_end, w_start:w_end] = out_tile

        return tiled_out

Thank you