-
Notifications
You must be signed in to change notification settings - Fork 273
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.6】 为 Paddle 增强put_along_axis API #634
Conversation
- `value (float)- 需要插入的值,形状和维度需要能够被 broadcast 与 indices 矩阵匹配,数据类型为:float32、float64。` | ||
- `axis (int) - 指定沿着哪个维度获取对应的值,数据类型为:int。` | ||
- `reduce (str,可选) - 归约操作类型,默认为 assign,可选为 add 或 multiple。不同的规约操作插入值 value 对于输入矩阵 arr 会有不同的行为,如为 assgin 则覆盖输入矩阵,add 则累加至输入矩阵,multiple 则累乘至输入矩阵。` | ||
|
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.
此处需要说明下和当前API的差异点,突出下这个RFC的工作在API上的修改或新增的点
## PyTorch | ||
|
||
目前 PyTorch 的归约方式支持 sum、prod、mean、amax 和 amin 五种,其中 sum 和 prod 对应 paddle 的 add 和 multiple 归约方式,因此需要为 paddle 补充 mean、amin、amax 三种归约方式。 | ||
|
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.
除底层实现以外,再补充下对pytorch API的分析吧
|
||
测试考虑的 case 如下: | ||
- 增加 reduce 分别为 'amin'、'amax' 和 'mean' 时的单测 | ||
|
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.
请教一下反向逻辑的设计是什么意思,我看源码里这个op的梯度实现与reduce方式无关,应该不需要额外实现反向梯度公式,请问是指在单测里验证新加的reduce方式下反向梯度是否正确的意思吗?
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.
源码里这个op的梯度实现与reduce方式无关
初步看起来,除assign外的其他反向是有问题的,reduce方式肯定会影响梯度的计算,这部分可能需要花时间测试和调研下。
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.
麻烦再请教一下,算子的不同 reduce 方式的反向梯度计算我大概了解了,但是目前有一个问题,单测的梯度检查这块 paddle 似乎是和对应的 numpy 算子来计算的,但是 numpy 的 put_along_axis
API 并没有 reduce 选项或者说只有和 paddle 对应的 assign
reduce 方式,这种情况下该怎么做其他 reduce 方式单测的梯度检查呢?
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.
这个通常需要自己通过Numpy组合实现一下,可以参考一些其他复杂API单测
已经有 RFC 合入了,如果需要更新和完善,可以在原来的 RFC 上进行修改,感谢! |
为 Paddle 增强 put_along_axis API RFC 文档