Skip to content

Commit a3424f5

Browse files
authored
映射文档 No.64 - 78 (#5915)
* Add pytorch api diff docs * Fix * Fix * Fix * Fix * Fix
1 parent 3cfd176 commit a3424f5

40 files changed

+1172
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [torch 参数更多]torch.Tensor.cuda
2+
3+
### [torch.Tensor.cuda](https://pytorch.org/docs/1.13/generated/torch.Tensor.cuda.html#torch.Tensor.cuda)
4+
5+
```python
6+
torch.Tensor.cuda(device=None, non_blocking=False, memory_format=torch.preserve_format)
7+
```
8+
9+
### [paddle.Tensor.cuda](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#cuda-device-id-none-blocking-false)
10+
11+
```python
12+
paddle.Tensor.cuda(device_id=None, blocking=False)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------ | ------------------------------------------------------------------------ |
21+
| device | device_id | 目标 GPU 设备,仅参数名不一致。 |
22+
| non_blocking | blocking | 是否使用同步拷贝,仅参数名不一致。 |
23+
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## [参数名不一致]torch.Tensor.fmod
2+
3+
### [torch.Tensor.fmod](https://pytorch.org/docs/1.13/generated/torch.Tensor.fmod.html#torch.Tensor.fmod)
4+
5+
```python
6+
torch.Tensor.fmod(divisor)
7+
```
8+
9+
### [paddle.Tensor.mod](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#mod-y-name-none)
10+
11+
```python
12+
paddle.Tensor.mod(y, name=None)
13+
```
14+
15+
其中功能一致, 仅参数名不一致,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | ------------ | ----------------------------- |
21+
| divisor | y | 多维 Tensor,仅参数名不一致。 |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## [torch 参数更多]torch.Tensor.histogram
2+
3+
### [torch.Tensor.histogram](https://pytorch.org/docs/1.13/generated/torch.Tensor.histogram.html#torch.Tensor.histogram)
4+
5+
```python
6+
torch.Tensor.histogram(bins, *, range=None, weight=None, density=False)
7+
```
8+
9+
### [paddle.Tensor.histogram](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#histogram-bins-100-min-0-max-0)
10+
11+
```python
12+
paddle.Tensor.histogram(bins=100, min=0, max=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | ------------ | -------------------------------------------------------------------------------------------------- |
21+
| bins | bins | 直方图 bins(直条)的个数。 |
22+
| range | min, max | PyTorch 为 bins 的范围,类型为 float,Paddle 为 range 的下边界,上边界,类型为 int,需要进行转写。 |
23+
| weight | - | 权重,Paddle 无此参数,暂无转写方式。 |
24+
| density | - | 结果中每个 bin 是否包含权重数,Paddle 无此参数,暂无转写方式。 |
25+
26+
### 转写示例
27+
28+
#### range 参数:bins 的范围
29+
30+
```python
31+
# PyTorch 写法:
32+
x = torch.tensor([1., 2, 1])
33+
y = x.histogram(bins=5, range=(0., 3.))
34+
35+
# Paddle 写法:
36+
x = paddle.to_tensor([1, 2, 1])
37+
y = x.histogram(bins=5, min=0, max=3)
38+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## [torch 参数更多]torch.distributed.all_gather
2+
3+
### [torch.distributed.all_gather](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_gather)
4+
5+
```python
6+
torch.distributed.all_gather(tensor_list, tensor, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.all_gather](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/all_gather_cn.html)
10+
11+
```python
12+
paddle.distributed.all_gather(tensor_list, tensor, group=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ----------- | ------------ | --------------------------------------------- |
21+
| tensor_list | tensor_list | 操作的输出 Tensor 列表。 |
22+
| tensor | tensor | 操作的输入 Tensor。 |
23+
| group | group | 工作的进程组编号。 |
24+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## [torch 参数更多]torch.distributed.all_reduce
2+
3+
### [torch.distributed.all_reduce](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_reduce)
4+
5+
```python
6+
torch.distributed.all_reduce(tensor, op=<torch.distributed.distributed_c10d.ReduceOp object>, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.all_reduce](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/all_reduce_cn.html)
10+
11+
```python
12+
paddle.distributed.all_reduce(tensor, op=ReduceOp.SUM, group=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| -------- | ------------ | --------------------------------------------- |
21+
| tensor | tensor | 操作的输入 Tensor。 |
22+
| op | op | 归约的具体操作。 |
23+
| group | group | 工作的进程组编号。 |
24+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [torch 参数更多]torch.distributed.all_to_all
2+
3+
### [torch.distributed.all_to_all](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_to_all)
4+
5+
```python
6+
torch.distributed.all_to_all(output_tensor_list, input_tensor_list, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.alltoall](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/alltoall_cn.html)
10+
11+
```python
12+
paddle.distributed.alltoall(in_tensor_list, out_tensor_list, group=None, use_calc_stream=True)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------------ | --------------- | ----------------------------------------------------------------- |
21+
| output_tensor_list | out_tensor_list | 包含所有输出 Tensors 的一个列表,仅参数名不一致。 |
22+
| input_tensor_list | in_tensor_list | 包含所有输入 Tensors 的一个列表,仅参数名不一致。 |
23+
| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 |
24+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
25+
| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## [torch 参数更多]torch.distributed.broadcast
2+
3+
### [torch.distributed.broadcast](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.broadcast)
4+
5+
```python
6+
torch.distributed.broadcast(tensor, src, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.broadcast](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/broadcast_cn.html)
10+
11+
```python
12+
paddle.distributed.broadcast(tensor, src, group=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| -------- | ------------ | ------------------------------------------------------------------------------------------------------ |
21+
| tensor | tensor | 如果当前进程编号是源,那么这个 Tensor 变量将被发送给其他进程,否则这个 Tensor 将接收源发送过来的数据。 |
22+
| src | src | 发送源的进程编号。 |
23+
| group | group | 工作的进程组编号。 |
24+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [torch 参数更多]torch.distributed.recv
2+
3+
### [torch.distributed.recv](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.recv)
4+
5+
```python
6+
torch.distributed.recv(tensor, src=None, group=None, tag=0)
7+
```
8+
9+
### [paddle.distributed.recv](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/recv_cn.html)
10+
11+
```python
12+
paddle.distributed.recv(tensor, src=0, group=None, use_calc_stream=True)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | --------------- | ----------------------------------------------------------------- |
21+
| tensor | tensor | 接收数据的 Tensor。 |
22+
| src | src | 发送者的标识符。 |
23+
| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 |
24+
| tag | - | 匹配接收标签,Paddle 无此参数,暂无转写方式。 |
25+
| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [torch 参数更多]torch.distributed.reduce
2+
3+
### [torch.distributed.reduce](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.reduce)
4+
5+
```python
6+
torch.distributed.reduce(tensor, dst, op=<torch.distributed.distributed_c10d.ReduceOp object>, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.reduce](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/reduce_cn.html)
10+
11+
```python
12+
paddle.distributed.reduce(tensor, dst, op=ReduceOp.SUM, group=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| -------- | ------------ | --------------------------------------------- |
21+
| tensor | tensor | 操作的输入 Tensor。 |
22+
| dst | dst | 返回操作结果的目标进程编号。 |
23+
| op | op | 归约的具体操作。 |
24+
| group | group | 工作的进程组编号。 |
25+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [torch 参数更多]torch.distributed.scatter
2+
3+
### [torch.distributed.scatter](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.scatter)
4+
5+
```python
6+
torch.distributed.scatter(tensor, scatter_list=None, src=0, group=None, async_op=False)
7+
```
8+
9+
### [paddle.distributed.scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/scatter_cn.html)
10+
11+
```python
12+
paddle.distributed.scatter(tensor, tensor_list=None, src=0, group=0)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------ | ------------ | --------------------------------------------- |
21+
| tensor | tensor | 操作的输出 Tensor。 |
22+
| scatter_list | tensor_list | 操作的输入 Tensor 列表,仅参数名不一致。 |
23+
| src | src | 操作的源进程号。 |
24+
| group | group | 工作的进程组编号。 |
25+
| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [torch 参数更多]torch.distributed.send
2+
3+
### [torch.distributed.send](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.send)
4+
5+
```python
6+
torch.distributed.send(tensor, dst, group=None, tag=0)
7+
```
8+
9+
### [paddle.distributed.send](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/send_cn.html)
10+
11+
```python
12+
paddle.distributed.send(tensor, dst=0, group=None, use_calc_stream=True)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | --------------- | ----------------------------------------------------------------- |
21+
| tensor | tensor | 需要发送的 Tensor。 |
22+
| dst | dst | 接收者的标识符。 |
23+
| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 |
24+
| tag | - | 匹配接收标签,Paddle 无此参数,暂无转写方式。 |
25+
| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [torch 参数更多]torch.distributions.categorical.Categorical
2+
3+
### [torch.distributions.categorical.Categorical](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.categorical.Categorical)
4+
5+
```python
6+
torch.distributions.categorical.Categorical(probs=None, logits=None, validate_args=None)
7+
```
8+
9+
### [paddle.distribution.Categorical](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Categorical_cn.html)
10+
11+
```python
12+
paddle.distribution.Categorical(logits, name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------ | --------------------------------------------- |
21+
| probs | - | 事件概率,Paddle 无此参数,暂无转写方式。 |
22+
| logits | logits | 类别分布对应的 logits。 |
23+
| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## [torch 参数更多]torch.distributions.dirichlet.Dirichlet
2+
3+
### [torch.distributions.dirichlet.Dirichlet](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.dirichlet.Dirichlet)
4+
5+
```python
6+
torch.distributions.dirichlet.Dirichlet(concentration, validate_args=None)
7+
```
8+
9+
### [paddle.distribution.Dirichlet](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Dirichlet_cn.html)
10+
11+
```python
12+
paddle.distribution.Dirichlet(concentration)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------- | --------------------------------------------- |
21+
| concentration | concentration | 浓度参数,即公式中 α 参数。 |
22+
| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [torch 参数更多]torch.distributions.distribution.Distribution
2+
3+
### [torch.distributions.distribution.Distribution](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.distribution.Distribution)
4+
5+
```python
6+
torch.distributions.distribution.Distribution(batch_shape=torch.Size([]), event_shape=torch.Size([]), validate_args=None)
7+
```
8+
9+
### [paddle.distribution.Distribution](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Distribution_cn.html)
10+
11+
```python
12+
paddle.distribution.Distribution(batch_shape, event_shape)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------ | --------------------------------------------- |
21+
| batch_shape | batch_shape | 概率分布参数批量形状。 |
22+
| event_shape | event_shape | 多元概率分布维数形状。 |
23+
| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [torch 参数更多]torch.distributions.exp_family.ExponentialFamily
2+
3+
### [torch.distributions.exp_family.ExponentialFamily](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.exp_family.ExponentialFamily)
4+
5+
```python
6+
torch.distributions.exp_family.ExponentialFamily(batch_shape=torch.Size([]), event_shape=torch.Size([]), validate_args=None)
7+
```
8+
9+
### [paddle.distribution.ExponentialFamily](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/ExponentialFamily_cn.html)
10+
11+
```python
12+
paddle.distribution.ExponentialFamily(batch_shape, event_shape)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------- | --------------------------------------------- |
21+
| batch_shape | batch_shape, | 概率分布参数批量形状。 |
22+
| event_shape | event_shape | 多元概率分布维数形状。 |
23+
| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 |

0 commit comments

Comments
 (0)