mmengine
mmengine copied to clipboard
Allow Torch half models
Motivation
Running the model in float16 takes up less memory, less disk space and runs faster. So, I added an option to publish the model and run inference as float16.
Modification
Added new information within the model to indicate, whether it was saved as float16, to load as well. When loading the model, check if it is in CUDA and was saved as float16, if positive, load as float16, otherwise load normally.
Also fixed a bug when running pre-commit -> Argument 1 to "join" has incompatible type "Optional[str]"; expected "Union[str, _PathLike[str]]"
BC-breaking (Optional)
Use cases (Optional)
This PR was created and tested using pose estimators (MMPose) and a PR was created there too: https://github.com/open-mmlab/mmpose/pull/3130 PS: The code works even if one of the libraries (MMPose or MMEngine) is not updated with the new suggested changes.
Checklist
- Pre-commit or other linting tools are used to fix the potential lint issues. OK
- The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness. OK
- If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDetection or MMPretrain. OK
- The documentation has been modified accordingly, like docstring or example tutorials. OK