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-15] Add type annotations for paddle/nn/layer/common.py #65197

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

megemini
Copy link
Contributor

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • paddle/nn/layer/common.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jun 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.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 15, 2024
zrr1999
zrr1999 previously approved these changes Jun 15, 2024
Comment on lines 406 to 408
mode: Literal[
'linear', 'nearest', 'bilinear', 'bicubic', 'trilinear'
] = 'nearest',
Copy link
Member

Choose a reason for hiding this comment

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

这块是不是也可以写个TypeAlias

@SigureMo
Copy link
Member

这个可以等等 #65191,那边基本没啥大问题,应该先做 functional 再做 layer,API 签名基本没啥区别

Copy link

paddle-ci-bot bot commented Jun 23, 2024

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

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.

这个 PR 可以基于相关 functional 推进一下了~

@@ -13,9 +13,23 @@
# limitations under the License.

# TODO: define the common classes to build a neural network
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# TODO: define the common classes to build a neural network

return f'p={self.p}{name_str}'


class FeatureAlphaDropout(Layer):
Copy link
Member

Choose a reason for hiding this comment

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

诶?这个是误添加还是?添加了这个的话,这个 PR 就必须依赖于 #64881 先合了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

那边是不是忘了,早就搞完了 ... ... 🫠

我先删了吧 ~

@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

Copy link
Member

Choose a reason for hiding this comment

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

应该是忘记 PEP 563 了,导致运行时挂掉了

@megemini
Copy link
Contributor Author

Update 20240625

  • python/paddle/sparse/nn/layer/conv.py PEP 563
  • python/paddle/nn/layer/common.py 删除 FeatureAlphaDropout

SigureMo
SigureMo previously approved these changes Jun 25, 2024
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
Copy link
Member

诶?不对,还有些 type error 需要解决~

2024-06-25 16:02:58 ----------------Check results--------------------
2024-06-25 16:02:58 paddle.nn.Pad1D:1
2024-06-25 16:02:58 <string>:7:37: error: Argument "mode" to "Pad1D" has incompatible type "str"; expected "Literal['constant', 'reflect', 'replicate', 'circular']"  [arg-type]
2024-06-25 16:02:58 Found 1 error in 1 file (checked 1 source file)
2024-06-25 16:02:58 
2024-06-25 16:02:58 
2024-06-25 16:02:58 paddle.nn.Pad2D:1
2024-06-25 16:02:58 <string>:7:37: error: Argument "mode" to "Pad2D" has incompatible type "str"; expected "Literal['constant', 'reflect', 'replicate', 'circular']"  [arg-type]
2024-06-25 16:02:58 Found 1 error in 1 file (checked 1 source file)
2024-06-25 16:02:58 
2024-06-25 16:02:58 
2024-06-25 16:02:58 paddle.nn.Pad3D:1
2024-06-25 16:02:58 <string>:7:37: error: Argument "mode" to "Pad3D" has incompatible type "str"; expected "Literal['constant', 'reflect', 'replicate', 'circular']"  [arg-type]
2024-06-25 16:02:58 Found 1 error in 1 file (checked 1 source file)
2024-06-25 16:02:58 
2024-06-25 16:02:58 
2024-06-25 16:02:58 >>> Mistakes found in type checking!
2024-06-25 16:02:58 >>> Please recheck the type annotations. Run `tools/type_checking.py` to check the typing issues:
2024-06-25 16:02:58 > python tools/type_checking.py paddle.nn.Pad1D paddle.nn.Pad2D paddle.nn.Pad3D
2024-06-25 16:02:58 ----------------End of the Check--------------------
2024-06-25 16:02:58 ----------------End of the Check--------------------

from paddle import Tensor

_PaddingSizeMode: TypeAlias = Literal['valid', 'same', 'VALID', 'SAME']
Copy link
Member

Choose a reason for hiding this comment

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

这个要不移到 common?#65460 pool 也有在用

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK~ 要不等 #65460 合了,我再统一修改这个 PR 吧 ~

Copy link
Member

Choose a reason for hiding this comment

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

这个先吧,之后说不定还有其它地方在用,这种模块层次靠近底层的建议优先推进

@SigureMo SigureMo merged commit c106cfe into PaddlePaddle:develop Jun 27, 2024
33 of 34 checks passed
@SigureMo
Copy link
Member

一些下游任务可以推进了

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.

3 participants