You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
如果可以获取动转静组网时,python 变量和 pir value 的映射关系,就有足够的信息来判断?同时 x[::] 也有足够的信息去判断,而不用跳过?
show
all_vars_list=program.list_vars()
forvalueinall_vars_list:
iflen(value.all_used_ops()) ==0:
returnuesd_by_stride_ops= []
foropinvalue.all_used_ops()[::-1]:
inplace_info=paddle.pir.core.get_op_inplace_info(op)
ifop.name() inframework.stride_opsandop.operand_source(
0
).is_same(value):
uesd_by_stride_ops.append(op)
if (
op.name().endswith("_")
andany(op.operand_source(index).is_same(value) forindexininplace_info.keys())
):
ifvalue.get_defining_op().name() inframework.stride_ops:
# x = transpose(x) 的情况,如果 value 是 stride op 的输出(作为 python 变量),判断是否被 stride op 的输入(上一个同名 python 变量)使用pass# need valueerroriflen(uesd_by_stride_ops) ==0:
continue# 获取使用过该 value 的strideopforstride_opinuesd_by_stride_ops:
# y = transpose(x).clone() 等# 获取 stride_op 的输出,判断输出是否为python变量(xlist中的值)ifstride_op.name() =="pd_op.split"orstride_op.name() =="pd_op.unbind":
ifstride_op.results() inxlistorany(
resultinxlistforresultinstride_op.results()
):
pass# need valueerrorifstride_op.result(0) inxlist:
pass# need valueerrorop_callstack=op.callstackindex=op_callstack.index(" outputs = static_func(*inputs)")
op_callstack_result='\n'.join(op_callstack[index+1 :])
raiseValueError(
f'In transformed code:\n\n{op_callstack_result}\n\nSorry about what\'s happened. In to_static mode, {op.name()}\'s output variable is a viewed Tensor in dygraph. This will result in inconsistent calculation behavior between dynamic and static graphs. You must find the location of the strided ops be called, and call paddle.assign() before inplace input.'
)
你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Execute Infrastructure
PR Types
Others
Description
PIR 下暂不支持 stride ,拦截一个viewed Tensor被 Inplace API使用的情况 ,添加同旧 IR 下的报错提示
报错背景
在动态图下,transpose 的输入输出是共享显存的,对 a 做 inplace 操作,也会修改 b 的现存。在静态图下,transpose 不支持 stride view , 不共享显存,inplace 操作过后,并不会对 b 产生影响。两种模式下行为不一致,所以需要报错。
需要对动转静的 inplace api 的 inplace 输入判断 view Tensor
inplace_apis_in_dygraph_only 装饰器

使用此装饰器修饰的 api ,需要检查
还有一些不被装饰器所装饰的 inplace api(动静统一),如:fill_diagonal_tensor_
需要在动转静结束时,对整个 program 检查
修改单测
TODO
以这个为例
如果可以获取动转静组网时,python 变量和 pir value 的映射关系,就有足够的信息来判断?同时 x[::] 也有足够的信息去判断,而不用跳过?show