-
Notifications
You must be signed in to change notification settings - Fork 270
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 No.17】为 Paddle 新增 sgn #164
Conversation
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.
整体RFC需要补充较多内容:
- sgn是sign的复数功能,需要介绍下paddle.sign的情况。
- 提到sgn可以用组合API实现,那具体是用哪些API实现?为什么组合起来能实现复数功能?
- 业内方案调研里,numpy和tf的情况如何?
- 测试case请按照API验收标准来完成
pytorch实现逻辑简单,故直接参考其代码
,pytorch是用C++写的,RFC提到用python来组,那是如何直接参考代码呢?
好的 |
@luotao1 已更新 |
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.
@@ -74,10 +78,31 @@ inline c10::complex<T> sgn_impl (c10::complex<T> z) { | |||
} | |||
|
|||
``` | |||
|
|||
github链接为:https://github.com/pytorch/pytorch/blob/d7fc864f0da461512fb7b972f04e24e296bd266d/aten/src/ATen/native/cpu/zmath.h | |||
156-163 |
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.
dtype=x.dtype), | ||
name=name) | ||
return gen_math_ops.sign(x, name=name) | ||
``` |
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.
86-97行的代码格式有点乱,请调整下
如果复数为0,则直接返回0;否则,返回该复数除以它的绝对值的值 | ||
对于非复数直接返回其符号 | ||
使用is_complex判断输入是否为复数、若为实数则使用sign进行运算;若为复数则使用as_real将其转化为实数tensor,将其中的非零部分除以它自己的绝对值 | ||
,最后在使用as_complex将其转换回复数返回。 |
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.
最后在使用-》最后再使用
|
||
# 六、测试和验收的考量 | ||
|
||
测试考虑的case如下: | ||
|
||
- 数值正确性 | ||
- 反向 | ||
- 异常测试:由于使用了已有API:sign 该API不支持整型运算,仅支持float16, float32 或 float64,所以需要做数据类型的异常测试 | ||
- 异常测试:由于使用了已有API:sign,该API不支持整型运算,仅支持float16, float32 或 float64,所以需要做数据类型的异常测试 |
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.
根据您给的建议进行了修改,但是由于目前并未进行具体的代码开发,所以不知道调用的API是否覆盖静态图和GPU测试场景。这部分是开发阶段的工作,可以在后续开发时根据代码修改RFC具体内容。
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.
由于目前并未进行具体的代码开发,所以不知道调用的API是否覆盖静态图和GPU测试场景
虽然没有进行开发,但设计文档中应该是要能预判的:
- 业内方案里,并没有特殊说明覆盖不了静态图和GPU场景。
- 这是用组合API形式实现的,单API都能覆盖静态图和GPU测试场景,因此组合的应该也可以。
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.
LGTM
add rfc of paddle.sgn