Skip to content

Conversation

@Asthestarsfalll
Copy link
Contributor

@Asthestarsfalll Asthestarsfalll commented Apr 15, 2024

PR Category

Others

PR Types

Others

Description

rfc:

中文文档:

lp pool,前向公式

$$ f(X) = (\sum_{x \in X} x^p)^{\frac{1}{p}} $$

反向公式

$$ grad = \sum_{x \in X} (x^{p - 1} f(X)^{1 - p}) $$

本实现直接借用了 PoolRawKernel,当 norm_type$\infty$ 时,等价与最大池化,因此直接调用了 MaxPool;这样似乎可以直接支持LPPool3D,如果有需求的话。单测结果:
240415_21h23m27s_screenshot

@paddle-bot
Copy link

paddle-bot bot commented Apr 15, 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.

@Asthestarsfalll
Copy link
Contributor Author

@cyber-pioneer 老师大部分CI已通过,请先审一下吧。

@luotao1 luotao1 added the API label Apr 24, 2024
@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Apr 25, 2024

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

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented May 3, 2024

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

norm_type=norm_type,
pool_type='lp',
)
np.testing.assert_allclose(result.numpy(), result_np, rtol=1e-05)
Copy link
Contributor

Choose a reason for hiding this comment

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

精度现在只能对齐到1e-5么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,其他pool2d的精度也是1e-5

@cyber-pioneer
Copy link
Contributor

缺少float16和float64的单测?

@cyber-pioneer
Copy link
Contributor

任务完成度很高,手动点赞👍

@luotao1
Copy link
Contributor

luotao1 commented May 7, 2024

@Asthestarsfalll 需要附上 RFC 链接。如果之前的RFC思路和你这儿的有所区别,需要提一个修改 RFC 的PR

@Asthestarsfalll
Copy link
Contributor Author

@Asthestarsfalll 需要附上 RFC 链接。如果之前的RFC思路和你这儿的有所区别,需要提一个修改 RFC 的PR

已添加~

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented May 15, 2024

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

@Asthestarsfalll
Copy link
Contributor Author

@cyber-pioneer 老师请审核~

cyber-pioneer
cyber-pioneer previously approved these changes May 20, 2024
@luotao1
Copy link
Contributor

luotao1 commented May 22, 2024

冲突了,而且DCU流水线失败,需要修复

@Asthestarsfalll Asthestarsfalll force-pushed the lppool branch 2 times, most recently from d6329dd to 015f667 Compare May 28, 2024 05:11
jeff41404
jeff41404 previously approved these changes May 29, 2024
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM


class LPPool1D(Layer):
r"""
This operation applies a 1D power-average pooling over an input signal composed
Copy link
Contributor

Choose a reason for hiding this comment

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

This operation 删了吧,文档里不要出现 OP 的概念

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

4. A list[int] or tuple(int) whose length is 2. It has the form [pad_before, pad_after].
5. A list or tuple of pairs of integers. It has the form [[pad_before, pad_after], [pad_before, pad_after], ...]. Note that, the batch dimension and channel dimension should be [0,0] or (0,0).
The default value is 0.
ceil_mode(bool, optional): ${ceil_mode_comment}Whether to use the ceil function to calculate output height
Copy link
Contributor

Choose a reason for hiding this comment

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

${ceil_mode_comment} 这个是啥

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已去除

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit 85fd4cd into PaddlePaddle:develop Jun 7, 2024
@luotao1 luotao1 changed the title 【Hackathon 6th No.16】为 Paddle 新增 LPPool1D / LPPool2D API 【Hackathon 6th No.16】为 Paddle 新增 LPPool1D / LPPool2D API -part Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants