Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Optimize RoPEAttention implementation for onnx export#10

Merged
Aimol-l merged 1 commit into
Aimol-l:mainAimol-l/SAM2Export:mainfrom
zz990099:mainzz990099/SAM2Export:mainCopy head branch name to clipboard
May 1, 2025
Merged

Optimize RoPEAttention implementation for onnx export#10
Aimol-l merged 1 commit into
Aimol-l:mainAimol-l/SAM2Export:mainfrom
zz990099:mainzz990099/SAM2Export:mainCopy head branch name to clipboard

Conversation

@zz990099

Copy link
Copy Markdown
Contributor

矩阵乘法实现的RoPEAttention在TensorRT框架下耗时较高,相比于pytorch下的复数实现,在nvidia-3080-laptop下,耗时 30ms(pytorch) vs 100ms(tensorrt). 主要是由于大矩阵乘法耗时较高,所以对这部分做了优化。

这个PR的内容是将复数实现的RoPEAttention转换为实数运算,既避免了复数运算ONNX/TensorRT不支持的情况,又保留了复数运算的高效率。

推理速度测试:

Orin-NX-16GB latency
基于矩阵运算 900ms
基于实数运算 100ms
3080-laptop latency
基于矩阵运算 100ms
基于实数运算 24ms

在sam2原工程上验证,输出结果与原版一致。

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.