Skip to content
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

为 paddle.linalg.norm 进行功能升级与对齐- 添加 vector_norm #61155

Merged
merged 6 commits into from
Jan 29, 2024

Conversation

zbt78
Copy link
Contributor

@zbt78 zbt78 commented Jan 25, 2024

PR types

Function optimization

PR changes

APIs

Description

暴露内部函数vector_norm为paddle.linalg.vector_norm

def vector_norm(x, p=2.0, axis=None, keepdim=False, name=None):

>>> print(out_vector_norm)
Tensor(shape=[2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
[12., 11.])
>>> out_vector_norm = paddle.vector_norm(x=x,p=1,axis=1,keepdim=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

infoflow 2024-01-25 14-57-33

这个需要改成 paddle.linalg.vector_norm

x, porder=p, axis=axis, keepdim=keepdim, name=name
)


Copy link
Contributor

Choose a reason for hiding this comment

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

原来的那个内部函数vector_norm也一起删掉吧,这个相当于暴露了之前的内部函数vector_norm,可以覆盖其功能

zhwesky2010
zhwesky2010 previously approved these changes Jan 25, 2024
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.

LGTM

@paddle-bot paddle-bot bot added the contributor External developers label Jan 25, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jan 26, 2024
Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

image 示例代码在CPU环境下跑不通

@zbt78
Copy link
Contributor Author

zbt78 commented Jan 26, 2024

示例代码在CPU环境下跑不通

目前猜测的问题是 当p=0 && len(axis) >= 2时得到结果的数据类型与input数据类型不一致。
请问还有更详细一点的错误提示吗~

@luotao1
Copy link
Contributor

luotao1 commented Jan 26, 2024

请问还有更详细一点的错误提示吗~

本地复现不出来么

@zbt78
Copy link
Contributor Author

zbt78 commented Jan 26, 2024

本地复现不出来么

找到问题了,np.inf的原因,已更正。

zhwesky2010
zhwesky2010 previously approved these changes Jan 26, 2024
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.

doctoring 格式需要规范化一下

Calculate the p-order vector norm for certain dimension of Tensor `input`.
Returns the vector norm (the 1-norm, the Euclidean or 2-norm, and in general the p-norm)
of a given tensor.
Args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Args:
Args:

keepdim (bool, optional): Whether keep the dimensions as the `input`, Default False.
name (str, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`.
Returns:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Returns:
Returns:

Comment on lines +298 to +299
Examples:
.. code-block:: python
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Examples:
.. code-block:: python
Examples:
.. code-block:: python

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

doc-preview的ci挂了,好像是因为你分支behind develop太多,先豁免合入~建议明天去官网develop文档看看效果,有没有错误

@luotao1 luotao1 merged commit d25bf3d into PaddlePaddle:develop Jan 29, 2024
30 checks passed
@luotao1
Copy link
Contributor

luotao1 commented Jan 29, 2024

doc-preview的ci挂了,好像是因为你分支behind develop太多

remind @zbt78
f37053e2ed1e0eeebe916dc5fd2252b3
58961db3cded7f0fa77a57c65d2dc7e5
CI 里只拉最新的200个commit,你是behind 249个了,所以合并分支失败。以后可以常常merge下develop再提上来。

@zbt78
Copy link
Contributor Author

zbt78 commented Jan 29, 2024

CI 里只拉最新的200个commit,你是behind 249个了,所以合并分支失败。以后可以常常merge下develop再提上来。

好滴,明白是那里的问题了。

@luotao1 luotao1 changed the title 【Hackathon 5th No.115】为 paddle.linalg.norm 进行功能升级与对齐- 添加 vector_norm 为 paddle.linalg.norm 进行功能升级与对齐- 添加 vector_norm Jan 29, 2024
Copy link

paddle-bot bot commented Feb 4, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants