mmengine icon indicating copy to clipboard operation
mmengine copied to clipboard

Allow Torch half models

Open ProgramadorArtificial opened this issue 1 year ago • 1 comments
trafficstars

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

  1. Pre-commit or other linting tools are used to fix the potential lint issues. OK
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness. OK
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDetection or MMPretrain. OK
  4. The documentation has been modified accordingly, like docstring or example tutorials. OK

ProgramadorArtificial avatar Sep 24 '24 21:09 ProgramadorArtificial

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 24 '24 21:09 CLAassistant