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

Fix docs #6870

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [无参数]torch.cuda.is_bf16_supported

### [torch.cuda.is_bf16_supported](https://pytorch.org/docs/stable/cuda.html)

```python
torch.cuda.is_bf16_supported()
```

### [paddle.amp.is_bfloat16_supported](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/amp/is_bfloat16_supported_cn.html#is-bfloat16-supported)

```python
paddle.amp.is_bfloat16_supported()
```

功能一致,无参数。
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## [ torch 参数更多 ] torch.distributions.Binomial

### [torch.distributions.Binomial](https://pytorch.org/docs/stable/distributions.html#torch.distributions.binomial.Binomial)

```python
torch.distributions.Binomial(total_count=1,
probs=None,
logits=None,
validate_args=None)
```

### [paddle.distribution.Binomial](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/distribution/Binomial_cn.html#binomial)

```python
paddle.distribution.Binomial(total_count,
probs)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| total_count | total_count | 样本大小。 |
| probs | probs | 每次伯努利实验中事件发生的概率。 |
| logits | - | 采样 1 的 log-odds,Paddle 无此参数,暂无转写方式。 |
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## [ torch 参数更多 ] torch.distributions.ContinuousBernoulli

### [torch.distributions.ContinuousBernoulli](https://pytorch.org/docs/stable/distributions.html)

```python
torch.distributions.ContinuousBernoulli(probs=None,
logits=None,
lims=(0.499, 0.501)
validate_args=None)
```

### [paddle.distribution.ContinuousBernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/distribution/ContinuousBernoulli_cn.html#continuousbernoulli)

```python
paddle.distribution.ContinuousBernoulli(probs,
lims=(0.499, 0.501))
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| probs | probs | 参数化分布的 (0,1) 值。 |
| logits | - | 实值参数,与 probs 通过 sigmoid 函数匹配。Paddle 无此参数,暂无转写方式。 |
| lims | lims | 一个包含两个元素的元组,指定了分布的下限和上限,默认为 (0.499, 0.501)。 |
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## [ torch 参数更多 ] torch.distributions.Exponential

### [torch.distributions.Exponential](https://pytorch.org/docs/stable/distributions.html#torch.distributions.exponential.Exponential.arg_constraints)

```python
torch.distributions.Exponential(rate,
validate_args=None)
```

### [paddle.distribution.Exponential](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/distribution/ExponentialFamily_cn.html#exponential)

```python
paddle.distribution.Exponential(rate)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| rate | rate | 分布的速率参数。 |
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## [ torch 参数更多 ] torch.distributions.MultivariateNormal

### [torch.distributions.MultivariateNormal](https://pytorch.org/docs/stable/distributions.html#multivariatenormal)

```python
torch.distributions.MultivariateNormal(loc,
covariance_matrix=None,
precision_matrix=None,
scale_tril=None,
validate_args=None)
```

### [paddle.distribution.MultivariateNormal](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/distribution/MultivariateNormal_cn.html#multivariatenormal)

```python
paddle.distribution.MultivariateNormal(loc,
covariance_matrix=None,
precision_matrix=None,
scale_tril=None)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| loc | loc | MultivariateNormal 的均值向量。 |
| covariance_matrix | covariance_matrix | MultivariateNormal 的协方差矩阵。 |
| precision_matrix | precision_matrix | MultivariateNormal 协方差矩阵的逆矩阵。 |
| scale_tril | scale_tril | MultivariateNormal 协方差矩阵的柯列斯基分解的下三角矩阵。 |
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## [ paddle 参数更多 ]torch.nn.functional.channel_shuffle

### [torch.nn.functional.channel_shuffle](https://pytorch.org/docs/stable/generated/torch.nn.ChannelShuffle.html)

```python
torch.nn.functional.channel_shuffle(input,
groups)
```

### [paddle.nn.functional.channel_shuffle](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/channel_shuffle_cn.html#channel-shuffle)

```python
paddle.nn.functional.channel_shuffle(x,
groups,
data_format='NCHW',
name=None)
```

其中 Paddle 相比 PyTorch 支持更多其他参数,具体如下:
### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的 Tensor ,仅参数名不一致。 |
| groups | groups | 表示要把通道分成的组数。 |
| - | data_format | 数据格式,可选:NCHW 或 NHWC。PyTorch 无此参数,Paddle 保持默认即可。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## [torch 参数更多] torch.special.gammainc

### [torch.special.gammainc](https://pytorch.org/docs/stable/special.html#torch.special.gammainc)

```python
torch.special.gammainc(input,
other,
*,
out=None)
```

### [paddle.gammainc](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/index_cn.html)

```python
paddle.gammainc(x,
y)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| input | x | 第一个非负输入张量,仅参数名不一致。 |
| other | y | 第二个非负输入张量,仅参数名不一致。 |
| out | - | Paddle 无此参数,需要转写。 |

### 转写示例

#### out:指定输出

```python
# PyTorch 写法
torch.special.gammainc(torch.tensor([1.0,2.0]),torch.tensor([3.0,4.0]),out=y)

# Paddle 写法
paddle.assign(paddle.gammainc(paddle.to_tensor([1.0,2.0]),paddle.to_tensor([3.0,4.0])), y)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## [ torch 参数更多 ]torch.special.gammaincc

### [torch.special.gammaincc](https://pytorch.org/docs/stable/special.html#torch.special.gammaincc)

```python
torch.special.gammaincc(input,
other,
*,
out=None)
```

### [paddle.gammaincc](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/index_cn.html)

```python
paddle.gammaincc(x,
y)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| input | x | 第一个非负输入张量,仅参数名不一致。 |
| other | y | 第二个非负输入张量,仅参数名不一致。 |
| out | - | Paddle 无此参数,需要转写。 |

### 转写示例
#### out:指定输出
```python
# PyTorch 写法
torch.special.gammaincc(torch.tensor([1.0,2.0]),torch.tensor([3.0,4.0]),out=y)

# Paddle 写法
paddle.assign(paddle.gammaincc(paddle.to_tensor([1.0,2.0]),paddle.to_tensor([3.0,4.0])), y)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [ 参数完全一致 ] torch._\_version__.split

### [torch._\_version__.split]()

```python
torch.__version__.split(sep=None, maxsplit=-1)
```

### [paddle._\_version__.split]()

```python
paddle.__version__.split(sep=None, maxsplit=-1)
```

两者功能一致,参数完全一致,具体如下:
### 参数映射

| PyTorch | PaddlePaddle | 备注 |
|---------|--------------| -------------------------------------------------- |
| sep | sep | 分割字符串的分隔符。 |
| max | max | 分割操作的最大次数 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## [ torch 参数更多 ] torch.amp.autocast

### [torch.amp.autocast](https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.autocast)

```python
torch.amp.autocast(device_type,
dtype=None,
enabled=True,
cache_enabled=None)
```

### [paddle.amp.auto_cast](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/amp/auto_cast_cn.html#auto-cast)

```python
paddle.amp.auto_cast(enable=True,
custom_white_list=None,
custom_black_list=None,
level='O1',
dtype='float16',
use_promote=True)
```

PyTorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------ | ------------------------------------------------------------ |
| device_type | - | 指定设备类型,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
| dtype | dtype | 指定自动混合精度的计算类型 |
| enabled | enable | 是否启用自动混合精度。 |
| cache_enabled | - | 启用或禁用 CUDA 图形缓存 Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
| - | custom_white_list | 白名单,通常不需要设置。PyTorch 无此参数,Paddle 保持默认即可。 |
| - | custom_black_list | 黑名单,通常不需要设置。PyTorch 无此参数,Paddle 保持默认即可。 |
| - | level | 混合精度训练的优化级别,可为 O1 、O2 或者 OD 模式。PyTorch 无此参数,Paddle 保持默认即可。 |
| - | use_promote | 当一个算子存在 float32 类型的输入时,按照 Promote to the Widest 原则,选择 float32 数据类型进行计算。PyTorch 无此参数,Paddle 保持默认即可。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [ 参数完全一致 ] flash_attn._\_version__.split

### [flash_attn._\_version__.split](https://github.com/Dao-AILab/flash-attention/blob/72e27c6320555a37a83338178caa25a388e46121/flash_attn/__init__.py)

```python
flash_attn.__version__.split(sep=None, maxsplit=-1)
```

### [paddle._\_version__.split](https://github.com/PaddlePaddle/Paddle/tree/develop)

```python
paddle.__version__.split(sep=None, maxsplit=-1)
```

两者功能一致,参数完全一致,具体如下:
### 参数映射

| flash_attn | PaddlePaddle | 备注 |
|---------|--------------| -------------------------------------------------- |
| sep | sep | 分割字符串的分隔符。 |
| max | max | 分割操作的最大次数 |