The Wayback Machine - https://web.archive.org/web/20211128215611/https://github.com/OAID/Tengine/issues/640
Skip to content
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

yolov5 preprocessing SpaceToDepth #640

Open
stevenwudi opened this issue May 5, 2021 · 3 comments
Open

yolov5 preprocessing SpaceToDepth #640

stevenwudi opened this issue May 5, 2021 · 3 comments

Comments

@stevenwudi
Copy link
Contributor

@stevenwudi stevenwudi commented May 5, 2021

Currently, yolov5 examples put the Focus part of the model (SpaceToDepth) into the preprocessing part. (which actually takes quite a lot of CPU time, 20ms + for 640x640 input).

ONNX (since Opset 13, https://github.com/onnx/onnx/blob/master/docs/Operators.md#spacetodepth),
Tengine and TIMVX all have SpaceToDepth support.

Does Tengine have any plan to further incorporate the SpaceToDepth ops into the yolov5 model to further accelerate the detection model?

Looking forward to super-fast implementation of yolov5 models :)

@qinhj
Copy link
Contributor

@qinhj qinhj commented Jul 10, 2021

Hello~ Actually, in my understanding, the SpaceToDepth op can be totally achieved by reshape and transpose Ops
Below is a quick test:
image

@qinhj
Copy link
Contributor

@qinhj qinhj commented Jul 10, 2021

I've updated the yolov5s optimization python script here

To keep the slice op as it is, one can simply try:
$ python3 yolov5s-opt.v2.py --input yolov5s.v5.onnx --output yolov5s.v5.opt.onnx --out_tensor 397,458,519
To replace the slice op by reshape and transpose op, one can try:
$ python3 yolov5s-opt.v2.py --input yolov5s.v5.onnx --output yolov5s.v5.opt.onnx --in_tensor 167 --out_tensor 397,458,519

A quick glance at the converted tmfile models:
image
The output results are exactly same during my test ~

However, with my ubuntu PC, I didn't see too much difference of the performance between these tmfiles.
Maybe you can have a try with some other devices (I'm always lack of hardware resources ...) and share me your test results~

@qinhj
Copy link
Contributor

@qinhj qinhj commented Jul 10, 2021

@BUG1989 BUG1989 pinned this issue Jul 10, 2021
@BUG1989 BUG1989 unpinned this issue Aug 2, 2021
@BUG1989 BUG1989 pinned this issue Aug 2, 2021
@BUG1989 BUG1989 unpinned this issue Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment