当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch Graph.inserting_after用法及代码示例


本文简要介绍python语言中 torch.fx.Graph.inserting_after 的用法。

用法:

inserting_after(n=None)

设置create_node 和伴随方法将插入图表的点。

在‘with’ 语句中使用时,这将临时设置插入点,然后在 with 语句退出时恢复它:

with g.inserting_after(n):
    ... # inserting after node n
... # insert point restored to what it was previously
g.inserting_after(n) #  set the insert point permanently
参数:
n(可选[节点]):要在其之前插入的节点。如果没有,这将插入之后

整个图形的开始。

返回:

将恢复 __exit__ 上的插入点的资源管理器。

注意

保证此 API 的向后兼容性。

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.fx.Graph.inserting_after。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。