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

[xdoctest] reformat example code with google style in No.138 and 140 #57479

Closed
wants to merge 6 commits into from

Conversation

yuchen202
Copy link
Contributor

PR types

Others

PR changes

Others

Description

修改如下文件的示例代码,使其通过 xdoctest 检查:

python\paddle\tensor\manipulation.py
python\paddle\tensor\search.py

Related links

@paddle-bot
Copy link

paddle-bot bot commented Sep 19, 2023

你的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.

@yuchen202
Copy link
Contributor Author

我先改改,先不慌review

@paddle-bot paddle-bot bot added the contributor External developers label Sep 19, 2023
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Sep 20, 2023
先浅改了一下下,请大佬帮我康康
@luotao1
Copy link
Contributor

luotao1 commented Sep 26, 2023

我先改改,先不慌review

改完了么?

@yuchen202
Copy link
Contributor Author

yuchen202 commented Sep 26, 2023 via email

# [[2., 2., 2.],
# [1., 1., 1.],
# [2., 2., 2.]])
>>> # required: gpu
Copy link
Contributor

Choose a reason for hiding this comment

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

改成 doctest 的样式 ~

# [[2., 1., 2.],
# [2., 1., 2.],
# [2., 1., 2.]])
>>> # required: gpu
Copy link
Contributor

Choose a reason for hiding this comment

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

改成 doctest 的样式 ~

>>> # doctest: +REQUIRES(env:GPU)

out = paddle.flatten(img, start_axis=1, stop_axis=2)
# out shape is [2, 12, 4]
>>> out = paddle.flatten(img, start_axis=1, stop_axis=2)
>>> # out shape is [2, 12, 4]
Copy link
Contributor

Choose a reason for hiding this comment

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

>>> print(out.shape)
[2, 12, 4]

Comment on lines 1599 to 1601
>>> print(out[0, 0, 0])
Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,
[-1])
Copy link
Contributor

Choose a reason for hiding this comment

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

已经是 0D 的了

Tensor(shape=[], dtype=int64, place=Place(gpu:0), stop_gradient=True,
       -1)

Comment on lines 3689 to 3698
>>> # the shape of out_2 is [4, 12].
Tensor(shape=[4, 12], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.16556728, 0.98233348, 0.64653695, 0.68488085, 0.26045629, 0.32933319,
0.29747701, 0.85176629, 0.84460896, 0.86866283, 0.46335083, 0.33930254],
[0.42339125, 0.14102051, 0.69832194, 0.63159829, 0.91087127, 0.31725556,
0.09400324, 0.25861803, 0.26968575, 0.38659596, 0.25225133, 0.26315665],
[0.83726203, 0.33221707, 0.98031831, 0.38393897, 0.00512545, 0.04543629,
0.90596122, 0.70148915, 0.26110184, 0.55263036, 0.68636090, 0.67877120],
[0.60491085, 0.96849394, 0.08488113, 0.48084566, 0.61894107, 0.92885363,
0.37273413, 0.08096626, 0.74429852, 0.85212839, 0.60244918, 0.76718718]])
Copy link
Contributor

Choose a reason for hiding this comment

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

reshape 后的数据不对 ~ x 只是 shape 变了,数据应该不变的 ~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我看看啊

Comment on lines 4236 to 4240
Tensor(shape=[1], dtype=float64, place=Place(cpu), stop_gradient=True,
[285.])
>>> print(z2)
Tensor(shape=[1], dtype=float64, place=Place(cpu), stop_gradient=True,
[285.])
Copy link
Contributor

Choose a reason for hiding this comment

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

这里 Tensor 是 0D 的 ~

Comment on lines 5323 to 5324
[[0., 1.],
[4., 5.]]
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是 Tensor ~

Comment on lines 2680 to 2685
>>> print(out1[0, 0, 0])
[10.]
>>> print(out2[0, 0, 0, 0])
[10.]
>>> print(out3[0, 0, 0, 0, 0])
[10.]
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是 Tensor ~

Comment on lines 5220 to 5226
>>> import paddle
>>> paddle.base.set_flags({"FLAGS_use_stride_kernel": True})

>>> x = paddle.rand([2, 4, 6], dtype="float32")

>>> out = paddle.view(x, "uint8")
>>> print(out)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里最好也加个 seed 重新看一下结果 ~

Comment on lines 5281 to 5290
>>> print(out)
Tensor(shape=[8, 6], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.23340422, 0.62036550, 0.12185233, 0.88982582, 0.61383390, 0.22415221],
[0.85698199, 0.87602723, 0.00502827, 0.92127788, 0.34579527, 0.85451263],
[0.68906647, 0.05126054, 0.25322226, 0.43883288, 0.49656981, 0.68857300],
[0.21424839, 0.99576813, 0.62306029, 0.48010525, 0.31222206, 0.48758999],
[0.35929242, 0.12802263, 0.80540675, 0.76783085, 0.84970695, 0.00389719],
[0.69256896, 0.73718327, 0.97155327, 0.50271672, 0.60357946, 0.59580350],
[0.68182445, 0.28539398, 0.13948134, 0.66333318, 0.72601736, 0.31108484],
[0.58283192, 0.89317679, 0.11751470, 0.04111906, 0.04056534, 0.75454420]])
Copy link
Contributor

Choose a reason for hiding this comment

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

这个结果跟 aistudio 上的不一样 ~ 需要确认一下 ~

应该还有一个文件要review@megemini
Comment on lines 2683 to 2690
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[10.])
>>> print(out2[0, 0, 0, 0])
[10.]
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[10.])
>>> print(out3[0, 0, 0, 0, 0])
[10.]
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[10.])
Copy link
Contributor

Choose a reason for hiding this comment

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

可以在 aistudio 上面验证一下,安装最新的 develop 版本:


python -m pip install paddlepaddle-gpu==0.0.0.post112 -f https://www.paddlepaddle.org.cn/whl/linux/gpu/develop.html

结果应该是 0D 而不是 1D ~

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Oct 5, 2023

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

python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
python/paddle/tensor/search.py Outdated Show resolved Hide resolved
Comment on lines +3672 to +3695
[[[[0.01787627, 0.76492310],
[0.67605734, 0.04620579],
[0.38763246, 0.96462214]],
[[0.62356627, 0.64948404],
[0.53736508, 0.09874519],
[0.47123933, 0.85700107]],
[[0.34647217, 0.62869102],
[0.54760450, 0.18061899],
[0.55075216, 0.71997911]],
[[0.78576684, 0.76743823],
[0.35644373, 0.63325852],
[0.26549375, 0.68052763]]],
[[[0.40971112, 0.95848298],
[0.41229674, 0.05506011],
[0.18543524, 0.63480365]],
[[0.81180859, 0.94548297],
[0.19634065, 0.73838711],
[0.42057949, 0.96017945]],
[[0.72278100, 0.93858665],
[0.72018963, 0.61661047],
[0.33307818, 0.86660689]],
[[0.55808324, 0.12933673],
[0.42916751, 0.22745337],
[0.60508877, 0.82193440]]]])
Copy link
Member

Choose a reason for hiding this comment

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

这里 reshape 的输出是没有必要的,可以

  • 只打印 shape
  • 或者使用较小的、arange 数据

下同,其他地方也需要修改

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Oct 18, 2023

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

@luotao1
Copy link
Contributor

luotao1 commented Oct 19, 2023

@luotao1 luotao1 closed this Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants