-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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][B-70] Add type annotations for python/paddle/sparse/unary.py
#65868
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/sparse/unary.py
Outdated
x: Tensor, | ||
index_dtype: ( | ||
Literal['uint8', 'int8', 'int16', 'int32', 'int64'] | ||
| type[np.uint8 | np.int8 | np.int16 | np.int32 | np.int64] |
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.
paddle 的也支持吧?这里不用区分这么细吧,直接 DTypeLike 就好,不然仍然有一堆重复代码
除非说我们在 typing 里加 IntDTypeLike
,FloatDTypeLike
等,但目前看必要性不是很高
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.
嗯 这里确实有点纠结 ~ 就用 DTypeLike
吧,不然太麻烦了 ~
Update 20240710看了一下示例检查的错误, In [4]: >>> import paddle
...:
...: >>> dense_x = paddle.to_tensor([[-2., 0.], [1., 2.]])
...: >>> sparse_x = dense_x.to_sparse_coo(1)
...: >>> out = paddle.sparse.transpose(sparse_x, [1, 0])
...: >>> out
...:
Out[4]:
Tensor(shape=[2, 2], dtype=paddle.float32, place=Place(gpu:0), stop_gradient=True,
indices=[[4607182418800017408, 4607182418800017408]],
values=[[-2., 0.],
[ 1., 2.]]) 本地验证, 另一个报错的 先 |
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.
PR Category
User Experience
PR Types
Improvements
Description
类型标注:
python/paddle/sparse/unary.py
Related links
@SigureMo @megemini