forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update doc for ReduceOp (PaddlePaddle#2791)
* update doc for ReduceOp
- Loading branch information
lilong12
authored
Oct 19, 2020
1 parent
cf14cd5
commit d91179d
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. _cn_api_distributed_ReduceOp: | ||
|
||
ReduceOp | ||
------------------------------- | ||
|
||
指定规约类操作的逐元素操作类型,需要是下述值之一: | ||
|
||
ReduceOp.SUM | ||
|
||
ReduceOp.MAX | ||
|
||
ReduceOp.MIN | ||
|
||
ReduceOp.PROD | ||
|
||
代码示例 | ||
::::::::: | ||
.. code-block:: python | ||
import numpy as np | ||
import paddle | ||
from paddle.distributed import ReduceOp | ||
from paddle.distributed import init_parallel_env | ||
paddle.set_device('gpu:%d'%paddle.distributed.ParallelEnv().dev_id) | ||
init_parallel_env() | ||
if paddle.distributed.ParallelEnv().local_rank == 0: | ||
np_data = np.array([[4, 5, 6], [4, 5, 6]]) | ||
else: | ||
np_data = np.array([[1, 2, 3], [1, 2, 3]]) | ||
data = paddle.to_tensor(np_data) | ||
paddle.distributed.all_reduce(data, op=ReduceOp.SUM) | ||
out = data.numpy() | ||
# [[5, 7, 9], [5, 7, 9]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. _cn_api_distributed_ReduceOp: | ||
|
||
ReduceOp | ||
------------------------------- | ||
|
||
指定规约类操作的逐元素操作类型,需要是下述值之一: | ||
|
||
ReduceOp.SUM | ||
|
||
ReduceOp.MAX | ||
|
||
ReduceOp.MIN | ||
|
||
ReduceOp.PROD | ||
|
||
代码示例 | ||
::::::::: | ||
.. code-block:: python | ||
import numpy as np | ||
import paddle | ||
from paddle.distributed import ReduceOp | ||
from paddle.distributed import init_parallel_env | ||
paddle.set_device('gpu:%d'%paddle.distributed.ParallelEnv().dev_id) | ||
init_parallel_env() | ||
if paddle.distributed.ParallelEnv().local_rank == 0: | ||
np_data = np.array([[4, 5, 6], [4, 5, 6]]) | ||
else: | ||
np_data = np.array([[1, 2, 3], [1, 2, 3]]) | ||
data = paddle.to_tensor(np_data) | ||
paddle.distributed.all_reduce(data, op=ReduceOp.SUM) | ||
out = data.numpy() | ||
# [[5, 7, 9], [5, 7, 9]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters