Skip to content

The torch.gather documentation states that input and index must have the same number of dimensions. However, no corresponding validation is added. #157425

@xka-jxj

Description

@xka-jxj

🐛 Describe the bug

The torch.gather and Tensor.gather documentation states that input and index must have the same number of dimensions. However, no corresponding validation is added.Validation needs to be added for both CPU and GPU.

cpu:
import torch
input_data = torch.tensor([[1, 2], [3, 4], [5, 6]])
indices = torch.tensor([])
output = torch.gather(input_data, dim=0, index=indices)
print(output)

gpu:
import time
import math
import numpy as np
import torch
input_data = torch.tensor([[1, 2], [3, 4], [5, 6]])
input_data = input_data.cuda()
indices = torch.tensor([])
indices = indices.cuda()
output = torch.gather(input_data, dim=0, index=indices)
output = output.cuda()

npu:
import time
import math
import numpy as np
import torch
import torch_npu
input_data = torch.tensor([[1, 2], [3, 4], [5, 6]])
input_data = input_data.npu()
indices = torch.tensor([])
indices = indices.npu()
output = torch.gather(input_data, dim=0, index=indices)
output = output.npu()

Versions

RuntimeError: call aclnnGather failed, detail:EZ1001: [PID: 64283] 2025-05-21-07:32:10.823.227 Index tensor must have the same number of dimensions as input tensor.

cc @malfet

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: error checkingBugs related to incorrect/lacking error checkingrelease notes: python_frontendpython frontend release notes categorytriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy