Optimize RoPEAttention implementation for onnx export#10
Merged
Aimol-l merged 1 commit intoAimol-l:mainfrom May 1, 2025
Merged
Optimize RoPEAttention implementation for onnx export#10Aimol-l merged 1 commit intoAimol-l:mainfrom
RoPEAttention implementation for onnx export#10Aimol-l merged 1 commit intoAimol-l:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
矩阵乘法实现的
RoPEAttention在TensorRT框架下耗时较高,相比于pytorch下的复数实现,在nvidia-3080-laptop下,耗时30ms(pytorch) vs 100ms(tensorrt). 主要是由于大矩阵乘法耗时较高,所以对这部分做了优化。这个PR的内容是将复数实现的
RoPEAttention转换为实数运算,既避免了复数运算ONNX/TensorRT不支持的情况,又保留了复数运算的高效率。推理速度测试:
在sam2原工程上验证,输出结果与原版一致。