Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOPI][Relay][ONNX] Replace scatter_add by scatter_elements(reduction="add") #14008

Merged
merged 19 commits into from
Feb 23, 2023

Conversation

vvchernov
Copy link
Contributor

@vvchernov vvchernov commented Feb 16, 2023

Operation scatter_add duplicates one of functionality of scatter_elements. It was replaced, but useful code was transferred to scatter_elements (particularly cuda implementation for 1d input)

cc @AndrewZhaoLuo

@tvm-bot
Copy link
Collaborator

tvm-bot commented Feb 16, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@vvchernov vvchernov force-pushed the vc/rem_scatter_add branch 3 times, most recently from 55ff794 to 171a8cb Compare February 16, 2023 16:56
@vvchernov vvchernov changed the title WIP: [TOPI][Front-end] Replace scatter_add by scatter_elements(reduction="add") WIP: [TOPI][Relay][ONNX] Replace scatter_add by scatter_elements(reduction="add") Feb 16, 2023
@vvchernov vvchernov changed the title WIP: [TOPI][Relay][ONNX] Replace scatter_add by scatter_elements(reduction="add") [TOPI][Relay][ONNX] Replace scatter_add by scatter_elements(reduction="add") Feb 17, 2023
@vvchernov vvchernov force-pushed the vc/rem_scatter_add branch 3 times, most recently from 4b0d49b to ca239fe Compare February 19, 2023 08:02
python/tvm/relay/op/_transform.py Show resolved Hide resolved
from .nms import atomic_add


def gen_scatter_add_1d_atomic(data, indices, updates, out, axis, _):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is something I think I might have missed. Within indices along a particular axis, do we expect all indices to be unique? Otherwise I believe something similar must be done with all operators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, potentially we can. The problem is that quick search did not give me any atomic operation like atomic_add, moreover it is not supported by some architectures ("vulkan", "metal"). I postponed this task due to it requires more time for investigation and implementation but does not have any priority.

@vvchernov
Copy link
Contributor Author

@tvm-bot rerun

Copy link
Contributor

@KJlaccHoeUM9l KJlaccHoeUM9l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vvchernov
Copy link
Contributor Author

Hello @AndrewZhaoLuo! Could you see this PR again?

Copy link
Contributor

@AndrewZhaoLuo AndrewZhaoLuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the refactor @vvchernov !

@AndrewZhaoLuo AndrewZhaoLuo merged commit c64f462 into apache:main Feb 23, 2023
@vvchernov vvchernov deleted the vc/rem_scatter_add branch February 24, 2023 05:11
yongwww pushed a commit to yongwww/tvm that referenced this pull request Feb 27, 2023
…="add") (apache#14008)

* update paddlepaddle

* update tensorflow

* update pytorch

* remove scatter_add strategy

* remove ScatterAddAttrs registration

* remove scatter_add from front-end

* remove scatter_add schedule and strategy

* remove back-end API of scatter_add

* update test_op_level3

* add checks for scatter_add to pytorch front-end

* remove cpu topi implementation of scatter_add

* remove scatter_add strategy for cuda-gpu

* transfer reduction_func definition on higher level

* use atomic_add in cude scatter_elements. remove cuda implementation for scatter_add

* fix lint

* remove ScatterAddAttrs

* fix condition for using of atomic_add

* last upstream of scatter_add with pytorch description. add test case

* upstream scatter_elements for CPU with CUDA approach

---------

Co-authored-by: Valery Chernov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants