CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Typing] 修改 core.pyi 及一些示例代码中的类型错误 #65496
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/base/core.pyi
Outdated
@@ -26,23 +28,39 @@ class Place: | |||
def set_place(self, place: Place) -> None: ... | |||
def xpu_device_id(self) -> int: ... | |||
|
|||
class CPUPlace(Place): ... | |||
class CPUPlace: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不「继承」,也不「实现」的话,怎么保证 CPUPlace()
可以传入 foo(p: Place)
呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
咱们有个
PlaceLike: TypeAlias = Union[
"CPUPlace",
"CUDAPlace",
"CUDAPinnedPlace",
"IPUPlace",
"CustomPlace",
"XPUPlace",
str, # some string like "cpu", "gpu:0", etc.
]
是不是应该用这个?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那……Place
的意义是啥啊 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道 ... ... 可能有地方单独需要 Place
的一些方法?
class Place(Protocol):
def custom_device_id(self) -> int: ...
def custom_device_type(self) -> str: ...
def gpu_device_id(self) -> int: ...
def ipu_device_id(self) -> int: ...
def is_cpu_place(self) -> bool: ...
def is_cuda_pinned_place(self) -> bool: ...
def is_custom_place(self) -> bool: ...
def is_gpu_place(self) -> bool: ...
def is_ipu_place(self) -> bool: ...
def is_xpu_place(self) -> bool: ...
def set_place(self, place: Place) -> None: ...
def xpu_device_id(self) -> int: ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以为啥不实现呢?
所有 Place 实现这个 Place 不可以么?
然后我们是不是可以用 PlaceLike: TypeAlias = Union[Place, str]
?
Update 20240626
|
@@ -54,7 +54,7 @@ def __init__( | |||
oup: int, | |||
stride: int, | |||
expand_ratio: float, | |||
norm_layer: nn.Layer = nn.BatchNorm2D, | |||
norm_layer: type[nn.Layer] = nn.BatchNorm2D, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是和 #65487 做重了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦?好像当时还只看到 mobilenetv3 ~ 我撤掉就行 ~
Update 20240627
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
喔喔,还有点问题 |
居然影响到这里 ... ... 防不胜防 ~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! LGTM
PR Category
User Experience
PR Types
Bug fixes
Description
core.pyi
中XXXPlace
不再继承Place
core.pyi
一些类及方法关联 PR #65008 #65397
@SigureMo