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

【Hackathon 5th No.11】为 Paddle 新增 igamma 和 igammac API RFC #625

Merged
merged 19 commits into from Sep 21, 2023

Conversation

zrr1999
Copy link
Member

@zrr1999 zrr1999 commented Sep 14, 2023

No description provided.

@paddle-bot
Copy link

paddle-bot bot commented Sep 14, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请检查PR提交格式和内容是否完备,具体请参考示例模版
Your PR has been submitted. Thanks for your contribution!
Please check its format and content. For this, you can refer to Template and Demo.

测试需要考虑的 case 如下:

- 输出数值结果的一致性和数据类型是否正确,使用 scipy 作为参考标准
- 对不同 dtype 的输入数据 `x` 进行计算精度检验 (float32, float64)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否有调研其他框架中支持的数据类型?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已添加相关内容, PyTorch中 CPU支持(float16, bfloat16, float32, float64),GPU支持(float32, float64)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那么在实现的时候时候是否可以也在CPU中支持float16, bfloat16?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果按照目前情况来看的话,float16, bfloat16的支持只需要在注册算子的时候添加相应的类型即可,并没有需要单独实现的部分

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但这点仍需在文档中写出支持类型。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在API实现方案和底层OP设计中添加相应类型支持说明

rfcs/APIs/20230914_api_design_for_igamma_and_igammac.md Outdated Show resolved Hide resolved

## API实现方案

该 API 实现于 `python/paddle/tensor/manipulation.py`。
Copy link

@zxcd zxcd Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python代码放在python/paddle/tensor/math.py,也给出c++代码实现位置

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要写Kernel吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kernel 部分可以参考 底层OP设计

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数应该是需要新增kernel,需要写出kernel实现的位置。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在底层OP设计添加相应的路径位置

@zrr1999 zrr1999 requested a review from zxcd September 18, 2023 04:04
$$ \gamma(a, x) = \int_0^x t^{a-1} e^{-t} dt $$

上不完全伽马函数 $\Gamma(a,x)$ 的定义域为 $a>0$,$x\geq 0$,值域为 $(0,\Gamma(a)]$。
下不完全伽马函数 $\gamma(a,x)$ 的定义域为 $a>0$,$x\geq 0$,值域为 $[0,\Gamma(a))$,其中 $\Gamma(a)$ 是伽马函数的值。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

值域是不是有问题

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上不完全伽马函数和下不完全伽马函数都是单调函数,因此值域只需要算边界值,当x=0时,上不完全伽马函数=Gamma(a),下不完全伽马函数=0,当x趋于正无穷时,上不完全伽马函数趋近于0正,下不完全伽马函数趋近于Gamma(a)负,所以相应的值域就是(0,\Gamma(a)]和[0,\Gamma(a))

@zrr1999 zrr1999 requested a review from zxcd September 19, 2023 06:02
@zxcd
Copy link

zxcd commented Sep 21, 2023

LGTM

rfcs/APIs/20230914_api_design_for_igamma_and_igammac.md Outdated Show resolved Hide resolved

### 实现基础计算逻辑
根据 igamma (上不完全伽马函数) 的定义,即
$$ \Gamma(a, x) = \int_x^{\infty} t^{a-1} e^{-t} dt $$
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 公式存在乱码

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,这里已经修复

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看预览里面还是乱码呢

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像又拉下了这个地方,现在已修复

@luotao1 luotao1 merged commit b366bad into PaddlePaddle:master Sep 21, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants