https://www.mindspore.cn/docs/zh-CN/r2.2/note/static_graph_syntax_support.html
对静态图内的Cell对象以及jit_class对象进行设置与修改。
支持对图模式Cell对象进行属性修改,例如:
import mindspore as ms
from mindspore import nn, set_context
set_context(mode=ms.GRAPH_MODE)
class InnerNet(nn.Cell):
def init(self):
super(InnerNet, self).init()
self.x = 10
class Net(nn.Cell):
def init(self):
super(Net, self).init()
self.inner = InnerNet()
def construct(self):
self.inner.x = 100
return
net = Net()
net()
print(f"net.inner.x is {net.inner.x}")
运行结果为:
net.inner.x is 100
正确性:
代码样例运行报错、运行结果不符;
代码无法运行,弹出错误提示:
RuntimeError: BUG: no manager for this func graph: __main___InnerNet_construct_2 NodeInfo: In file C:********\mindspore\nn\cell.py:1155
def construct(self, *args, **kwargs):
^
Framework Unexpected Exception Raised:
This exception is caused by framework's unexpected error. Please cr
Please assign maintainer to check this issue.
请为此issue分配处理人。
@fangwenyi @chengxiaoli @Shawny
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:
得分:5
类型:正确性
活动链接(可查询积分):https://www.mindspore.cn/feedback
欢迎您提交更多issue或PR,获得更多积分。
登录 后才可以发表评论