mindspore.get_context

mindspore.get_context(attr_key)[source]

Get context attribute value according to the input key. If some attributes are not set, they will be automatically obtained.

Parameters

attr_key (str) – The key of the attribute.

Returns

Object, The value of given attribute key.

Raises

ValueError – If input key is not an attribute in context.

Examples

>>> import mindspore as ms
>>> ms.get_context("device_target")
>>> ms.get_context("device_id")