mindspore/docs/api/api_python/utils/mindspore.utils.dryrun.rst

17 lines
984 B
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.

.. py:function:: mindspore.utils.dryrun.set_simulation()
用于设置dryrun功能开启。dryrun功能主要用于模拟大模型的实际运行开启后可以在不占卡的情况下模拟出显存占用编译信息等。
在PyNative场景下开启后若存在从device取值到host的场景会打印出Python调用栈日志告知用户这些值是不准确的。
.. py:function:: mindspore.utils.dryrun.mock(mock_val, *args)
在网络中若一些if判断需要用到实际执行值虚拟执行无法获取可以使用该接口返回模拟值。实际执行时可以获取到正确结果返回执行值。
参数:
- **mock_val** (Union[Value, Tensor]) - 虚拟执行场景下,想要输出的值。
- **args** (Union[Value, function]) - 期望被mock掉的值可以是函数或者变量。
返回:
开启dryrun功能返回静态模拟值mock_val否则返回实际执行结果args