mindformers.core.init_context

View Source On Gitee
mindformers.core.init_context(use_parallel=False, context_config=None, parallel_config=None)[source]

Initialize the context.

Parameters
  • use_parallel (bool) – Whether to use parallel, default: False.

  • context_config (Union[dict, ContextConfig]) – The context config, default: None.

  • parallel_config (Union[dict, ParallelContextConfig]) – The parallel context config, default: None.

Returns

  • Int, the local_rank number.

  • Int, the total available devices number.

Examples

>>> from mindformers import init_context
>>> init_context(use_parallel=False)