diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cauchy_.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cauchy_.md new file mode 100644 index 00000000000..cb9ad6def9c --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cauchy_.md @@ -0,0 +1,23 @@ +## [ torch 参数更多 ]torch.Tensor.cauchy_ + +### [torch.Tensor.cauchy_](https://pytorch.org/docs/stable/generated/torch.Tensor.cauchy_.html) + +```python +torch.Tensor.cauchy_(median=0, sigma=1, *, generator=None) +``` + +### [paddle.Tensor.cauchy_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html) + +```python +paddle.Tensor.cauchy_(loc=0, scale=1, name=None) +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| --------- | ------------ | ------------------------------------------------------------------------------------ | +| median | loc | 输入 Tensor,仅参数名不一致。 | +| sigma | scale | 输入 Tensor,仅参数名不一致。 | +| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.geometric_.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.geometric_.md new file mode 100644 index 00000000000..984d011c650 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.geometric_.md @@ -0,0 +1,22 @@ +## [ 仅参数名不一致 ]torch.Tensor.geometric_ + +### [torch.Tensor.geometric_](https://pytorch.org/docs/stable/generated/torch.Tensor.geometric_.html) + +```python +torch.Tensor.geometric_(p, *, generator=None) +``` + +### [paddle.Tensor.geometric_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html) + +```python +paddle.Tensor.geometric_(probs, name=None) +``` + +两者功能一致且参数用法一致,仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ----------------------------- | +| p | probs | 输入 Tensor,仅参数名不一致。 | +| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.is_inference.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.is_inference.md new file mode 100644 index 00000000000..a5103acd85b --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.is_inference.md @@ -0,0 +1,15 @@ +## [ 无参数 ]torch.Tensor.is_inference + +### [torch.Tensor.is_inference](https://pytorch.org/docs/stable/generated/torch.Tensor.is_inference.html) + +```python +torch.Tensor.is_inference() +``` + +### [paddle.Tensor.stop_gradient]() + +```python +paddle.Tensor.stop_gradient +``` + +两者功能一致,无参数。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.random_.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.random_.md new file mode 100644 index 00000000000..a9d31e752c6 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.random_.md @@ -0,0 +1,19 @@ +## [ 组合替代实现 ] torch.Tensor.random_ + +### [torch.Tensor.random_](https://pytorch.org/docs/stable/generated/torch.Tensor.random_.html) + +```python +torch.Tensor.random_(from=0, to=None, *, generator=None) +``` + +PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。 + +### 转写示例 + +```python +# PyTorch 写法 +x.random_(from=0, to=10) + +# Paddle 写法 +paddle.assign(paddle.cast(paddle.randint(low=0, high=2, shape=x.shape), dtype='float32'), x) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.optim.DistributedOptimizer.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.optim.DistributedOptimizer.md new file mode 100644 index 00000000000..6f99245c0a8 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.optim.DistributedOptimizer.md @@ -0,0 +1,26 @@ +## [ 输入参数用法不一致 ]torch.distributed.optim.DistributedOptimizer + +### [torch.distributed.optim.DistributedOptimizer](https://pytorch.org/docs/stable/distributed.optim.html) + +```python +torch.distributed.optim.DistributedOptimizer(optimizer_class, params_rref, *args, **kwargs) +``` + +### [paddle.distributed.shard_optimizer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/shard_optimizer_cn.html) + +```python +paddle.distributed.shard_optimizer(optimizer, shard_fn=None) +``` + +其中 PyTorch 和 Paddle 功能一致,参数用法不一致,具体如下: + +### 参数映射 + + +| PyTorch | PaddlePaddle | 备注 | +| --------------- | ------------ | ----------------------------------------------------------- | +| optimizer_class | optimizer | 优化器。 | +| params_rref | - | 初始化方法,paddle 无此参数,暂无转写方式。 | +| args | - | 优化器实例化参数。 | +| kwargs | - | 优化器实例化参数 | +| - | shard_fn | 用于切分优化器状态,PyTorch 无此参数,Paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.rpc.remote.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.rpc.remote.md new file mode 100644 index 00000000000..ac63cb4daf7 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.rpc.remote.md @@ -0,0 +1,25 @@ +## [ 仅参数名不一致 ]torch.distributed.rpc.remote + +### [torch.distributed.rpc.remote](https://pytorch.org/docs/stable/rpc.html#torch.distributed.rpc.remote) + +```python +torch.distributed.rpc.remote(to, func, args=None, kwargs=None, timeout=-1.0) +``` + +### [paddle.distributed.rpc.rpc_async](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distributed/rpc/rpc_async_cn.html#rpc-async) + +```python +paddle.distributed.rpc.rpc_async(to, fn, args=None, kwargs=None, timeout=- 1) +``` + +两者功能一致且参数用法一致,仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------- | +| to | to | 目标 worker 的名字。 | +| func | fn | 一个可调用的函数,仅参数名不一致。 | +| args | args | 函数 fn 的参数。 | +| kwargs | kwargs | 函数 fn 的字典参数。 | +| timeout | timeout | RPC 调用的超时时间。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.chi2.Chi2.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.chi2.Chi2.md new file mode 100644 index 00000000000..c11d6f0f844 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.chi2.Chi2.md @@ -0,0 +1,22 @@ +## [torch 参数更多 ]torch.distributions.chi2.Chi2 + +### [torch.distributions.chi2.Chi2](https://pytorch.org/docs/stable/distributions.html#chi2) + +```python +torch.distributions.chi2.Chi2(df, validate_args=None) +``` + +### [paddle.distribution.Chi2](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distribution/Chi2_cn.html#prob-value) + +```python +paddle.distribution.Chi2(df) +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------------- | ------------ | ----------------------------------------------------------------------- | +| df | df | 表示输入的参数。 | +| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.constraints.Constraint.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.constraints.Constraint.md new file mode 100644 index 00000000000..19209bf9288 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.constraints.Constraint.md @@ -0,0 +1,15 @@ +## [ 无参数 ]torch.distributions.constraints.Constraint + +### [torch.distributions.constraints.Constraint](https://pytorch.org/docs/stable/distributions.html#module-torch.distributions.constraints) + +```python +torch.distributions.constraints.Constraint(is_discrete, event_dim) +``` + +### [paddle.distribution.constraint.Constraint](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/distribution/constraint.py) + +```python +paddle.distribution.constraint.Constraint() +``` + +功能一致,无参数。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.gamma.Gamma.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.gamma.Gamma.md new file mode 100644 index 00000000000..7f9c8175220 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.gamma.Gamma.md @@ -0,0 +1,23 @@ +## [torch 参数更多 ]torch.distributions.gamma.Gamma + +### [torch.distributions.gamma.Gamma](https://pytorch.org/docs/stable/distributions.html#gamma) + +```python +torch.distributions.gamma.Gamma(concentration, rate, validate_args=None) +``` + +### [paddle.distribution.Gamma](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distribution/Gamma_cn.html) + +```python +paddle.distribution.Gamma(concentration, rate) +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------- | +| concentration | concentration | 表示输入的参数。 | +| rate | rate | 表示输入的参数。 | +| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.lkj_cholesky.LKJCholesky.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.lkj_cholesky.LKJCholesky.md new file mode 100644 index 00000000000..e71f9981352 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.lkj_cholesky.LKJCholesky.md @@ -0,0 +1,24 @@ +## [ torch 参数更多 ]torch.distributions.lkj_cholesky.LKJCholesky + +### [torch.distributions.lkj_cholesky.LKJCholesky](https://pytorch.org/docs/stable/distributions.html#torch.distributions.lkj_cholesky.LKJCholesky) + +```python +torch.distributions.lkj_cholesky.LKJCholesky(dim, concentration=1.0, validate_args=None) +``` + +### [paddle.distribution.LKJCholesky](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/LKJCholesky_cn.html) + +```python +paddle.distribution.LKJCholesky(dim, concentration=1.0, sample_method='onion') +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | ----------------------------------------------------------------------- | +| dim | dim | 表示输入的参数。 | +| concentration | concentration | 表示输入的参数。 | +| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | +| - | sample_method | pytorch 无此参数,paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.poisson.Poisson.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.poisson.Poisson.md new file mode 100644 index 00000000000..ac0954a0c23 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.poisson.Poisson.md @@ -0,0 +1,22 @@ +## [torch 参数更多 ]torch.distributions.poisson.Poisson + +### [torch.distributions.poisson.Poisson](https://pytorch.org/docs/stable/distributions.html#poisson) + +```python +torch.distributions.poisson.Poisson(rate, validate_args=None) +``` + +### [paddle.distribution.Poisson](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Poisson_cn.html) + +```python +paddle.distribution.Poisson(rate) +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | ----------------------------------------------------------------------- | +| rate | rate | 表示输入的参数。 | +| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.studentT.StudentT.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.studentT.StudentT.md new file mode 100644 index 00000000000..819e80a5ed2 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.studentT.StudentT.md @@ -0,0 +1,24 @@ +## [torch 参数更多 ]torch.distributions.studentT.StudentT + +### [torch.distributions.studentT.StudentT](https://pytorch.org/docs/stable/distributions.html#studentt) + +```python +torch.distributions.studentT.StudentT(df, loc=0.0, scale=1.0, validate_args=None) +``` + +### [paddle.distribution.StudentT](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/StudentT_cn.html) + +```python +paddle.distribution.StudentT(df, loc, scale, name=None) +``` + +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | ----------------------------------------------------------------------- | +| df | df | 表示输入的参数。 | +| loc | loc | 表示输入的参数。 | +| scale | scale | 表示输入的参数。 | +| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.PositiveDefiniteTransform.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.PositiveDefiniteTransform.md new file mode 100644 index 00000000000..0bceabf4514 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.PositiveDefiniteTransform.md @@ -0,0 +1,26 @@ +## [ 组合替代实现 ]torch.distributions.transforms.PositiveDefiniteTransform + +### [torch.distributions.transforms.PositiveDefiniteTransform](https://pytorch.org/docs/stable/distributions.html#module-torch.distributions.transforms) + +```python +torch.distributions.transforms.PositiveDefiniteTransform(cache_size=0) +``` + +PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。 + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ---------- | ------------ | ------------------------------------------------------------------- | +| cache_size | - | 缓存大小,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# PyTorch 写法 +y = PositiveDefiniteTransform()(tensor1) + +# Paddle 写法 +T = tensor1.tril(-1) + tensor1.diagonal(-2, -1).exp().diag_embed() +y = T @ T.mT +```