PaddlePaddle / PaddlePaddle/FastDeploy
RKYolo 预测推理耗时不断增加
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 756
- Avg merge
- 19h 28m
- Merged PRs (30d)
- 4
Description
温馨提示:根据社区不完全统计,按照模板提问,可以加快回复和解决问题的速度
环境
-
【FastDeploy版本】: 说明具体的版本,如fastdeploy-linux-rknn2-0.0.3
-
【编译命令】如果您是自行编译的FastDeploy,cmake .. -DENABLE_ORT_BACKEND=ON
-DENABLE_RKNPU2_BACKEND=ON -DENABLE_VISION=ON -DRKNN2_TARGET_SOC=RK3588 -DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.3 -
【系统平台】: Linux x64(Ubuntu 18.04)
-
【硬件】: RK3588
-
【编译语言】: C++
-
【性能问题】描述清楚对比的方式
/opt/pp/FastDeploy/fastdeploy/vision/detection/contrib/rknpu2/rkyolo.cc
同一个(fastdeploy::vision::detection::RKYOLOV5对象实例 RKYOLO 多次推理耗时不断增加从100多毫秒不断增加4秒多离了大普
调试打印发现:
void RKYOLOPreprocessor::LetterBox(FDMat* mat) {
...
scale_.push_back(scale);
pad_hw_values_.push_back({pad_h, pad_w});
}
两个向量scale_,pad_hw_values_ 没有清理的地方,向量大小会不断增长,隐藏引起对象拷贝耗时不断增加postprocessor_.SetPadHWValues(preprocessor_.GetPadHWValues());
postprocessor_.SetScale(preprocessor_.GetScale());
rkyolo.cc(109)::BatchPredict RKYOLO sn:11232,Infer:0.057892 s
rkyolo.cc(109)::BatchPredict RKYOLO sn:11232,Infer:0.075516 s
rkyolo.cc(109)::BatchPredict RKYOLO sn:11232,Infer:0.092575 s
rkyolo.cc(114)::BatchPredict RKYOLO sn:11232,GetPadHWValues time:0.067186 s,size:3760
rkyolo.cc(114)::BatchPredict RKYOLO sn:11232,GetPadHWValues time:0.065356 s,size:3727
rkyolo.cc(114)::BatchPredict RKYOLO sn:11232,GetPadHWValues time:0.067844 s,size:3750
rkyolo.cc(119)::BatchPredict RKYOLO sn:11232,SetPadHWValues: GetPadHWValues time:0.260485 s,size:3760
rkyolo.cc(125)::BatchPredict RKYOLO sn:11232,GetScale & SetScale time:0.000106 s,size:3760
rkyolo.cc(119)::BatchPredict RKYOLO sn:11232,SetPadHWValues: GetPadHWValues time:0.341411 s,size:3727
rkyolo.cc(136)::BatchPredict RKYOLO sn:11232,postprocessor_:0.028234 s
rkyolo.cc(139)::BatchPredict RKYOLO sn:11232,all:0.665357 s
rkyolo.cc(119)::BatchPredict RKYOLO sn:11232,SetPadHWValues: GetPadHWValues time:0.476271 s,size:3750
rkyolo.cc(125)::BatchPredict RKYOLO sn:11232,GetScale & SetScale time:0.000125 s, size:3727
两个操作耗时增加
deepseek 给出修改建议:
1 使用局部变量替代成员变量;
2. 清空向量
如果 pad_hw_values_ 和 scale_ 必须在类的成员变量中保留,可以在每次调用 Preprocess 或 LetterBox 之前清空它们,以避免它们不断增长。
3. 使用引用传递
在 SetPadHWValues 和 SetScale 中,可以使用引用传递来避免不必要的拷贝。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in fastdeploy/vision/detection/contrib/rknpu2/rkyolo.cc, especially RKYOLOPreprocessor::LetterBox and BatchPredict, and trace how scale_ and pad_hw_values_ flow through GetPadHWValues, SetPadHWValues, GetScale, and SetScale. Reproduce repeated inference on RK3588 and verify that the vectors do not grow across calls and that inference and transfer times remain stable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- computer-vision, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100