diff --git a/docs/pytorch_project_convertor/API_docs/ops/README.md b/docs/pytorch_project_convertor/API_docs/ops/README.md index 6366598ce310f4890e4af22ccc13035c349a6460..0b733f3b2df35746564b318ac2e10619e6dc78be 100644 --- a/docs/pytorch_project_convertor/API_docs/ops/README.md +++ b/docs/pytorch_project_convertor/API_docs/ops/README.md @@ -145,6 +145,16 @@ | 140 | [torch.addmv](https://pytorch.org/docs/stable/generated/torch.addmv.html?highlight=addmv#torch.addmv) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.addmv.md) | | 141 | [torch.addr](https://pytorch.org/docs/stable/generated/torch.addr.html?highlight=addr#torch.addr) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.addr.md) | | 142 | [torch.baddbmm](https://pytorch.org/docs/stable/generated/torch.baddbmm.html?highlight=baddbmm#torch.baddbmm) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.baddbmm.md) | -| 143 | [torch.bmm](https://pytorch.org/docs/stable/generated/torch.bmm.html?highlight=bmm#torch.bmm) | [paddle.bmm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/bmm_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor | +| 143 | [torch.addmm](https://pytorch.org/docs/stable/generated/torch.addmm.html?highlight=addmm#torch.addmm) | [paddle.addmm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/addmm_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor | +| 144 | [torch.chain_matmul](https://pytorch.org/docs/stable/generated/torch.chain_matmul.html?highlight=chain_matmul#torch.chain_matmul) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.chain_matmul.md) | +| 145 | [torch.cholesky_inverse](https://pytorch.org/docs/stable/generated/torch.cholesky_inverse.html?highlight=cholesky_inverse#torch.cholesky_inverse) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_inverse.md) | +| 146 | [torch.cholesky_solve](https://pytorch.org/docs/stable/generated/torch.cholesky_solve.html?highlight=cholesky_solve#torch.cholesky_solve) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_solve.md) | +| 147 | [torch.matmul](https://pytorch.org/docs/stable/generated/torch.matmul.html?highlight=matmul#torch.matmul) | [paddle.matmul](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/matmul_cn.html) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.matmul.md) | +| 148 | [torch.mm](https://pytorch.org/docs/stable/generated/torch.mm.html?highlight=mm#torch.mm) | [paddle.matmul](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/matmul_cn.html) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.mm.md) | +| 149 | [torch.mv](https://pytorch.org/docs/stable/generated/torch.mv.html?highlight=mv#torch.mv) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.mv.md) | + + + + ***持续更新...*** diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.chain_matmul.md b/docs/pytorch_project_convertor/API_docs/ops/torch.chain_matmul.md new file mode 100644 index 0000000000000000000000000000000000000000..653e8b1288dc132087567e4242a8c769c290c82b --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.chain_matmul.md @@ -0,0 +1,19 @@ +## torch.chain_matmul +### [torch.chain_matmul](https://pytorch.org/docs/stable/generated/torch.chain_matmul.html?highlight=chain_matmul#torch.chain_matmul) +```python +torch.chain_matmul(*matrices, out=None) +``` +### 功能介绍 +用于实现多个矩阵相乘,PaddlePaddle目前无对应API,可使用如下代码组合实现该API。 +```python +import paddle + +def chain_matmul(*matrices, out=None): + assert len(matrices) >= 1, "Expected one or more matrices." + if len(matrices) == 1: + return matrices[0] + out = paddle.matmul(matrices[0], matrices[1]) + for i in range(2, len(matrices)): + out = paddle.matmul(out, matrices[i]) + return out +``` \ No newline at end of file diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_inverse.md b/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_inverse.md new file mode 100644 index 0000000000000000000000000000000000000000..e0d623b4437a4e1fc3b52360886c78a9d23aa608 --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_inverse.md @@ -0,0 +1,28 @@ +## torch.cholesky_inverse +### [torch.cholesky_inverse](https://pytorch.org/docs/stable/generated/torch.cholesky_inverse.html?highlight=cholesky_inverse#torch.cholesky_inverse) +```python +torch.cholesky_inverse(input, upper=False, out=None) +``` + +### 功能介绍 +用于计算对称正定矩阵的逆矩阵,公式为: +> 当`upper`为False时, +> $inv=(uu^T)^{-1}$ ; +> 当`upper`为True时, +> $inv=(u^Tu)^{-1}$ 。 + + +PaddlePaddle目前无对应API,可使用如下代码组合实现该API。 + +```python +import paddle + +def cholesky_inverse(input, upper=False, out=None) : + u = paddle.cholesky(input, False) + ut = paddle.transpose(u, perm=[1, 0]) + if upper: + out = paddle.inverse(paddle.matmul(ut, u)) + else: + out = paddle.inverse(paddle.matmul(u, ut)) + return out +``` \ No newline at end of file diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_solve.md b/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_solve.md new file mode 100644 index 0000000000000000000000000000000000000000..c96e4c152bdbb9a55254dc549c2e6f3dc9aeb2e7 --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.cholesky_solve.md @@ -0,0 +1,28 @@ +## torch.cholesky_solve +### [torch.cholesky_solve](https://pytorch.org/docs/stable/generated/torch.cholesky_solve.html?highlight=cholesky_solve#torch.cholesky_solve) +```python +torch.cholesky_solve(input, input2, upper=False, out=None) +``` + +### 功能介绍 +用于计算对称正定矩阵的逆矩阵,并与另一个矩阵相乘,公式为: +> 当`upper`为False时, +> $inv=(uu^T)^{-1}b$ ; +> 当`upper`为True时, +> $inv=(u^Tu)^{-1}b$ 。 + +PaddlePaddle目前无对应API,可使用如下代码组合实现该API。 + +```python +import paddle + +def cholesky_solve(input, input2, upper=False, out=None) : + u = paddle.cholesky(input, False) + ut = paddle.transpose(u, perm=[1, 0]) + if upper: + out = paddle.inverse(paddle.matmul(ut, u)) + else: + out = paddle.inverse(paddle.matmul(u, ut)) + out = paddle.matmul(out, input2) + return out +``` \ No newline at end of file diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.matmul.md b/docs/pytorch_project_convertor/API_docs/ops/torch.matmul.md new file mode 100644 index 0000000000000000000000000000000000000000..98ad96f44203c5b993482ed1061177d2adbfe753 --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.matmul.md @@ -0,0 +1,19 @@ +## torch.matmul +### [torch.matmul](https://pytorch.org/docs/stable/generated/torch.matmul.html?highlight=matmul#torch.matmul) +```python +torch.matmul(input, other, out=None) +``` + +### [paddle.matmul](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/matmul_cn.html) +```python +paddle.matmul(x, y, transpose_x=False, transpose_y=False, name=None) +``` + +### 参数差异 +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------ | +| input | x | 表示输入的第一个Tensor。 | +| other | y | 表示输入的第二个Tensor。 | +| - | transpose_x | 表示相乘前是否转置x,PyTorch无此参数。 | +| - | transpose_y | 表示相乘前是否转置y,PyTorch无此参数。 | +| out | - | 表示输出的Tensor,PaddlePaddle无此参数。 | diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.mm.md b/docs/pytorch_project_convertor/API_docs/ops/torch.mm.md new file mode 100644 index 0000000000000000000000000000000000000000..f1ee788664a3937435404c39f20064105c0d5dc7 --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.mm.md @@ -0,0 +1,25 @@ +## torch.mm +### [torch.mm](https://pytorch.org/docs/stable/generated/torch.mm.html?highlight=mm#torch.mm) +```python +torch.mm(input, mat2, *, out=None) +``` +### [paddle.matmul](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/matmul_cn.html) +```python +paddle.matmul(x, y, transpose_x=False, transpose_y=False, name=None) +``` + +### 参数差异 +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------ | +| input | x | 表示输入的第一个Tensor。 | +| other | y | 表示输入的第二个Tensor。 | +| - | transpose_x | 表示相乘前是否转置x,PyTorch无此参数。 | +| - | transpose_y | 表示相乘前是否转置y,PyTorch无此参数。 | +| out | - | 表示输出的Tensor,PaddlePaddle无此参数。 | + + +### 功能差异 + +#### 计算方式 +***PyTorch***:只支持$n × m$的矩阵与$m × p$的矩阵相乘。 +***PaddlePaddle***:支持的输入与`torch.matmul`相同。 \ No newline at end of file diff --git a/docs/pytorch_project_convertor/API_docs/ops/torch.mv.md b/docs/pytorch_project_convertor/API_docs/ops/torch.mv.md new file mode 100644 index 0000000000000000000000000000000000000000..cb270e162d6ac48a4a9d81061965fefb26357b92 --- /dev/null +++ b/docs/pytorch_project_convertor/API_docs/ops/torch.mv.md @@ -0,0 +1,17 @@ +## torch.mv +### [torch.mv](https://pytorch.org/docs/stable/generated/torch.mv.html?highlight=mv#torch.mv) +```python +torch.mv(input, vec, out=None) +``` + +### 功能介绍 +用于实现矩阵(`input`,大小为$n × m$)与向量(`vec`, $m$)相乘,PaddlePaddle目前无对应API,可使用如下代码组合实现该API。 +```python +import paddle + +def mv(input, vec, out=None): + vec = paddle.unsqueeze(vec, 1) + out = paddle.matmul(input, vec) + out = paddle.squeeze(out, 1) + return out +``` \ No newline at end of file