The _load_model_fromconfig function in our codebase is responsible for loading a model from the given configuration and checkpoint. However, the current implementation can be optimized further for better readability and performance. In this pull request, we introduce some improvements to the function.
Changes Made:
Validate the device input at the beginning of the function.
Remove redundant torch.device calls.
Use a context manager to handle model device placement.
Simplify the conditional statements for better readability.
Background:
The _load_model_fromconfig function in our codebase is responsible for loading a model from the given configuration and checkpoint. However, the current implementation can be optimized further for better readability and performance. In this pull request, we introduce some improvements to the function.
Changes Made: