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

doc(): add IPU dy2static related docs. #4932

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/api/paddle/fluid/layers/identity_loss_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. _cn_api_fluid_layers_identity_loss:

identity_loss
-------------------------------

.. py:function:: paddle.fluid.layers.identity_loss(loss, reduction='none')
Copy link
Collaborator

Choose a reason for hiding this comment

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

loss -> x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更改



该OP用于在IPU动态图转静态图功能中标记网络的损失值,从而能够在IPU上为网络添加反向计算过程。该OP以网络的损失值作为输入,并对输入做reduction:
Copy link
Collaborator

Choose a reason for hiding this comment

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

该OP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更改


当 `reduction` 为 `none` 时,直接返回最原始的 `Out` 结果。

当 `reduction` 为 `mean` 时,最终的输出结果为:

.. math::
Out = MEAN(Out)

当 `reduction` 为 `sum` 时,最终的输出结果为:

.. math::
Out = SUM(Out)

参数
::::::::::::

- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'none'``,直接返回输入loss的值;设置为 ``'sum'`` 时,计算输入loss的总和;设置为 ``'mean'`` 时,返回输入loss的均值。
Copy link
Collaborator

Choose a reason for hiding this comment

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

少了 x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已添加


返回
::::::::::::
根据 `reduction` 返回网络损失值的计算结果。

返回类型
Copy link
Collaborator

Choose a reason for hiding this comment

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

返回类型和 返回写在一起

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更改

::::::::::::
Variable

代码示例
::::::::::::

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

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

用 COPY FROM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更改


import paddle.fluid as fluid
import paddle
paddle.enable_static()
loss = fluid.data(name="loss", shape=[-1, 1], dtype="float32")
out = fluid.layers.identity_loss(loss, reduction='sum')
44 changes: 44 additions & 0 deletions docs/api/paddle/static/IpuStrategy_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,50 @@ disable_pattern(self, pattern)

COPY-FROM: paddle.static.IpuStrategy.disable_pattern

register_patch(self)
'''''''''

注册patch function以支持IPU上的动转静功能。该函数仅应在IPU动转静时使用,注册的函数会影响原动转静的逻辑,可通过``release_patch``释放注册的函数。

**代码示例**

COPY-FROM: paddle.static.IpuStrategy.register_patch

release_patch(self)
'''''''''

释放IPU动转静所注册的函数。

**代码示例**

COPY-FROM: paddle.static.IpuStrategy.release_patch

set_optimizer(self, optimizer)
'''''''''

该接口用于在IPU动转静时向IpuStrategy实例设置optimizer。

**参数**

- **optimizer** (Optimizer)- 需要设置的Optimizer实例。

**代码示例**

COPY-FROM: paddle.static.IpuStrategy.set_optimizer

parse_optimizer(self, optimizer)
'''''''''

该接口用于解析IPU动转静所需要的优化器参数,接收优化器实例并返回动转静所需要的优化器属性,当前仅支持解析学习率。

**参数**

- **optimizer** (Optimizer)- 需要解析的Optimizer实例。

**代码示例**

COPY-FROM: paddle.static.IpuStrategy.parse_optimizer

属性
::::::::::::
num_ipus
Expand Down