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

[Typing][C-66][BUAA] Add type annotations for python/paddle/incubate/nn/loss.py #66270

Merged
merged 6 commits into from
Jul 21, 2024

Conversation

uanu2002
Copy link
Contributor

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • python/paddle/incubate/nn/loss.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jul 19, 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.

@paddle-bot paddle-bot bot added the contributor External developers label Jul 19, 2024
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Jul 19, 2024

def identity_loss(x, reduction="none"):
def identity_loss(x: Tensor, reduction: str | int | None = "none") -> Tensor:
Copy link
Contributor

Choose a reason for hiding this comment

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

reduction 可以使用 Literal

另外,为什么 reduction 可以是 None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@uanu2002 uanu2002 requested a review from megemini July 21, 2024 05:19
@SigureMo SigureMo changed the title [Typing][C-66] Add type annotations for python/paddle/incubate/nn/loss.py [Typing][C-66] Add type annotations for python/paddle/incubate/nn/loss.py Jul 21, 2024

_ReduceModeStringLiteral: TypeAlias = Literal['mean', 'sum', 'none']
_ReduceModeNumberLiteral: TypeAlias = Literal[0, 1, 2]
_ReduceMode: TypeAlias = Union[_ReduceModeStringLiteral, _ReduceModeNumberLiteral]
Copy link
Member

Choose a reason for hiding this comment

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

那个……Union 自己 import 下……

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

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

LGTM ~

@SigureMo SigureMo merged commit a6bccb8 into PaddlePaddle:develop Jul 21, 2024
31 checks passed
@uanu2002 uanu2002 changed the title [Typing][C-66] Add type annotations for python/paddle/incubate/nn/loss.py [Typing][C-66 BUAA] Add type annotations for python/paddle/incubate/nn/loss.py Jul 22, 2024
@uanu2002 uanu2002 changed the title [Typing][C-66 BUAA] Add type annotations for python/paddle/incubate/nn/loss.py [Typing BUAA][C-66] Add type annotations for python/paddle/incubate/nn/loss.py Jul 22, 2024
lixcli pushed a commit to lixcli/Paddle that referenced this pull request Jul 22, 2024
inaomIIsfarell pushed a commit to inaomIIsfarell/Paddle that referenced this pull request Jul 31, 2024
@uanu2002 uanu2002 deleted the document branch August 15, 2024 02:43
@SigureMo SigureMo changed the title [Typing BUAA][C-66] Add type annotations for python/paddle/incubate/nn/loss.py [Typing][C-66][BUAA] Add type annotations for python/paddle/incubate/nn/loss.py Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants