mindspore/docs/api/api_python/ops/mindspore.ops.TensorDump.rst

41 lines
2.1 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.TensorDump
========================
.. py:class:: mindspore.ops.TensorDump(input_output='out')
将Tensor保存为numpy格式的.npy文件。
.. warning::
参数 `input_output` 将不再支持参数值为'all'。
.. note::
在Ascend平台上的Graph模式下可以通过设置环境变量 `MS_DUMP_SLICE_SIZE``MS_DUMP_WAIT_TIME` 解决在输出大Tensor或输出Tensor比较密集的场景下算子执行失败的问题。
参数:
- **input_output** (str可选) - 控制Tensordump行为模式的参数可选的值为 ['out', 'in'] 中的一个,默认值: ``out``
对于算子A --> 重排算子 --> 算子B这样的情况由于重排算子的插入导致算子A的输出不再等价于算子B的输入。
假设一种情况是算子A的计算结果既作为算子B的输入也作为Tensordump算子的输入。则在该情况下
通过设置参数 `input_output` 可以实现不同的保存数据的需求:
- 如果参数 `input_output` 设置为'out'保存的数据仅包含算子A的输出分片。
- 如果参数 `input_output` 设置为'in'保存的数据将仅包含算子B的输入分片。
当参数 `input_output` 被配置为'in'时生成的输入分片所对应的npy文件命名格式为fileName_dumpMode_dtype_id.npy。
当参数 `input_output` 被配置为'out'时生成的输出分片所对应的npy文件命名格式为fileName_dtype_id.npy。
- fileName参数 `file` 的值若该参数传入时是一个用户指定的路径则fileName的值为路径的最后一级
- dumpMode参数 `input_output` 的值。
- dtype原始的数据类型。bfloat16类型数据保存在.npy文件中会被转换成float32类型。
- id一个自增的ID。
输入:
- **file** (str) - 要保存的文件路径。
- **input_x** (Tensor) - 任意维度的Tensor。
异常:
- **TypeError** - 如果 `file` 不是str。
- **TypeError** - 如果 `input_x` 不是Tensor。