静态图模式下报错TypeError: pynative模式不支持重新计算

系统环境

硬件环境(Ascend/GPU/CPU): GPU
MindSpore版本: mindspore=2.5.0
执行模式(PyNative/ Graph): PyNative
Python版本: Python=3.10
操作系统平台: Ubuntu22.04

报错信息

问题描述

在MindSpore静态图模式下使用nn.Cell.recompute方法报错

脚本信息

import mindspore
from mindspore import context
context.set_context(mode=context.GRAPH_MODE)

报错信息

/site-packages/mindspore/nn/cell.py in recompute(self, mode, output_recompute)
1306 “”"
1307 if context.get_context(“mode”) == context.PYNATIVE_MODE:
-> 1308 raise TypeError(“Recompute is not supported in pynative mode currently.”)
1309 Validator.check_bool(mode)
1310 Validator.check_bool(output_recompute)
TypeError: Recompute is not supported in pynative mode currently.

根因分析

此处由用户填写

解决方案

此处由用户填写
包含文字方案和最终脚本代码
请将正确的脚本打包并上传附件