spiro.core.config
spiro.core.config module¶
helper function to set runtime backend.
This module contains the function to define the runtime context which include backend.
Examples:
>>> from spiro.core.config import set_backend
>>> set_backend('tensorflow')
>>> import dgl
set_backend(backend)
¶
Setup backend to the input one.
Returns:
Type | Description |
---|---|
|
the name of predefined backend |
Source code in core/config.py
def set_backend(backend):
"""Setup backend to the input one.
Returns:
the name of predefined backend
Raises:
if no valid backend setting is found in either environment variable or config file,
stop the current run and print error message.
"""
backend_name = backend
if backend_name not in supported_backends():
logger.warning(_BACKEND_NOT_FOUND)
backend_name = _PYTORCH
logger.debug("Using Backend: %s" % (backend_name))
os.environ[_DGL_BACKEND] = backend_name
global _BACKEND
_BACKEND = backend_name