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

[Docathon] Add paddle.incubate.ampdecorate and paddle.incubate.amp.prune_model API CN Doc #6222

Merged
merged 15 commits into from
Oct 16, 2023
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
Prev Previous commit
Next Next commit
rename
  • Loading branch information
ooooo-create committed Oct 10, 2023
commit a95614d4ce9ed9e427a8a8311eabbcf2359f0b77
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _cn_api_paddle_incubate_amp_decorate:
.. _cn_api_paddle_incubate_asp_decorate:

decorate
-------------------------------

.. py:function:: paddle.incubate.amp.decorate(optimizer)
.. py:function:: paddle.incubate.asp.decorate(optimizer)


将给定的优化器包装为 `OptimizerWithSparsityGuarantee`。如果在动态图模式下运行,装饰时 ASP 会为支持的参数创建掩码变量。如果在静态图模式下运行,ASP 会在调用 minimize() 时创建掩码变量并插入必要的掩码操作。
ooooo-create marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -24,8 +24,8 @@ decorate

1. 动态图模式

COPY-FROM: paddle.incubate.amp.decorate:dynamic_graph
COPY-FROM: paddle.incubate.asp.decorate:dynamic_graph

2. 静态图模式

COPY-FROM: paddle.incubate.amp.decorate:static_graph
COPY-FROM: paddle.incubate.asp.decorate:static_graph
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _cn_api_paddle_incubate_amp_prune_model:
.. _cn_api_paddle_incubate_asp_prune_model:

prune_model
-------------------------------

.. py:function:: paddle.incubate.amp.prune_model(model, n=2, m=4, mask_algo='mask_1d', with_mask=True)
.. py:function:: paddle.incubate.asp.prune_model(model, n=2, m=4, mask_algo='mask_1d', with_mask=True)


使用 mask_algo 指定的掩码生成函数修剪 model 中支持 ASP 的子层参数。使用 with_mask 来控制模型训练和推理,如果 with_mask 是 True ,还有修剪参数相关的 ASP 掩码变量,如果是 False,仅仅裁剪参数。
ooooo-create marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -19,7 +19,7 @@ prune_model
- **n** (int, optional) - n:m 稀疏中的 n
- **m** (int, optional) - n:m 稀疏中的 m
- **mask_algo** (string, optional) - 生成掩码的函数名。默认值为 mask_1d。有效输入应为 mask_1d , mask_2d_greedy 和 mask_2d_best 之一。
- **with_mask** (bool, optional) - 选择是否裁剪参数相关的 AMP 掩码变量,True 是要裁剪,False 就是不裁剪。默认是 True。
- **with_mask** (bool, optional) - 选择是否裁剪参数相关的 ASP 掩码变量,True 是要裁剪,False 就是不裁剪。默认是 True。

返回
:::::::::
Expand All @@ -31,8 +31,8 @@ prune_model

1. 动态图模式

COPY-FROM: paddle.incubate.amp.prune_model:dynamic_graph
COPY-FROM: paddle.incubate.asp.prune_model:dynamic_graph

2. 静态图模式

COPY-FROM: paddle.incubate.amp.prune_model:static_graph
COPY-FROM: paddle.incubate.asp.prune_model:static_graph