dragon.config

Quick Reference

List Brief
EnableCPU Enable CPU mode globally.
EnableCUDA Enable CUDA mode globally.
SetRandomSeed Set the global random seed.
GetRandomSeed Get the global random seed.
SetGPU Set the global id GPU.
GetGPU Get the global id of GPU.
SetGraphOptimizationLevel Set the default level of graph optimization.
LogMetaGraph Enable to log meta graph globally.
LogOptimizedGraph Enable to log optimized graph globally.
ExportMetaGraph Enable to export all runnable meta graphs into text files.
SetLoggingLevel Set the minimum level of Logging.
SetLoggingFile Redirect the logging into the specific file.

API Reference

Define the global options and useful device helpers.

dragon.config.GetGlobalOptions()

Return all the global options.

Returns:The global option dict.
Return type:dict
dragon.config.EnableCPU()

Enable CPU mode globally.

Returns:
Return type:None
dragon.config.EnableCUDA(gpu_id=0)

Enable NVIDIA’s CUDA mode globally.

Parameters:gpu_id (int) – The index of GPU to use.
Returns:
Return type:None
dragon.config.EnableCNML(mlu_id=0)

Enable Cambricon’s CNML mode globally.

Parameters:mlu_id (int) – The index of MLU to use.
Returns:
Return type:None
dragon.config.SetRandomSeed(seed)

Set the global random seed.

Parameters:seed (int) – The seed to use.
Returns:
Return type:None
dragon.config.GetRandomSeed()

Get the global random seed.

Returns:The global random seed.
Return type:int
dragon.config.SetGPU(id)

Set the global index GPU.

Parameters:id (int) – The index of GPU to use.
Returns:
Return type:None
dragon.config.GetGPU()

Get the global index of GPU.

Returns:The global index of GPU.
Return type:int
dragon.config.SetGraphType(graph_type='')

Set the graph type.

If empty, the default DAG graph will be used.

Parameters:graph_type (str) – The graph type.
Returns:
Return type:None
dragon.config.SetGraphOptimizationLevel(level=3)

Set the default level of graph optimization.

We have predefined four levels:

-O0: Do nothing.

-O1: Prune the redundant nodes.

-O2: Add the inplace to outputs. Note that the graph will no longer be a DAG.

-O3: Allocate the buffer for outputs. This level is memory-efficient while debugging will be non-trivial.

Parameters:level ({0, 1, 2, 3}, optional, default=3) – The level, see the documentation for details.
Returns:
Return type:None
dragon.config.LogMetaGraph(enabled=True)

Enable to log meta graph globally.

The meta graph is a describer generated by the VM frontend.

Parameters:enabled (boolean) – Whether to enable logging.
Returns:
Return type:None
dragon.config.LogOptimizedGraph(enabled=True)

Enable to log optimized graph globally.

The optimized graph is a describer optimized by the VM backend.

Parameters:enabled (boolean) – Whether to enable logging.
Returns:
Return type:None
dragon.config.ExportMetaGraph(prefix='')

Enable to export all runnable meta graphs into text files.

These text files will be saved as the following format:

prefix/Graph.metatxt

Note that an empty prefix will leads to invalid exporting.

Parameters:prefix (str) – The prefix of the exporting.
Returns:
Return type:None
dragon.config.SetLoggingLevel(level)

Set the minimum level of Logging.

Parameters:level ({'DEBUG', 'INFO, 'WARNING', 'ERROR', 'FATAL'}, required) – The logging level.

Notes

The default level is INFO.