mindspore/docs/api/api_python/mindspore.set_dump.rst

23 lines
2.2 KiB
ReStructuredText
Raw Normal View History

mindspore.set_dump
==================
.. py:class:: mindspore.set_dump(target, enabled=True)
启用或者禁用target及其子节点的Dump数据功能。
target为Cell或Primitive的实例。请注意此API仅在开启异步Dump功能且Dump配置文件中的 `dump_mode` 字段为"2"时生效。有关详细信息,请参阅 `Dump功能文档 <https://mindspore.cn/docs/programming_guide/zh-CN/master/dump_in_graph_mode.html>`_ 。默认状态下Cell和Primitive实例不使能Dump数据功能。
.. Warning::
此API还在实验阶段后续可能修改或删除。
.. Note::
- 此API只在Ascend后端的图模式有效。
- 当target是一个Cell且enabled设置为True时Cell实例及其子Cell实例的Primitive将递归启用Dump。如果算子不是Cell实例的成员则不会为该算子启用Dump例如在construct方法中直接使用的 `functional 算子 <https://www.mindspore.cn/docs/api/zh-CN/master/api_python/mindspore.ops.html#functional>`_ 。要使此API生效请在Cell的__init__方法中使用self.some_op = SomeOp()的写法。
- 使用set_dump(Cell, True)后Cell正向计算中的算子会被Dump大多数反向计算梯度运算产生的计算不会被Dump。然而由于图的优化一些后向计算的数据仍然会被Dump。可以忽略文件名中包含“Gradients”的反向计算数据。
- 此API只支持训练开始前调用。如果在训练过程中调用这个API可能不会有效果。
- 对于 `nn.SoftMaxCrossEntropyWithLogits 层 <https://www.mindspore.cn/docs/api/zh-CN/master/api_python/nn/mindspore.nn.SoftmaxCrossEntropyWithLogits.html#mindspore.nn.SoftmaxCrossEntropyWithLogits>`_ 正向计算和反向计算使用同一组算子。因此只能看到反向计算中的Dump数据。请注意当使用sparse=True和reduce=“mean”初始化时nn.SoftmaxCrossEntropyWithLogits层也将在内部使用这些算子。
**参数:**
- **target** (Union[Cell, Primitive]) - 要设置Dump标志的Cell或Primitive的实例。
- **enabled** (bool) - True表示启用DumpFalse表示禁用Dump默认值: True。