error when infer

#23
by liu00 - opened

If anyone has ever encountered this problem?

[TypeError: all() received an invalid combination of arguments - got (Tensor, keepdim=bool, dim=tuple), but expected one of:
(Tensor input, *, Tensor out)](TypeError: all() received an invalid combination of arguments - got (Tensor, keepdim=bool, dim=tuple), but expected one of:
(Tensor input, *, Tensor out)
didn't match because some of the keywords were incorrect: keepdim, dim
(Tensor input, int dim, bool keepdim, *, Tensor out)
(Tensor input, name dim, bool keepdim, *, Tensor out))

I had this problem, it was due to the torch version. I solved by upgrading to torch 2.4.1

I also solve it by transforming the code into this:

        cfg = self.config
        v_cfg = self.config.vision_backbone
        B, T, N, D = images.shape

        # mask = ~torch.all(images.view(B * T, N, D) == -1, dim=(1, 2), keepdim=True)
        # Converts the shape of images from (B, T, N, D) to (B * T, N, D)
        reshaped_images = images.view(B * T, N, D)

        # Creates a Boolean tensor that indicates whether each pixel is equal to -1
        equal_to_minus_one = reshaped_images == -1

        # The first calculation is along dimension 2
        intermediate_mask = torch.all(equal_to_minus_one, dim=2, keepdim=True)

        # The second calculation is along dimension 1
        all_minus_one = torch.all(intermediate_mask, dim=1, keepdim=True)

        # Create a mask that indicates which views contain valid patches
        mask = ~all_minus_one

It is not clear whether such code-switching has any effect on accuracy

I recreated this and solved by upgrading to torch 2.4.1. Feel free to reopen this issue if you need further help.

amanrangapur changed discussion status to closed

Sign up or log in to comment