Unverified Commit ef2b927b authored by tripleMu's avatar tripleMu Committed by GitHub
Browse files

Add typehint in mmcv/utils* (#1998)



* Add typehint in mmcv/utils*

* Update mmcv/utils/registry.py
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* Update mmcv/utils/registry.py
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>
parent af861bf9
# Copyright (c) OpenMMLab. All rights reserved. # Copyright (c) OpenMMLab. All rights reserved.
def is_ipu_available(): def is_ipu_available() -> bool:
try: try:
import poptorch import poptorch
return poptorch.ipuHardwareIsAvailable() return poptorch.ipuHardwareIsAvailable()
...@@ -12,7 +12,7 @@ def is_ipu_available(): ...@@ -12,7 +12,7 @@ def is_ipu_available():
IS_IPU_AVAILABLE = is_ipu_available() IS_IPU_AVAILABLE = is_ipu_available()
def is_mlu_available(): def is_mlu_available() -> bool:
try: try:
import torch import torch
return (hasattr(torch, 'is_mlu_available') return (hasattr(torch, 'is_mlu_available')
......
...@@ -67,6 +67,6 @@ else: ...@@ -67,6 +67,6 @@ else:
return ExtModule(*ext_list) return ExtModule(*ext_list)
def check_ops_exist(): def check_ops_exist() -> bool:
ext_loader = pkgutil.find_loader('mmcv._ext') ext_loader = pkgutil.find_loader('mmcv._ext')
return ext_loader is not None return ext_loader is not None
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
import inspect import inspect
import warnings import warnings
from functools import partial from functools import partial
from typing import Any, Dict, Optional
from .misc import deprecated_api_warning, is_seq_of from .misc import deprecated_api_warning, is_seq_of
def build_from_cfg(cfg, registry, default_args=None): def build_from_cfg(cfg: Dict,
registry: 'Registry',
default_args: Optional[Dict] = None) -> Any:
"""Build a module from config dict when it is a class configuration, or """Build a module from config dict when it is a class configuration, or
call a function from config dict when it is a function configuration. call a function from config dict when it is a function configuration.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment