-
Notifications
You must be signed in to change notification settings - Fork 242
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
【PaddlePaddle Hackathon 第四期】No.6:为 Paddle 新增 ldexp API #407
Conversation
@@ -0,0 +1,169 @@ | |||
# paddle.ldexp 设计文档 | |||
|
|||
|API名称 | paddle.Idexp | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
任务 Issue: [No.6:为 Paddle 新增 ldexp API](https://github.com/PaddlePaddle/Paddle/issues/50630#task6) | ||
|
||
## 2、功能目标 | ||
增加API `paddle.ldexp` 和 `paddle.Tensor.ldexp`,实现 `ldexp(double x, int exponent)`函数,函数返回 x 乘以 2 的 exponent 次幂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
实现
ldexp(double x, int exponent)
函数,
下面参数设计里写的是,请对齐
paddle.ldexp(
input: Tensor,
other: Tensor
)
1. 使用`paddle.exp`对输入exponent,进行以自然数 e 为底指数运算 | ||
2. 将步骤1得到的值乘以x即可 | ||
|
||
但在实际实现时,不能完全直接复用上述方案,理由如下: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将步骤1得到的值乘以x即可
这个对么,paddle.exp是e为底,paddle.ldexp是2为底
paddle.ldexp( | ||
input: Tensor, | ||
other: Tensor | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要写一下input和other的数据类型
|
||
## 七、可行性分析及规划排期 | ||
具体规划: | ||
- 阶段一:完成API功能开放 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
开放-》开发
@luotao1 修改好了~,辛苦review下 |
|
||
# 五、设计思路与实现方案 | ||
|
||
## 命名与参数设计 | ||
添加 API | ||
```python | ||
paddle.ldexp( | ||
input: Tensor, | ||
other: Tensor | ||
input: 多纬Tensor,数据类型为 float16 、 float32 、 float64 、 int32 或 int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多纬-》多维
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改好了~
任务 Issue: [No.6:为 Paddle 新增 ldexp API](https://github.com/PaddlePaddle/Paddle/issues/50630#task6) | ||
|
||
## 2、功能目标 | ||
增加API `paddle.ldexp` 和 `paddle.Tensor.ldexp`,实现 `ldexp(input, other)`函数,函数返回 x 乘以 2 的 other 次幂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 的 other 次幂,下面数据类型变了,这里可以强调下是整数幂
添加 API | ||
```python | ||
paddle.ldexp( | ||
input: 多纬Tensor,数据类型为 float32 、 float64 、 int32 或 int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多纬Tensor-》多维,为什么这里去掉float16呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为我测试代码的时候,发现我目前实现方式是不支持float16
好的
input * 2^{other} | ||
$$ | ||
|
||
通过调研发现,Paddle 本身已实现 paddle.pow 可以计算2的整数次幂函数,可利用paddle.pow API 与 input 相乘实现 paddl.lexp。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paddl.lexp-》paddle.ldexp
@@ -123,8 +123,8 @@ math_ldexp_impl(PyObject *module, double x, PyObject *i) | |||
添加 API | |||
```python | |||
paddle.ldexp( | |||
input: 多纬Tensor,数据类型为 float32 、 float64 、 int32 或 int64 | |||
other: 多维Tensor,数据类型为 int32 或 int64 | |||
input: 多纬Tensor,数据类型为 float32、float64、int32 或 int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input: 多纬Tensor。多维
@@ -137,7 +137,7 @@ $$ | |||
input * 2^{other} | |||
$$ | |||
|
|||
通过调研发现,Paddle 本身已实现 paddle.pow 可以计算2的整数次幂函数,可利用paddle.pow API 与 input 相乘实现 paddl.lexp。 | |||
通过调研发现,Paddle 本身已实现 paddle.pow 可以计算2的整数次幂函数,可利用paddle.pow API 与 input 相乘实现 paddl.ldexp。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paddl.ldexp -》paddle.ldexp
修改好了~ |
【PaddlePaddle Hackathon 第四期】No.6:为 Paddle 新增 ldexp API