Skip to content

Conversation

@NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Mar 25, 2024

PR types

Others

PR changes

APIs

Description

  1. paddle.nn.functional.max_unpool1d / max_unpool2d / max_unpool3d 增加支持 int64 输入

  2. paddle.nn.functional.max_unpool1d / max_unpool2d / max_unpool3d 的 output_size 参数的判断有 bug,输入正确的 output_size 会报错:
    这个目前按 x -> out, indices = pool(x, ...) -> unpool(out, indices, ..., output_size=x.shape) 这样来检验的话有问题的是paddle.nn.functional.max_unpool1d,output_size 参数处理之前少加了一维,是否还存在其他问题?

  3. paddle.nn.functional.kl_div 增加参数 log_target

@paddle-bot
Copy link

paddle-bot bot commented Mar 25, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

将两个PR拆开吧,一个是修改max_unpool1d/2d/3d,一个是修改kl_div

HOSTDEVICE KLDivLossBackward() {}
bool LogTarget = false;

HOSTDEVICE KLDivLossBackward(bool _log_target) : LogTarget(_log_target) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

形参应该是不带下划线的,结构体 内部变量你可以带个 下划线

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的


auto loss_grad_expand = loss_grad_t.broadcast(Array1(expand));
auto grad_t = target_t * loss_grad_expand;
auto grad_t = loss_grad_expand;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个修改不影响计算结果吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不会影响计算结果,target_t 我放到 KLDivLossBackward 这个结构体去乘了

之前是

 return static_cast<T>(-1.) * grad;

改为

 return static_cast<T>(-1.) * target * grad;

验证了一下是不影响的

HOSTDEVICE T operator()(const T& target, const T& input) const {
if (target <= 0) {
return 0;
if (LogTarget) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

):
label = paddle.cast(label, 'float64')

if paddle.is_compiled_with_xpu():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是需要修改xpu 的kernel,你学一学,也不难,主要是调一些xpu::的数学库函数可以实现exp等操作

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,这个 xpu::kldiv_loss 他的定义是在哪里
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,这个 xpu::kldiv_loss 他的定义是在哪里 image

xpu:: 这种开头的就是xpu自己提供的sdk了,可以理解为其他厂商提供的对外硬件接口,类似于CUDA库的cuda::函数,你需要查一查这些接口是否提供相应的功能,不提供的话就需要额外组装来计算

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Apr 3, 2024

Sorry to inform you that 309e151's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants