Repository navigation
[Accuracy diff No.15] Fix accuracy diff for cumprod API - #212
Conversation
|
Thanks for your contribution! |
|
@cangtianhuang @Cutelemon6 This pr is ready to be reviewed, Thanks! |
| if dim is None: | ||
| x = x.flatten() | ||
| axis = 0 |
There was a problem hiding this comment.
paddle 和 torch 的 api 在面对 dim == None / 缺省时的行为一致吗,如果一致可以删去。
There was a problem hiding this comment.
两者都不能为 None,paddle 在 api 层面设置了默认值,但其实默认值 None 会报错的,实现中实际需要的是整数,需要去改下,或者去适配 None 的时候 flatten(这个是 numpy 的行为),但是没看见别人反馈,应该是都没有使用默认值的情况,但是其他 cum 开头的函数确实会 flatten,感觉这个得去 Paddle 仓库提个 issue 问问。
在 paddle api 设计的层面,需要决定一下 dtype == None 时保持输出 dtype 和输入 dtype 一致(paddle 实现),还是说防止溢出计算时提升到更高精度进行计算(torch 实现)
我感觉提升比较好,但是有个流水线监控的很紧,很难通过,这个应该也要去 Paddle 问问😂
There was a problem hiding this comment.
我理解一下你的意思,并尝试回答一下:
- Q: "paddle 在 api 层面设置了默认值,但其实默认值 None 会报错的,实现中实际需要的是整数,需要去改下" => torch 不接受 axis == None (对应到 paddle 配置的输入就是 dim == None),所以需要进行转换。
A: 那这个就和删掉的 829 - 831 的意思是一致的。具体是 829,831 - Q: "或者去适配 None 的时候 flatten(这个是 numpy 的行为),但是没看见别人反馈,应该是都没有使用默认值的情况" => 对 dim == None,将 x 输入展平,应该是目前没有 dim == None / 缺省输入的配置。
A: 与 830 一致了,原有代码就是对齐 paddle 输入 dim == None时,torch 需要将 x 展平。 - Q: “但是其他 cum 开头的函数确实会 flatten,感觉这个得去 Paddle 仓库提个 issue 问问。”
A: 我们只需要关注这个 api 的情况就可以。
There was a problem hiding this comment.
噢好的,那就只考虑 dim != None 的情况就可以,配置出现使 paddle api 报错的概率很低。
| paddle.cumprod(x=Tensor([3, 4],"int32"), dim=0, ) | ||
| paddle.cumsum(Tensor([1, 32000],"float16"), axis=-1, ) | ||
| paddle.einsum("i, i", Tensor([2],"float64"), Tensor([1],"float64"), ) | ||
| paddle.einsum("ij,ij->j", Tensor([10, 2],"float64"), Tensor([1, 2],"float64"), ) |
There was a problem hiding this comment.
这里不用再mv到tester/api_config/5_accuracy/accuracy_9.txt了。tester/api_config/5_accuracy/accuracy_gpu_error.txt作为筛选出来的问题清单。用于快速回归测试使用。即便是Paddle没有问题,PaddleAPITest有问题,也不需要维护tester/api_config/5_accuracy/accuracy_gpu_error.txt了。


Torch 和 numpy 在 dtype 为 None,处理输入时,如果输入整数精度小于平台的默认整数时,会使用平台默认整数,cast 成 int64,所以直接设定 dtype 为 x.dtype
all config in

5_accuracy/accuracy_4.txt,5_accuracy/accuracy_6.txtand5_accuracy/accuracy_error_1.txthas passed.