-
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
[xdoctest][task 318-322] reformat example code with google style in paddle/fluid/*
and python/paddle/sparse/unary
#56748
Conversation
python/paddle/sparse/unary.py
Outdated
>>> import paddle | ||
|
||
>>> format = "coo" | ||
>>> dense_x = paddle.randn((5, 5), dtype='float64') | ||
|
||
>>> if format == "coo": | ||
... sparse_x = dense_x.to_sparse_coo(len(dense_x.shape)) | ||
>>> else: | ||
... sparse_x = dense_x.to_sparse_csr() | ||
|
||
>>> print("sparse.pca_lowrank API only support CUDA 11.x") | ||
>>> U, S, V = None, None, None | ||
>>> # use code blow when your device CUDA version >= 11.0 | ||
>>> # U, S, V = paddle.sparse.pca_lowrank(sparse_x) | ||
|
||
>>> print(U) |
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.
这段代码可以在 gpu 下面跑,试一下:
- 加个 REQUIRES 和 set_device
- 加个 seed,因为有 randn
- 使用
U, S, V = paddle.sparse.pca_lowrank(sparse_x)
而不是U, S, V = None, None, None
然后看看结果如何 ~
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.
收到 辛苦review ,已更新代码
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.
您好 尊敬的 @megemini 先生:
本次对应将U, S, V = paddle.sparse.pca_lowrank(sparse_x) 结果值分别进行打印,根据log显示 CI check失败 ,报错信息如下:
根据目前情况 是否执行 >>> # doctest: +SKIP('random sample') 跳过测试?
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.
根据目前情况 是否执行 >>> # doctest: +SKIP('random sample') 跳过测试?
先不要跳过 ~
这段示例代码的输出没有改,导致的错误 ~
从日志上看,我在 aistudio 上用 dev 版本的 gpu 环境,测试的结果跟 ci 结果是一样的 ~
自己尝试运行,然后修改一下示例中的结果吧。
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.
我在 aistudio 用 dev 版本测试,pca_lowrank 是没问题的,包括随机结果也一致 ~
但是 CI 环境中运行出错了~
@SigureMo 看看咋整? @whisky-12 抽空重新跑一下 CI 试试?
我 rerun 下试试 |
收到,辛苦了 , 我在aistudio也跑了下结果 如下: |
图挂了 ~ 🫠🫠🫠 你能看到? |
github 抽风了,现在我这边头像也看不到了 ~ 🤣🤣🤣 搞不明白了,只能怀疑 ci 里面的包有问题? |
🤣🤣🤣 其实我比较好奇 同样的代码 CI的报错量咋还不一样了呢 ,难搞哦 |
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.
感谢对问题的指摘,辛苦了 , 之前由于对函数模块的理解错误 ,造成了遗漏,对此深表歉意 ,我这边会重新对代码进行排查,再次感谢 ,辛苦了
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.
@megemini 有时间看看
.cc
文件目前是不支持嘛?
工具没有限制文件类型,这里是因为,cc 里面文档的书写方式与python不同(cc: DOC...DOC, python: """...""") ~
我把工具里面解析的正则改一下吧 ~
不过,这个应该不影响 CI 里面的检查,CI 里面是直接读取 docstring 的 ~
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.
已更新,pull 试一下 ~
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.
2023-09-08 10:37:57 --------------------------------------
2023-09-08 10:37:57 C++ Traceback (most recent call last):
2023-09-08 10:37:57 --------------------------------------
2023-09-08 10:37:57 0 phi::DenseTensor::~DenseTensor()
2023-09-08 10:37:57 1 std::_Sp_counted_deleter<phi::Allocation*, std::function<void (phi::Allocation*)>, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()
2023-09-08 10:37:57 2 paddle::memory::allocation::StatAllocator::FreeImpl(phi::Allocation*)
2023-09-08 10:37:57 3 paddle::memory::allocation::CPUAllocator::FreeImpl(phi::Allocation*)
日志里面 paddle.sparse.transpose
挂了~ 这是啥意思?回收内存的时候挂了?
python/paddle/sparse/unary.py
Outdated
>>> out1 = paddle.sparse.sum(sparse_x) # [1.] | ||
>>> out2 = paddle.sparse.sum(sparse_x, axis=0) # [-1., 2.] | ||
>>> out3 = paddle.sparse.sum(sparse_x, axis=-1) # [-2., 3.] | ||
>>> out4 = paddle.sparse.sum(sparse_x, axis=1, keepdim=True) # [[-2.], [3.]] |
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.
这里可以用print把输出打印出来~
paddle/fluid/*
and python/paddle/sparse/unary
2023-09-10 04:37:32 DOCTEST DEBUG INFO
2023-09-10 04:37:32 XDoc "<modpath?>::paddle.sparse.transpose:1:0", line 7 <- wrt doctest
2023-09-10 04:37:32 File "<fpath?>", line 7, <- wrt source file
2023-09-10 04:37:32 DOCTEST PART BREAKDOWN
2023-09-10 04:37:32 Passed Parts:
2023-09-10 04:37:32 1 >>> import paddle
2023-09-10 04:37:32 3 >>> dense_x = paddle.to_tensor([[-2., 0.], [1., 2.]])
2023-09-10 04:37:32 4 >>> sparse_x = dense_x.to_sparse_coo(1)
2023-09-10 04:37:32 5 >>> out = paddle.sparse.transpose(sparse_x, [1, 0])
2023-09-10 04:37:32 Failed Part:
2023-09-10 04:37:32 6 >>> out
2023-09-10 04:37:32 DOCTEST TRACEBACK
2023-09-10 04:37:32 Differences (unified diff with -expected +actual):
2023-09-10 04:37:32 @@ -1,4 +1,4 @@
2023-09-10 04:37:32 Tensor(shape=[2, 2], dtype=paddle.float32, place=Place(cpu), stop_gradient=True,
2023-09-10 04:37:32 - indices=[[0, 0]],
2023-09-10 04:37:32 - values=[[-2., 0.],
2023-09-10 04:37:32 - [ 1., 2.]])
2023-09-10 04:37:32 + indices=[[1139, 65 ]],
2023-09-10 04:37:32 + values=[[-2., 0.],
2023-09-10 04:37:32 + [ 1., 2.]])
2023-09-10 04:37:32
2023-09-10 04:37:32 Repr Difference:
2023-09-10 04:37:32 got = 'Tensor(shape=[2, 2], dtype=paddle.float32, place=Place(cpu), stop_gradient=True, \n indices=[[1139, 65 ]], \n values=[[-2., 0.],\n [ 1., 2.]])'
2023-09-10 04:37:32 want = 'Tensor(shape=[2, 2], dtype=paddle.float32, place=Place(cpu), stop_gradient=True,\n indices=[[0, 0]],\n values=[[-2., 0.],\n [ 1., 2.]])'
2023-09-10 04:37:32 DOCTEST REPRODUCTION
2023-09-10 04:37:32 CommandLine:
2023-09-10 04:37:32 python -m xdoctest <modpath?> paddle.sparse.transpose:1:0
在 aistudio 上面运行,会卡死~ 还是有点问题 ... ... In [1]: import paddle
pa
In [2]: paddle.set_device('cpu')
Out[2]: Place(cpu)
In [3]:
In [3]: >>> 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
malloc_consolidate(): invalid chunk size |
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.
LGTMeow 🐾
Tensor(shape=[2, 2], dtype=paddle.float32, place=Place(cpu), stop_gradient=True, | ||
indices=[[0, 0]], | ||
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.
2023-09-08 10:37:57 -------------------------------------- 2023-09-08 10:37:57 C++ Traceback (most recent call last): 2023-09-08 10:37:57 -------------------------------------- 2023-09-08 10:37:57 0 phi::DenseTensor::~DenseTensor() 2023-09-08 10:37:57 1 std::_Sp_counted_deleter<phi::Allocation*, std::function<void (phi::Allocation*)>, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() 2023-09-08 10:37:57 2 paddle::memory::allocation::StatAllocator::FreeImpl(phi::Allocation*) 2023-09-08 10:37:57 3 paddle::memory::allocation::CPUAllocator::FreeImpl(phi::Allocation*)日志里面
paddle.sparse.transpose
挂了~ 这是啥意思?回收内存的时候挂了?
这个问题有时间 @zrr1999 看一下吧 [doge],这个 PR 我觉得可以先行合入
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.
LGTMeow 🐾
PR types
Others
PR changes
Others
Description
修改如下文件的示例代码,使其通过
xdoctest
检查:python/paddle/sparse/unary.py
paddle/fluid/operators/fused/fused_elemwise_activation_op.cc
paddle/fluid/pybind/cuda_streams_py.cc
paddle/fluid/pybind/custom_device_py.cc
paddle/fluid/pybind/inference_api.cc
预览:
Related links
@sunzhongkai588 @SigureMo @megemini