mindspore.JitConfig
- class mindspore.JitConfig(jit_level='O1', exc_mode='auto', jit_syntax_level='', **kwargs)[source]
Jit config for compile.
Warning
This is an experimental API that is subject to change or deletion.
- Parameters
jit_level (str, optional) –
Used to control the compilation optimization level. Supports [“O0”, “O1”, “O2”]. Default:
"O1"
."O0"
: Except for optimizations that may affect functionality, all other optimizations are turned off."O1"
: Using commonly used optimizations, recommended to set the O1 level."O2"
: Activate some experimental level optimizations.
exc_mode (str, optional) –
Control the execution mode of the model. Supports [“auto”, “sink”, “no_sink”]. Default:
"auto"
."auto"
: The framework automatically selects the execution method."sink"
: Support the network to load and load the entire device at once, and then execute it by input driver, without the need to iterate through each operator to achieve better execution performance. This mode is only supported on the Ascend backend."no_sink"
: The network model is executed asynchronously one by one using a single operator.
jit_syntax_level (str, optional) –
JIT syntax level for graph compiling. The value must be
"STRICT"
,"LAX"
or""
. Default to an empty string, which means that this JitConfig configuration will be ignored and the jit_syntax_level of ms.context will be used. For more details about ms.context, refer to set_context . Default:""
."STRICT"
: Only basic syntax is supported, and execution performance is optimal. Can be used for MindIR load and export."LAX"
: Compatible with all Python syntax as much as possible. However, execution performance may be affected and not optimal. Cannot be used for MindIR load and export due to some syntax that may not be able to be exported.
**kwargs (dict) – A dictionary of keyword arguments that the class needs.
Examples
>>> from mindspore import JitConfig >>> >>> jitconfig = JitConfig(jit_level="O1") >>> >>> # Define the network structure of LeNet5. Refer to >>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py >>> net = LeNet5() >>> >>> net.set_jit_config(jitconfig)