Repository navigation
【complex op No.7】add complex support for Log/log10/log2/log1p - #62448
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
| dev_ctx, &x, nullptr, &dout, dx, functor); \ | ||
| } | ||
|
|
||
| #define DEFINE_CPU_ACTIVATION_GRAD_KERNEL_WITH_INT_IN_FLOAT_OUT_DEPX( \ |
There was a problem hiding this comment.
这些kernel原来就不接收int的输入吧,你看原来的注册宏里面就没有注册int相关的类型
There was a problem hiding this comment.
这里的是反向kernel,因为如果需要算梯度的话,算出来的x梯度是float类型,还得再转回int,从float转成int 损失太大,这个梯度就没有意义了,所以这种的反向一般都不支持int的输入。
There was a problem hiding this comment.
好的,那我把backward相关部分删除了
| x.dtype() == phi::DataType::INT64) { \ | ||
| DenseTensor x_fp; \ | ||
| MetaTensor meta_xp(x_fp); \ | ||
| UnchangedInferMeta(dx, &meta_xp); \ |
There was a problem hiding this comment.
infermeta 按理来说不应该放在kernel 内部
| check_pir=True, check_pir_onednn=self.check_pir_onednn | ||
| ) | ||
|
|
||
| def test_api_complex(self): |
| PD_REGISTER_ACTIVATION_GRAD_KERNEL_WITH_COMPLEX(log2_grad, Log2GradKernel) | ||
| PD_REGISTER_ACTIVATION_GRAD_KERNEL_WITH_COMPLEX(log10_grad, Log10GradKernel) | ||
| PD_REGISTER_ACTIVATION_GRAD_KERNEL_WITH_COMPLEX(log1p_grad, Log1pGradKernel) | ||
| PD_REGISTER_KERNEL(log_double_grad, |
There was a problem hiding this comment.
这里注册了log的double_grad,但是单测有覆盖到这个二阶吗
There was a problem hiding this comment.
还没覆盖,高阶导的测试有示例吗🤔,我没太找到相应的实现参考
There was a problem hiding this comment.
目前高阶单测不支持复数,这个就先不加了,加了但是不能保证正确性意义不大
There was a problem hiding this comment.
这里应该也是有之前的问题,高阶如果不注册的话,低阶在测试的时候会出问题。
There was a problem hiding this comment.
这个还是加个单测吧,可以用np手写反向计算逻辑,然后与paddle 算出来的进行比较,不能添加一个不能保证正确性额kernel
| if device == 'cpu' or ( | ||
| device == 'gpu' and paddle.is_compiled_with_cuda() | ||
| ): | ||
| paddle.set_device(device) |
There was a problem hiding this comment.
用 paddle.set_device(device) 这个会不会引起全局并发的问题,从而影响其他的单测,可以在to_tensor的时候设置place来区分不同设备

PR types
New features
PR changes
OPs
Description
add complex support for Log/log10/log2/log1p
#61975