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][A-40,A-41,A-42] Add type annotations for some optimizers (adamax, adamw, asgd) #65236

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

ooooo-create
Copy link
Contributor

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • paddle/optimizer/adamax.py
  • paddle/optimizer/adamw.py
  • paddle/optimizer/asgd.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jun 17, 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 Jun 17, 2024
@ooooo-create ooooo-create changed the title [Typing][A-40,A-41,A-42] Add type annotations for paddle/optimizer/optimizer/* [Typing][A-40,A-41,A-42] Add type annotations for paddle/optimizer/* Jun 17, 2024
@SigureMo
Copy link
Member

2024-06-18 00:41:53 ++ python type_checking.py
2024-06-18 00:41:53 ----------------Check results--------------------
2024-06-18 00:41:53 paddle.optimizer.Adamax:1
2024-06-18 00:41:53 <string>:11:15: error: Argument "beta1" to "Adamax" has incompatible type "Tensor"; expected "float"  [arg-type]
2024-06-18 00:41:53 <string>:12:15: error: Argument "beta2" to "Adamax" has incompatible type "Tensor"; expected "float"  [arg-type]
2024-06-18 00:41:53 Found 2 errors in 1 file (checked 1 source file)
2024-06-18 00:41:53 
2024-06-18 00:41:53 
2024-06-18 00:41:53 >>> Mistakes found in type checking!
2024-06-18 00:41:53 >>> Please recheck the type annotations. Run `tools/type_checking.py` to check the typing issues:
2024-06-18 00:41:53 > python tools/type_checking.py paddle.optimizer.Adamax
2024-06-18 00:41:53 ----------------End of the Check--------------------

adamax 的 beta1、beta2 支持 Tensor?

@ooooo-create
Copy link
Contributor Author

2024-06-18 00:41:53 ++ python type_checking.py
2024-06-18 00:41:53 ----------------Check results--------------------
2024-06-18 00:41:53 paddle.optimizer.Adamax:1
2024-06-18 00:41:53 <string>:11:15: error: Argument "beta1" to "Adamax" has incompatible type "Tensor"; expected "float"  [arg-type]
2024-06-18 00:41:53 <string>:12:15: error: Argument "beta2" to "Adamax" has incompatible type "Tensor"; expected "float"  [arg-type]
2024-06-18 00:41:53 Found 2 errors in 1 file (checked 1 source file)
2024-06-18 00:41:53 
2024-06-18 00:41:53 
2024-06-18 00:41:53 >>> Mistakes found in type checking!
2024-06-18 00:41:53 >>> Please recheck the type annotations. Run `tools/type_checking.py` to check the typing issues:
2024-06-18 00:41:53 > python tools/type_checking.py paddle.optimizer.Adamax
2024-06-18 00:41:53 ----------------End of the Check--------------------

adamax 的 beta1、beta2 支持 Tensor?

应该不行叭,看 ops.yml 里面 adamax 定义的写的是 float beta1,adam 写的是 scalar beta1

@SigureMo
Copy link
Member

应该不行叭,看 ops.yml 里面 adamax 定义的写的是 float beta1,adam 写的是 scalar beta1

示例代码不能跑吗?

@ooooo-create
Copy link
Contributor Author

示例代码不能跑吗?

可以~,加上 Tensor 了

@SigureMo
Copy link
Member

可以~,加上 Tensor 了

应该不止这一个?看其他 API 也有这么用的

@ooooo-create
Copy link
Contributor Author

可以~,加上 Tensor 了

应该不止这一个?看其他 API 也有这么用的

是有一些,有些 docstring 里没有明确写beta1,beta2支持 0d tensor,但是传进去也不报错,adam 里 epsilon 也写可以是 0d tensor,别的地方 docstring 也没明确写支持,但是也可以传😂

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 🐾

@SigureMo SigureMo changed the title [Typing][A-40,A-41,A-42] Add type annotations for paddle/optimizer/* [Typing][A-40,A-41,A-42] Add type annotations for some optimizers (adamax, adamw, asgd) Jun 18, 2024
@SigureMo SigureMo merged commit a571934 into PaddlePaddle:develop Jun 18, 2024
32 of 33 checks passed
@SigureMo SigureMo added the HappyOpenSource 快乐开源活动issue与PR label Jun 21, 2024
co63oc pushed a commit to co63oc/Paddle that referenced this pull request Jun 25, 2024
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.

2 participants