Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output defs for unique kernels #52507

Closed
wants to merge 9 commits into from

Conversation

sanbuphy
Copy link
Contributor

@sanbuphy sanbuphy commented Apr 4, 2023

PR types

Others

PR changes

Others

Describe

#51292

对于这种多嵌套有条件分支的该如何判断呢

@paddle-bot
Copy link

paddle-bot bot commented Apr 4, 2023

你的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.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Apr 4, 2023
@luotao1 luotao1 requested a review from From00 April 11, 2023 03:05
@sanbuphy
Copy link
Contributor Author

@From00 麻烦研发大哥看一下

@From00
Copy link
Contributor

From00 commented Apr 11, 2023

这两个算子的输出参数推导比较复杂,还需要对InferMeta也做修改,PR #52773 已经改过来了,可以参考下。

@sanbuphy
Copy link
Contributor Author

这两个算子的输出参数推导比较复杂,还需要对InferMeta也做修改,PR #52773 已经改过来了,可以参考下。

收到,麻烦老哥分享以下思路~ @AndSonder

@paddle-bot
Copy link

paddle-bot bot commented Apr 11, 2023

很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。
Sorry to inform you that through our discussion, your PR fails to meet the merging standard (Reference: Paddle Custom Operator Design Doc). You can also submit an new one. Thank you.

@AndSonder
Copy link
Contributor

这两个算子的输出参数推导比较复杂,还需要对InferMeta也做修改,PR #52773 已经改过来了,可以参考下。

收到,麻烦老哥分享以下思路~ @AndSonder

复杂的主要是对 UniqueRawKernel 下 UniqueOpFunctor/UniqueFlattendTensorFunctor 等结构体 apply 函数的 Alloc 类型分析。输出类型的参数是根据 结构体 中 apply 函数的模板函数去确认的。apply 函数的调用在 phi::VisitDataType 中,里面通过调用 PhiVisitDataTypeCallback 传入,经过分析可以知道,cpp_type 只有两种情况 int 和 int64_t:

#define _PhiForEachDataTypeTiny_(callback)                    \
  _PhiForEachDataTypeHelper_(callback, int, DataType::INT32); \
  _PhiForEachDataTypeHelper_(callback, int64_t, DataType::INT64);

这个其实是和Unique的输入参数 dtype 是一样的,所以把传入的 dtype 作为注册类型即可;

同时由于直接在InferMate中写注册信息会出现 Dim 判断报错,所以需要在 static_build.cc 中添加if条件,不在InferMate里面进行类型推导

@sanbuphy
Copy link
Contributor Author

这两个算子的输出参数推导比较复杂,还需要对InferMeta也做修改,PR #52773 已经改过来了,可以参考下。

收到,麻烦老哥分享以下思路~ @AndSonder

复杂的主要是对 UniqueRawKernel 下 UniqueOpFunctor/UniqueFlattendTensorFunctor 等结构体 apply 函数的 Alloc 类型分析。输出类型的参数是根据 结构体 中 apply 函数的模板函数去确认的。apply 函数的调用在 phi::VisitDataType 中,里面通过调用 PhiVisitDataTypeCallback 传入,经过分析可以知道,cpp_type 只有两种情况 int 和 int64_t:

#define _PhiForEachDataTypeTiny_(callback)                    \
  _PhiForEachDataTypeHelper_(callback, int, DataType::INT32); \
  _PhiForEachDataTypeHelper_(callback, int64_t, DataType::INT64);

这个其实是和Unique的输入参数 dtype 是一样的,所以把传入的 dtype 作为注册类型即可;

同时由于直接在InferMate中写注册信息会出现 Dim 判断报错,所以需要在 static_build.cc 中添加if条件,不在InferMate里面进行类型推导

非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants