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

映射文档 No.358/361 #6139

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## [ torch 参数更多 ]torch.linalg.lu_factor

### [torch.linalg.lu_factor](https://pytorch.org/docs/stable/generated/torch.linalg.lu_factor.html#torch.linalg.lu_factor)

```python
torch.linalg.lu_factor(A, *, bool pivot=True, out=None)
```

### [paddle.linalg.lu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/lu_cn.html)

```python
paddle.linalg.lu(x, pivot=True, get_infos=False, name=None)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ----------------------------------------------------- |
| A | x | 表示需要进行 LU 分解的输入 Tensor ,仅参数名不一致。 |
| pivot | pivot | 表示 LU 分解时是否进行旋转。 |
| - | get_infos | 表示是否返回分解状态信息 , Paddle 保持默认即可。 |
| out | - | 表示输出的 Tensor 元组 , Paddle 无此参数,需要转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
torch.linalg.lu_factor(A, out=(LU, pivots))

# Paddle 写法
y = paddle.linalg.lu(A)
paddle.assign(y[0], out[0]), paddle.assign(y[1], out[1])
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## [ torch 参数更多 ]torch.linalg.lu_factor_ex

### [torch.linalg.lu_factor_ex](https://pytorch.org/docs/stable/generated/torch.linalg.lu_factor_ex.html?highlight=lu_factor_ex#torch.linalg.lu_factor_ex)

```python
torch.linalg.lu_factor_ex(A, *, pivot=True, check_errors=False, out=None)
```

### [paddle.linalg.lu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/lu_cn.html)

```python
paddle.linalg.lu(x, pivot=True, get_infos=True, name=None)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------ | ------------ | --------------------------------------------------------------------------------- |
| A | x | 表示需要进行 LU 分解的输入 Tensor ,仅参数名不一致。 |
| pivot | pivot | 表示 LU 分解时是否进行旋转。 |
| - | get_infos | 表示是否返回分解状态信息 ,PyTorch 返回 infos 信息,Paddle 需要设置为 True。 |
| check_errors | - | 检查 infos 的内容,如果为非 0 抛出错误, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
| out | - | 表示输出的 Tensor 元组 ,Paddle 无此参数,需要转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
torch.linalg.lu_factor_ex(A, out=(LU, pivots, info))

# Paddle 写法
y = paddle.linalg.lu(A, get_infos=True)
paddle.assign(y[0], out[0]), paddle.assign(y[1], out[1]), paddle.assign(y[2], out[2])
```