-
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] reformat example code with google style in No. 250-260 #56541
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
以后这种有特别大的文件注意拆成不同的 PR,比如这里的 Tensor 相关就不合适和分布式放在一起,较小的 PR 一般零碎时间就可以 review 了,这种大 PR 可能必须要找完整的时间(可能至少半小时)才能 review PR 拆分也要合适,不是说每个文件一个 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.
还有俩 tensor 的没看……
以后非必要这个任务不要改非示例代码部分了,typo 可以改,改参数、格式什么的,review 难度瞬间增大几十倍
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Show resolved
Hide resolved
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Outdated
Show resolved
Hide resolved
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Outdated
Show resolved
Hide resolved
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Outdated
Show resolved
Hide resolved
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Outdated
Show resolved
Hide resolved
python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py
Outdated
Show resolved
Hide resolved
好的,主要是改示例代码时看到参数和单词那些错的,就一起改了。。 |
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.
pslib 用 .. code-block:: text 应该没啥问题 ~ 解析时候是匹配 python ~
fluid 的一些接口有点问题 ~
python/paddle/incubate/layers/nn.py
Outdated
.. code-block:: python | ||
|
||
>>> # doctest: +REQUIRES(env:GPU) | ||
>>> import paddle | ||
>>> paddle.enable_static() | ||
|
||
>>> def build_program(main_program, startup_program): | ||
... with paddle.program_guard(main_program, startup_program): | ||
... x = paddle.static.data(name='x', shape=[-1, 1, 28, 28], dtype='float32') | ||
... y = paddle.static.data(name="y", shape=[-1, 1], dtype='int64') | ||
... conv1_1 = paddle.static.nn.conv2d( | ||
... input=x, | ||
... filter_size=3, | ||
... num_filters=32, | ||
... stride=1, | ||
... padding=1, | ||
... act=None, | ||
... bias_attr=False, | ||
... data_format='NHWC') | ||
... conv1_2 = paddle.static.nn.conv2d( | ||
... input=x, | ||
... filter_size=3, | ||
... num_filters=32, | ||
... stride=1, | ||
... padding=1, | ||
... act=None, | ||
... bias_attr=False, | ||
... data_format='NHWC') | ||
... bn = paddle.static.nn.batch_norm( | ||
... input=conv1_1, | ||
... act=None, | ||
... data_layout='NHWC') | ||
... fused_bn_add_act = paddle.incubate.layers.fused_bn_add_act(conv1_2, bn) | ||
... prediction = paddle.static.nn.fc(x=fused_bn_add_act, size=10, activation='softmax') | ||
... loss = paddle.nn.functional.cross_entropy( | ||
... input=prediction, label=y, | ||
... reduction='none', use_softmax=False | ||
... ) | ||
... loss = paddle.mean(loss) | ||
... sgd = paddle.optimizer.SGD(learning_rate=0.001) | ||
... sgd = paddle.static.amp.decorate( | ||
... sgd, use_dynamic_loss_scaling=True, init_loss_scaling=128.0) | ||
... sgd.minimize(loss) | ||
... | ||
... return x, y, loss | ||
|
||
>>> iters = 5 | ||
>>> batch_size = 16 | ||
>>> support_gpu = paddle.is_compiled_with_cuda() | ||
>>> if support_gpu: | ||
... main_program = paddle.Program() | ||
... startup_program = paddle.Program() | ||
... place = paddle.CUDAPlace(0) | ||
... x, y, loss = build_program(main_program, startup_program) | ||
... | ||
... feeder = paddle.DataFeeder(feed_list=[x, y], place=place) | ||
... train_reader = paddle.batch( | ||
... paddle.dataset.mnist.train(), batch_size=batch_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.
这一段里面 fluid 相关的修改有点问题 ~
比如
- paddle.Program -> paddle.static.Program
- paddle.DataFeeder
- paddle.program_guard
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 话说现在这种空的是正常的么,我看代码里好像是会在下面输出 CPU 和 GPU 各自的信息: Paddle/paddle/scripts/paddle_build.sh Line 3875 in 7635af0
现在好像是 CPU 和 GPU 其中一个失败了,但是报错信息不是很明显 |
确实是!日志前面翻一下,是 GPU 环境运行出错了 ~ 不过,具体要怎么改,我这边吃不准。
个人感觉 |
在 https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/git_guides/paddle_ci_manual_cn.html#pr-ci-static-check 可以找到一部分描述,但是我不太清楚「编译脚本」、「测试脚本」代表什么,从名字上看这两条命令明明只是差了环境而已,两个应该都是「编译 + 测试脚本」 我看了下流水线配置,应该只执行了
应该是这样的…… |
刚又看了 function summary_check_problems() {
set +x
local example_code=$1
local example_info=$2
if [ $example_code -ne 0 ];then
echo "==============================================================================="
echo "*****Example code error***** Please fix the error listed in the information:"
echo "==============================================================================="
echo "$example_info" | grep "API check -- Example Code" -A $(echo "$example_info" | wc -l)
exit $example_code
fi
set -x
} 这里我也改一下吧 ~ |
@enkilee 日志里 GPU 报错的 case 需要修正下哈 |
2023-09-05 15:37:19 2023-09-05 15:37:19 RuntimeError: |
@enkilee 设置一下 device 吧 ~ >>> # doctest: +REQUIRES(env:GPU)
>>> import paddle
>>> paddle.set_device('gpu')
>>> paddle.seed(2023)
>>> from paddle.incubate.nn.functional import fused_dropout_add
>>> x = paddle.randn([4, 10], dtype="float32")
>>> y = paddle.randn([4, 10], dtype="float32")
>>> out = fused_dropout_add(x, y, p=0.5)
>>> print(out) |
实在抱歉,忘了。 |
…into xdoctest-250-260
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.
emmmm,还有些小问题最好解决下 已解决
python/paddle/incubate/nn/functional/fused_rotary_position_embedding.py
Outdated
Show resolved
Hide resolved
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 🐾
…ddlePaddle#56541) * test=docs_preview * test=docs_preview * test=docs_preview * test=docs_preview * test=docs_preview * test=docs_preview * fix * test=docs_preview * test=docs_preview * fix * move stmts under imports --------- Co-authored-by: SigureMo <[email protected]>
PR types
Others
PR changes
Others
Description
250 | 1364 | python/paddle/incubate/distributed/fleet/parameter_server/pslib/init.py | @enkilee |
251 | 233 | python/paddle/incubate/distributed/models/moe/grad_clip.py | @enkilee |
252 | 500 | python/paddle/incubate/distributed/models/moe/moe_layer.py | @enkilee |
253 | 1659 | python/paddle/incubate/layers/nn.py | @enkilee |
254 | 3599 | python/paddle/tensor/linalg.py | @enkilee |
255 | 1150 | python/paddle/tensor/logic.py | @enkilee |
256 | 116 | python/paddle/incubate/nn/functional/fused_dropout_add.py | @enkilee |
257 | 75 | python/paddle/incubate/nn/functional/fused_ec_moe.py | @enkilee |
258 | 166 | python/paddle/incubate/nn/functional/fused_gate_attention.py | @enkilee |
259 | 161 | python/paddle/incubate/nn/functional/fused_matmul_bias.py | @enkilee |
260 | 49 | python/paddle/incubate/nn/functional/fused_rotary_position_embedding.py | @enkilee
预览:
en: http://preview-paddle-pr-56541.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/en/api/paddle/abs_en.html
zh: http://preview-paddle-pr-56541.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/abs_cn.html
关联 PR:
#55629
#55295
@sunzhongkai588 @SigureMo @megemini