onnxruntime/onnxruntime
guyang3532 341484e67c
Embedding sparsity optimization (#16141)
### Description
Optimize compute graph by eliminating padding in embedding.


### Motivation and Context
The computation for padding in nodes after embedding is unnecessary and
waste computation resources.
This pr just add an Optimizer of PaddingElimination to check and
eliminate the padding after embedding automatically by modifying the
graph.

### Implementation:
1. Find and check embedding node in graph.
2. Iterate the subgraph afterward the embedding node and record all the
input nodes and output nodes to this subgraph.
3. Insert 'Reshape + ShrunkenGather' to flatten each input node shape
from [batch_size, seqlen, ...] to [valid_token_without_padding, ...],
and insert 'GatherGrad + Reshape' to unflatten each output node shape
from [valid_token_without_padding, ...] to [batch_size, seqlen, ...]

---------

Co-authored-by: mindest <linminuser@gmail.com>
2023-06-19 20:34:53 +08:00
..
contrib_ops Stabilize Whisper export with beam search (#16297) 2023-06-16 18:56:52 -07:00
core Embedding sparsity optimization (#16141) 2023-06-19 20:34:53 +08:00
python Stabilize Whisper export with beam search (#16297) 2023-06-16 18:56:52 -07:00
test Separate out operator vs model testing. (#16228) 2023-06-17 12:58:57 +10:00
tool/etw
wasm [js/web] enable ONNX Runtime Web error messages in JS (#16335) 2023-06-15 09:45:41 -07:00
__init__.py Update VERSION_NUMBER (#15773) 2023-05-03 15:07:34 -07:00
ReformatSource.ps1
ReformatSourcePython.bat
VSCodeCoverage.runsettings