Skip to content

scatter_ supporting different reduction modes #22378

@soumith

Description

@soumith

🚀 Feature

Currently, we have scatter_ and scatter_add_.

However, in use-cases such as Graph Neural Networks, it's common to wanting to do other reductions than add.
As a case in point, @rusty1s has written https://github.com/rusty1s/pytorch_scatter which has add, sub, mean, max, min, std, mul, div.

The kernels are there, and they are minor variations of the existing scatter kernel, see here.

We should provide this in PyTorch natively, ideally has a reduce='add' keyword argument in scatter_, or if one wants it to be more explicit, scatter_reduce_(..., mode='mean')

Motivation

Graph Neural Nets are becoming pretty common.

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @anjali411 @bhosmer @smessmer @ljk53 @ailzhang @nikitaved @pearu @cpuhrsch @IvanYashchuk

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNot as big of a feature, but technically not a bug. Should be easy to fixhigh prioritymodule: internalsRelated to internal abstractions in c10 and ATenmodule: scatter & gather opsmodule: sparseRelated to torch.sparsetriagedThis 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