Deeplite / deeplite-torch-zoo

Collection of SOTA efficient computer vision models for embedded applications, with pre-trained weights and training recipes
Apache License 2.0
82 stars 10 forks source link

RAM profile fails to capture YOLO module names #393

Closed alexh-deeplite closed 3 months ago

alexh-deeplite commented 3 months ago

Module names under the scope column of the RAM profile table do not work for YOLO models due to the failed capture of the Sequential module. In the case where the Sequential module is iterated over with a for loop, the module was not captured, because its forward function was not called.

From torch 1.13, scope name tracing is natively supported with torch.onnx.utils._setup_trace_module_map, so I added that option to our trace handling for torch versions that support it. This change handles the Sequential module edge case and resolves the issue with the YOLO module name tracing. However, this fix only resolves the case where users are using torch>=1.13 (most users)