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

Add FlattenAndUnpad Op #17845

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Add FlattenAndUnpad Op #17845

merged 3 commits into from
Nov 9, 2023

Conversation

guyang3532
Copy link
Contributor

@guyang3532 guyang3532 commented Oct 9, 2023

Description

Add an op named FlattenAndUnpad.
This op implements functions:

  1. Flatten the first two dims of input tensor.
  2. Gather valid value from input tensor with index tensor,.

Motivation and Context

The grad op of PadAndUnflatten was GatherGrad which is inefficient in performance.
I implement this FlattenAndUnpad just to replace the GatherGrad as grad of PadAndUnflatten.
With this op, we also can simplify the "Reshape + ShrunkenGather" pattern to PadAndUnflatten in padding elimination optimizer, which will also improve performance.

@guyang3532 guyang3532 requested a review from pengwa October 9, 2023 11:16
@guyang3532 guyang3532 force-pushed the yangu/flatten_and_unpad branch 2 times, most recently from 89c157e to cbf9348 Compare October 10, 2023 12:20
@pengwa pengwa added the training issues related to ONNX Runtime training; typically submitted using template label Oct 11, 2023
@guyang3532 guyang3532 force-pushed the yangu/flatten_and_unpad branch from cbf9348 to 69db77a Compare October 11, 2023 06:26
@guyang3532 guyang3532 force-pushed the yangu/flatten_and_unpad branch from 69db77a to ec58f22 Compare October 12, 2023 07:25
@guyang3532 guyang3532 force-pushed the yangu/flatten_and_unpad branch from ec58f22 to 2003901 Compare October 12, 2023 07:41
@guyang3532 guyang3532 force-pushed the yangu/flatten_and_unpad branch from 2003901 to ba4fa1e Compare November 7, 2023 05:17
@pengwa
Copy link
Contributor

pengwa commented Nov 7, 2023

Do you have perf improvement numbers to share in the PR description?

pengwa
pengwa previously approved these changes Nov 7, 2023
@pengwa pengwa merged commit 4dc6369 into main Nov 9, 2023
91 checks passed
@pengwa pengwa deleted the yangu/flatten_and_unpad branch November 9, 2023 01:52
kleiti pushed a commit to kleiti/onnxruntime that referenced this pull request Mar 22, 2024
### Description
Add an op named `FlattenAndUnpad`.
This op implements functions:
1. Flatten the first two dims of input tensor.
2. Gather valid value from input tensor with index tensor,.


### Motivation and Context
The grad op of `PadAndUnflatten` was `GatherGrad` which is inefficient
in performance.
I implement this `FlattenAndUnpad` just to replace the `GatherGrad` as
grad of `PadAndUnflatten`.
With this op, we also can simplify the "Reshape + ShrunkenGather"
pattern to `PadAndUnflatten` in padding elimination optimizer, which
will also improve performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
training issues related to ONNX Runtime training; typically submitted using template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants