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-29] Add type annotations for paddle/nn/initializer/constant.py #65095

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

DrRyanHuang
Copy link
Member

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • paddle/nn/initializer/constant.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jun 12, 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 12, 2024
@DrRyanHuang
Copy link
Member Author

想问下 __init__ 的返回类型一般是 None 还是 ConstantInitializer 之类的?

from __future__ import annotations
from ...base.initializer import ConstantInitializer

class Constant(ConstantInitializer):
    def __init__(self, value: float = ...) -> None: ...

我看这里是前者:
https://github.com/cattidea/paddlepaddle-stubs/blob/main/paddle-stubs/nn/initializer/constant.pyi

@SigureMo
Copy link
Member

想问下 __init__ 的返回类型一般是 None 还是 ConstantInitializer 之类的?

None,__init__ 不返回值,只做初始化,__new__ 才是创建对象的方法

def forward(
self,
var: paddle.Tensor,
block: framework.Block | paddle.pir.Block | None = None,
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
block: framework.Block | paddle.pir.Block | None = None,
block: paddle.pir.Block | None = None,

统一下吧,静态图逻辑里不暴露老 IR 的概念,动静统一逻辑里不暴露静态图的概念

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 merged commit e3c5061 into PaddlePaddle:develop Jun 13, 2024
31 of 33 checks passed
@DrRyanHuang DrRyanHuang deleted the typehint29 branch June 13, 2024 15:40
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