openvinotoolkit/openvino

[Good First Issue]: Support torch_scatter::segment_mean_csr

Open

#29,734 opened on Mar 25, 2025

View on GitHub
 (10 comments) (0 reactions) (2 assignees)C++ (3,229 forks)auto 404
good first issueno_stale

Repository metrics

Stars
 (10,286 stars)
PR merge metrics
 (Avg merge 14d 3h) (305 merged PRs in 30d)

Description

Context

Example model to reproduce operation:

from torch_scatter import segment_csr
import torch


class Example(torch.nn.Module):
    def forward(self, src, indptr):
        return segment_csr(src, indptr, reduce="mean")

src = torch.randn(10, 6, 64)
indptr = torch.tensor([0, 2, 5, 6])
indptr = indptr.view(1, -1)

m = Example()
t = torch.jit.trace(m, example_inputs=(src, indptr))
print(t.inlined_graph)
graph(%self : __torch__.Example,
      %src : Float(10, 6, 64, strides=[384, 64, 1], requires_grad=0, device=cpu),
      %indptr : Long(1, 4, strides=[4, 1], requires_grad=0, device=cpu)):
  %3 : NoneType = prim::Constant()
  %4 : Float(10, 3, 64, strides=[192, 64, 1], requires_grad=0, device=cpu) = torch_scatter::segment_mean_csr(%src, %indptr, %3) # /home/vmaxim/openvino/ov_env/lib/python3.10/site-packages/torch/_ops.py:1123:0
  return (%4)

What needs to be done?

As in the main issue.

Example Pull Requests

No response

Resources

Contact points

As in the main issue.

Ticket

No response

Contributor guide