oneflow.nn.Graph.debug¶
-
Graph.
debug
(v_level: int = - 1, *, ranks: Optional[Union[int, List[int]]] = None, max_py_stack_depth: int = 2, only_user_py_stack=True, op_repr_with_py_stack=False) → None¶ Open or close debug mode of the graph.
If in debug mode, logs of computation graph building infos or warnings will be printed. Otherwise, only errors will be printed.
Each nn.Module inside a nn.Graph also has a debug() method to enable debug mode.
Use
v_level
to choose verbose debug info level, default level is 0, max level is 3.v_level
-1 will disable the debug mode of the graph (i.e. no info will be printed).v_level
0 will print warning and graph building stages.v_level
1 will additionally print graph build info of each nn.Module.v_level
2 will additionally print graph build info of each operation.v_level
3 will additionally print more detailed info of each operation.Use
ranks
to choose which rank to print the debug information.Use
max_py_stack_depth
to specify the max Python stack depth for the debug information.Use
only_user_py_stack
to only print the operators’ locations which are from users’ code or models.Use
op_repr_with_py_stack
to print operators’ locations when printing nn.Graph’s repr.For example:
g = CustomGraph() g.debug() # Open debug mode out_tensors = g(input_tensors) # Will print log for debug at the first call
- Parameters
v_level (int) – choose verbose debug info level, default v_level is 0, max v_level is 3. v_level can be set to -1 to close the debug mode.
ranks (int or list(int)) – choose ranks to print the debug information. Default rank
0
. You can choose any valid rank. Ranks equals-1
means debug on all ranks.max_py_stack_depth (int) – the maximum depth for the Python stack debug information. Default:
2
.only_user_py_stack (bool) – only to print the operators’ locations from users’ code. Default:
True
.op_repr_with_py_stack (bool) – print operators’ locations when printing nn.Graph’s repr. Default:
False
.