-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...el_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu_factor.md
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,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]) | ||
``` |
49 changes: 49 additions & 0 deletions
49
...convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu_factor_ex.md
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,49 @@ | ||
## [ 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 无此参数,Pytorch 为 True 时,需要转写。 | | ||
| out | - | 表示输出的 Tensor 元组 ,Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### check_errors:检查 infos 的内容 | ||
|
||
```python | ||
# Pytorch 写法,设置为 True | ||
torch.linalg.lu_factor_ex(A, check_errors=True) | ||
|
||
# Paddle 写法 | ||
LU, P, info = paddle.linalg.lu(A, get_infos=True) | ||
assert info.item == 0 | ||
``` | ||
|
||
#### 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]) | ||
``` |