[PTen] Update all forward argument maping fns #39252
Merged
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 types
Function optimization
PR changes
Others
Describe
[PTen] Update all forward argument maping fns
为满足infrt需求,将用于Op和Kernel参数匹配的函数,lower到pten中作为兼容组件,且不依赖fluid,本PR迁移了前向kernel相关的匹配函数
由于infrt不仅需要在运行时动态调用此参数映射函数,还需要在没有任何信息的情况下,提前将该函数所有的可能结果在运行之前提前静态化声明如下定义:
因此,我们需要将参数映射函数的每个结果都具体写出来,infrt通过正则抽取
return KernelSignature("full", {}, {"ShapeTensor", "value"}, {"Out"});
,在运行之前拿到所有的结果用于上述静态定义的生成,这导致一些函数会写得比较冗长,复杂的可能会有几百行,对于编程体验有一定副作用,示例如下fill_constant_op映射函数原写法:
为适配infrt更改后,fill_constant_op映射函数写法: