Skip to content

Commit 7f98642

Browse files
authored
映射文档更新 (#7321)
* update docs * fix docs * update docs * fix docs * fix docs * update docs
1 parent e6559ce commit 7f98642

21 files changed

+307
-78
lines changed
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
## [ 组合替代实现 ]torch.Tensor.bernoulli_
1+
## [ torch 参数更多 ]torch.Tensor.bernoulli_
22

33
### [torch.Tensor.bernoulli_](https://pytorch.org/docs/stable/generated/torch.Tensor.bernoulli_.html#torch.Tensor.bernoulli_)
44

55
```python
66
torch.Tensor.bernoulli_(p=0.5, *, generator=None)
77
```
8-
Paddle 无此 API,需要组合实现。
98

10-
### 转写示例
11-
#### p:输入概率,类型为 tensor 时
12-
```python
13-
# PyTorch 写法
14-
input.bernoulli_(p=x)
9+
### [paddle.Tensor.bernoulli_](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/tensor/tensor.py)
1510

16-
# Paddle 写法
17-
paddle.assign(paddle.bernoulli(paddle.broadcast_to(x, input.shape)), input)
11+
```python
12+
paddle.Tensor.bernoulli_(p=0.5, name=None)
1813
```
1914

20-
#### p:输入概率,类型为 float 时
21-
```python
22-
# PyTorch 写法
23-
input.bernoulli_(p=x)
15+
PyTorch 相比 Paddle 支持更多其他参数,具体如下:
2416

25-
# Paddle 写法
26-
tensor = paddle.to_tensor([x])
27-
paddle.assign(paddle.bernoulli(paddle.broadcast_to(tensor, input.shape)), input)
28-
```
17+
18+
### 参数映射
19+
20+
| PyTorch | PaddlePaddle | 备注 |
21+
| ------------- | ------------ | ----------------------------------------------------------------------------- |
22+
| p | p | 可选,伯努利参数 p。 |
23+
| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
## [ 组合替代实现 ]torch.Tensor.cholesky_inverse
1+
## [ 参数完全一致 ]torch.Tensor.cholesky_inverse
22

33
### [torch.Tensor.cholesky_inverse](https://pytorch.org/docs/stable/generated/torch.cholesky_inverse.html#torch.cholesky_inverse)
44
```python
55
torch.Tensor.cholesky_inverse(upper=False)
66
```
77

8-
PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。
8+
### [paddle.Tensor.cholesky_inverse](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html)
99

10-
### 转写示例
1110
```python
12-
# PyTorch 写法
13-
y = u.cholesky_inverse(upper)
14-
15-
# Python 写法
16-
ut = paddle.transpose(u, perm=[1, 0])
17-
if upper:
18-
y = paddle.linalg.inv(paddle.matmul(ut, u))
19-
else:
20-
y = paddle.inverse(paddle.matmul(u, ut))
11+
paddle.Tensor.cholesky_inverse(upper=False, name=None)
2112
```
13+
14+
功能一致,参数完全一致,具体如下:
15+
16+
### 参数映射
17+
18+
| PyTorch | PaddlePaddle | 备注 |
19+
| ------- | ------------ | -- |
20+
| upper | upper | 指示是否返回上三角矩阵或下三角矩阵。 |
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
## [ 组合替代实现 ]torch.Tensor.ldexp
1+
## [ 仅参数名不一致 ]torch.Tensor.ldexp
22

33
### [torch.Tensor.ldexp](https://pytorch.org/docs/stable/generated/torch.Tensor.ldexp.html#torch.Tensor.ldexp)
44

55
```python
66
torch.Tensor.ldexp(other)
77
```
88

9-
Paddle 无此 API,需要组合实现。
10-
11-
### 转写示例
9+
### [paddle.Tensor.ldexp](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#tensor)
1210

1311
```python
14-
# PyTorch 写法
15-
y = a.ldexp(b)
16-
17-
# Paddle 写法
18-
y = a * (2 ** b)
12+
paddle.Tensor.ldexp(y)
1913
```
14+
15+
两者功能一致且参数用法一致,仅参数名不一致,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | ------------ | ------------------------------------------ |
21+
| other | y | 表示输入的 Tensor ,仅参数名不一致。 |
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
## [ 组合替代实现 ]torch.Tensor.logaddexp
1+
## [ 仅参数名不一致 ]torch.Tensor.logaddexp
22

33
### [torch.Tensor.logaddexp](https://pytorch.org/docs/stable/generated/torch.Tensor.logaddexp.html#torch.Tensor.logaddexp)
44

55
```python
66
torch.Tensor.logaddexp(other)
77
```
88

9-
Paddle 无此 API,需要组合实现。
10-
11-
### 转写示例
9+
### [paddle.Tensor.logaddexp](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#tensor)
1210

1311
```python
14-
# PyTorch 写法
15-
y = a.logaddexp(b)
16-
17-
# Paddle 写法
18-
y = paddle.log(paddle.exp(a) + paddle.exp(b))
12+
paddle.Tensor.logaddexp(y)
1913
```
14+
15+
两者功能一致且参数用法一致,仅参数名不一致,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | ------------ | ------------------------------------------ |
21+
| other | y | 表示输入的 Tensor ,仅参数名不一致。 |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## [参数完全一致]torch.cuda.reset_max_memory_reserved
1+
## [参数完全一致]torch.cuda.reset_max_memory_cached
22

3-
### [torch.cuda.reset_max_memory_reserved](https://pytorch.org/docs/stable/generated/torch.cuda.reset_max_memory_reserved.html#torch.cuda.reset_max_memory_reserved)
3+
### [torch.cuda.reset_max_memory_cached](https://docs.pytorch.org/docs/stable/generated/torch.cuda.reset_max_memory_cached.html#torch-cuda-reset-max-memory-cached)
44

55
```python
6-
torch.cuda.reset_max_memory_reserved(device)
6+
torch.cuda.reset_max_memory_cached(device)
77
```
88

99
### [paddle.device.cuda.reset_max_memory_reserved](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/device/cuda/reset_max_memory_reserved_cn.html)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [ 无参数 ]torch.bfloat16
2+
3+
### [torch.bfloat16](https://github.com/pytorch/pytorch/tree/main/torch)
4+
5+
```python
6+
torch.bfloat16
7+
```
8+
9+
### [paddle.bfloat16](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/framework/dtype.pyi#L31)
10+
11+
```python
12+
paddle.bfloat16
13+
```
14+
15+
两者功能一致,无参数。
16+
注:该 API 也可直接转写为字符串形式:'bfloat16'。
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [ 无参数 ]torch.bool
2+
3+
### [torch.bool](https://github.com/pytorch/pytorch/tree/main/torch)
4+
5+
```python
6+
torch.bool
7+
```
8+
9+
### [paddle.bool](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/framework/dtype.pyi#L36)
10+
11+
```python
12+
paddle.bool
13+
```
14+
15+
两者功能一致,无参数。
16+
注:该 API 也可直接转写为字符串形式:'bool'。
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
## [ 组合替代实现 ]torch.cholesky_inverse
1+
## [ torch 参数更多 ]torch.cholesky_inverse
2+
23
### [torch.cholesky_inverse](https://pytorch.org/docs/stable/generated/torch.cholesky_inverse.html?highlight=cholesky_inverse#torch.cholesky_inverse)
4+
35
```python
46
torch.cholesky_inverse(input, upper=False, out=None)
57
```
68

7-
### 功能介绍
8-
用于计算对称正定矩阵的逆矩阵,公式为:
9-
> `upper`为 False 时,
10-
> $inv=(uu^T)^{-1}$ ;
11-
> `upper`为 True 时,
12-
> $inv=(u^Tu)^{-1}$ 。
9+
### [paddle.linalg.cholesky_inverse](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/cholesky_inverse_cn.html#cholesky-inverse)
10+
11+
```python
12+
paddle.linalg.cholesky_inverse(x, upper=False, name=None)
13+
```
14+
15+
PyTorch 相比 Paddle 支持更多其他参数,具体如下:
1316

17+
### 参数映射
1418

15-
PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------- | ------------ | ------------------------------------------------------ |
21+
| input | x | 表示输入的 Tensor ,仅参数名不一致。 |
22+
| upper | upper | 指示是否返回上三角矩阵或下三角矩阵。 |
23+
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 |
24+
25+
### 转写示例
1626

1727
```python
18-
import paddle
19-
20-
def cholesky_inverse(input, upper=False, out=None) :
21-
u = paddle.cholesky(input, False)
22-
ut = paddle.transpose(u, perm=[1, 0])
23-
if upper:
24-
out = paddle.inverse(paddle.matmul(ut, u))
25-
else:
26-
out = paddle.inverse(paddle.matmul(u, ut))
27-
return out
28+
# PyTorch 写法
29+
torch.cholesky_inverse(input, out=output)
30+
31+
# Paddle 写法
32+
paddle.assign(paddle.linalg.cholesky_inverse(input), output=output)
2833
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [ 无参数 ]torch.complex128
2+
3+
### [torch.complex128](https://github.com/pytorch/pytorch/tree/main/torch)
4+
5+
```python
6+
torch.complex128
7+
```
8+
9+
### [paddle.complex128](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/framework/dtype.pyi#L34)
10+
11+
```python
12+
paddle.complex128
13+
```
14+
15+
两者功能一致,无参数。
16+
注:该 API 也可直接转写为字符串形式:'complex128'。
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [ 无参数 ]torch.complex64
2+
3+
### [torch.complex64](https://github.com/pytorch/pytorch/tree/main/torch)
4+
5+
```python
6+
torch.complex64
7+
```
8+
9+
### [paddle.complex64](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/framework/dtype.pyi#L33)
10+
11+
```python
12+
paddle.complex64
13+
```
14+
15+
两者功能一致,无参数。
16+
注:该 API 也可直接转写为字符串形式:'complex64'。

0 commit comments

Comments
 (0)