mmdeploy/utils/test.py
def check_backend(backend: Backend, require_plugin: bool = False):
    """A utility to check if a backend is available.

    Args:
        backend (Backend): The backend needs to be checked.
        require_plugin (bool): The checker will check if the backend package
            has been installed. If this variable is `True`, then the checker
            will also check if the backend plugin has been compiled. Default
            to `False`.
    """
    is_plugin_available = None
    if backend == Backend.ONNXRUNTIME:
        from mmdeploy.apis.onnxruntime import is_available
        if require_plugin:
            from mmdeploy.apis.onnxruntime import is_plugin_available
    elif backend == Backend.TENSORRT:
        from mmdeploy.apis.tensorrt import is_available
        if require_plugin:
            from mmdeploy.apis.tensorrt import is_plugin_available
    elif backend == Backend.PPLNN:
        from mmdeploy.apis.pplnn import is_available
    elif backend == Backend.NCNN:
        from mmdeploy.apis.ncnn import is_available
        if require_plugin:
            from mmdeploy.apis.ncnn import is_plugin_available
    elif backend == Backend.OPENVINO:
        from mmdeploy.apis.openvino import is_available
    else:
        warnings.warn('The backend checker is not available')
        return

    if not is_available():
        pytest.skip(f'{backend.value} package is not available')
    if require_plugin and is_plugin_available is not None:
        if not is_plugin_available():
            pytest.skip(f'{backend.value} plugin is not available')
A utility to check if a backend is available.

    Args:
        backend (Backend): The backend needs to be checked.
        require_plugin (bool): The checker will check if the backend package
            has been installed. If this variable is `True`, then the checker
            will also check if the backend plugin has been compiled. Default
            to `False`.
    
A utility to check if a backend is available.
A utility to check if a backend is available .
def check_backend(backend: Backend, require_plugin: bool = False):
    is_plugin_available = None
    if backend == Backend.ONNXRUNTIME:
        from mmdeploy.apis.onnxruntime import is_available
        if require_plugin:
            from mmdeploy.apis.onnxruntime import is_plugin_available
    elif backend == Backend.TENSORRT:
        from mmdeploy.apis.tensorrt import is_available
        if require_plugin:
            from mmdeploy.apis.tensorrt import is_plugin_available
    elif backend == Backend.PPLNN:
        from mmdeploy.apis.pplnn import is_available
    elif backend == Backend.NCNN:
        from mmdeploy.apis.ncnn import is_available
        if require_plugin:
            from mmdeploy.apis.ncnn import is_plugin_available
    elif backend == Backend.OPENVINO:
        from mmdeploy.apis.openvino import is_available
    else:
        warnings.warn('The backend checker is not available')
        return
    if not is_available():
        pytest.skip(f'{backend.value} package is not available')
    if require_plugin and is_plugin_available is not None:
        if not is_plugin_available():
            pytest.skip(f'{backend.value} plugin is not available')
def check_backend ( backend : Backend , require_plugin : bool = False ) : is_plugin_available = None if backend == Backend . ONNXRUNTIME : from mmdeploy . apis . onnxruntime import is_available if require_plugin : from mmdeploy . apis . onnxruntime import is_plugin_available elif backend == Backend . TENSORRT : from mmdeploy . apis . tensorrt import is_available if require_plugin : from mmdeploy . apis . tensorrt import is_plugin_available elif backend == Backend . PPLNN : from mmdeploy . apis . pplnn import is_available elif backend == Backend . NCNN : from mmdeploy . apis . ncnn import is_available if require_plugin : from mmdeploy . apis . ncnn import is_plugin_available elif backend == Backend . OPENVINO : from mmdeploy . apis . openvino import is_available else : warnings . warn ( 'The backend checker is not available' ) return if not is_available ( ) : pytest . skip ( f'{backend.value} package is not available' ) if require_plugin and is_plugin_available is not None : if not is_plugin_available ( ) : pytest . skip ( f'{backend.value} plugin is not available' )
A utility to check if a backend is available.
A utility to check if a backend is available .
"""A utility to check if a backend is available.

    Args:
        backend (Backend): The backend needs to be checked.
        require_plugin (bool): The checker will check if the backend package
            has been installed. If this variable is `True`, then the checker
            will also check if the backend plugin has been compiled. Default
            to `False`.
    """
backend
Backend
The backend needs to be checked.
The backend needs to be checked .
require_plugin
bool
The checker will check if the backend package
has been installed. If this variable is `True`, then the checker
will also check if the backend plugin has been compiled. Default
to `False`.
The checker will check if the backend package has been installed . If this variable is ` True ` then the checker will also check if the backend plugin has been compiled . Default to ` False ` .