Skip to content

Optimize RoPEAttention implementation for onnx export #10

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

Merged
merged 1 commit into from
May 1, 2025

Conversation

zz990099
Copy link
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