diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md new file mode 100644 index 00000000000..6c40e893be0 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.Tensor.cuda + +### [torch.Tensor.cuda](https://pytorch.org/docs/1.13/generated/torch.Tensor.cuda.html#torch.Tensor.cuda) + +```python +torch.Tensor.cuda(device=None, non_blocking=False, memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.cuda](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#cuda-device-id-none-blocking-false) + +```python +paddle.Tensor.cuda(device_id=None, blocking=False) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------------------------ | +| device | device_id | 目标 GPU 设备,仅参数名不一致。 | +| non_blocking | blocking | 是否使用同步拷贝,仅参数名不一致。 | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.fmod.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.fmod.md new file mode 100644 index 00000000000..9d8b68b2988 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.fmod.md @@ -0,0 +1,21 @@ +## [参数名不一致]torch.Tensor.fmod + +### [torch.Tensor.fmod](https://pytorch.org/docs/1.13/generated/torch.Tensor.fmod.html#torch.Tensor.fmod) + +```python +torch.Tensor.fmod(divisor) +``` + +### [paddle.Tensor.mod](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#mod-y-name-none) + +```python +paddle.Tensor.mod(y, name=None) +``` + +其中功能一致, 仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ----------------------------- | +| divisor | y | 多维 Tensor,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.histogram.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.histogram.md new file mode 100644 index 00000000000..6c187c1f6c5 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.histogram.md @@ -0,0 +1,38 @@ +## [torch 参数更多]torch.Tensor.histogram + +### [torch.Tensor.histogram](https://pytorch.org/docs/1.13/generated/torch.Tensor.histogram.html#torch.Tensor.histogram) + +```python +torch.Tensor.histogram(bins, *, range=None, weight=None, density=False) +``` + +### [paddle.Tensor.histogram](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#histogram-bins-100-min-0-max-0) + +```python +paddle.Tensor.histogram(bins=100, min=0, max=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------------------------------------------------------- | +| bins | bins | 直方图 bins(直条)的个数。 | +| range | min, max | PyTorch 为 bins 的范围,类型为 float,Paddle 为 range 的下边界,上边界,类型为 int,需要进行转写。 | +| weight | - | 权重,Paddle 无此参数,暂无转写方式。 | +| density | - | 结果中每个 bin 是否包含权重数,Paddle 无此参数,暂无转写方式。 | + +### 转写示例 + +#### range 参数:bins 的范围 + +```python +# PyTorch 写法: +x = torch.tensor([1., 2, 1]) +y = x.histogram(bins=5, range=(0., 3.)) + +# Paddle 写法: +x = paddle.to_tensor([1, 2, 1]) +y = x.histogram(bins=5, min=0, max=3) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather.md new file mode 100644 index 00000000000..572c7ab26c0 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather.md @@ -0,0 +1,24 @@ +## [torch 参数更多]torch.distributed.all_gather + +### [torch.distributed.all_gather](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_gather) + +```python +torch.distributed.all_gather(tensor_list, tensor, group=None, async_op=False) +``` + +### [paddle.distributed.all_gather](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/all_gather_cn.html) + +```python +paddle.distributed.all_gather(tensor_list, tensor, group=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ----------- | ------------ | --------------------------------------------- | +| tensor_list | tensor_list | 操作的输出 Tensor 列表。 | +| tensor | tensor | 操作的输入 Tensor。 | +| group | group | 工作的进程组编号。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_reduce.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_reduce.md new file mode 100644 index 00000000000..278ab33338b --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_reduce.md @@ -0,0 +1,24 @@ +## [torch 参数更多]torch.distributed.all_reduce + +### [torch.distributed.all_reduce](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_reduce) + +```python +torch.distributed.all_reduce(tensor, op=, group=None, async_op=False) +``` + +### [paddle.distributed.all_reduce](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/all_reduce_cn.html) + +```python +paddle.distributed.all_reduce(tensor, op=ReduceOp.SUM, group=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------- | ------------ | --------------------------------------------- | +| tensor | tensor | 操作的输入 Tensor。 | +| op | op | 归约的具体操作。 | +| group | group | 工作的进程组编号。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_to_all.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_to_all.md new file mode 100644 index 00000000000..897c90adc29 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_to_all.md @@ -0,0 +1,25 @@ +## [torch 参数更多]torch.distributed.all_to_all + +### [torch.distributed.all_to_all](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.all_to_all) + +```python +torch.distributed.all_to_all(output_tensor_list, input_tensor_list, group=None, async_op=False) +``` + +### [paddle.distributed.alltoall](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/alltoall_cn.html) + +```python +paddle.distributed.alltoall(in_tensor_list, out_tensor_list, group=None, use_calc_stream=True) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------------ | --------------- | ----------------------------------------------------------------- | +| output_tensor_list | out_tensor_list | 包含所有输出 Tensors 的一个列表,仅参数名不一致。 | +| input_tensor_list | in_tensor_list | 包含所有输入 Tensors 的一个列表,仅参数名不一致。 | +| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | +| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.broadcast.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.broadcast.md new file mode 100644 index 00000000000..8cdc2bb727d --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.broadcast.md @@ -0,0 +1,24 @@ +## [torch 参数更多]torch.distributed.broadcast + +### [torch.distributed.broadcast](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.broadcast) + +```python +torch.distributed.broadcast(tensor, src, group=None, async_op=False) +``` + +### [paddle.distributed.broadcast](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/broadcast_cn.html) + +```python +paddle.distributed.broadcast(tensor, src, group=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------- | ------------ | ------------------------------------------------------------------------------------------------------ | +| tensor | tensor | 如果当前进程编号是源,那么这个 Tensor 变量将被发送给其他进程,否则这个 Tensor 将接收源发送过来的数据。 | +| src | src | 发送源的进程编号。 | +| group | group | 工作的进程组编号。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.recv.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.recv.md new file mode 100644 index 00000000000..62bddeaf9c5 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.recv.md @@ -0,0 +1,25 @@ +## [torch 参数更多]torch.distributed.recv + +### [torch.distributed.recv](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.recv) + +```python +torch.distributed.recv(tensor, src=None, group=None, tag=0) +``` + +### [paddle.distributed.recv](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/recv_cn.html) + +```python +paddle.distributed.recv(tensor, src=0, group=None, use_calc_stream=True) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | --------------- | ----------------------------------------------------------------- | +| tensor | tensor | 接收数据的 Tensor。 | +| src | src | 发送者的标识符。 | +| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 | +| tag | - | 匹配接收标签,Paddle 无此参数,暂无转写方式。 | +| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.reduce.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.reduce.md new file mode 100644 index 00000000000..2c66881fe69 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.reduce.md @@ -0,0 +1,25 @@ +## [torch 参数更多]torch.distributed.reduce + +### [torch.distributed.reduce](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.reduce) + +```python +torch.distributed.reduce(tensor, dst, op=, group=None, async_op=False) +``` + +### [paddle.distributed.reduce](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/reduce_cn.html) + +```python +paddle.distributed.reduce(tensor, dst, op=ReduceOp.SUM, group=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------- | ------------ | --------------------------------------------- | +| tensor | tensor | 操作的输入 Tensor。 | +| dst | dst | 返回操作结果的目标进程编号。 | +| op | op | 归约的具体操作。 | +| group | group | 工作的进程组编号。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.scatter.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.scatter.md new file mode 100644 index 00000000000..b8fc723286e --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.scatter.md @@ -0,0 +1,25 @@ +## [torch 参数更多]torch.distributed.scatter + +### [torch.distributed.scatter](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.scatter) + +```python +torch.distributed.scatter(tensor, scatter_list=None, src=0, group=None, async_op=False) +``` + +### [paddle.distributed.scatter](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/scatter_cn.html) + +```python +paddle.distributed.scatter(tensor, tensor_list=None, src=0, group=0) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------ | ------------ | --------------------------------------------- | +| tensor | tensor | 操作的输出 Tensor。 | +| scatter_list | tensor_list | 操作的输入 Tensor 列表,仅参数名不一致。 | +| src | src | 操作的源进程号。 | +| group | group | 工作的进程组编号。 | +| async_op | - | 是否异步操作,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.send.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.send.md new file mode 100644 index 00000000000..9fcff349218 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.send.md @@ -0,0 +1,25 @@ +## [torch 参数更多]torch.distributed.send + +### [torch.distributed.send](https://pytorch.org/docs/1.13/distributed.html#torch.distributed.send) + +```python +torch.distributed.send(tensor, dst, group=None, tag=0) +``` + +### [paddle.distributed.send](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/send_cn.html) + +```python +paddle.distributed.send(tensor, dst=0, group=None, use_calc_stream=True) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | --------------- | ----------------------------------------------------------------- | +| tensor | tensor | 需要发送的 Tensor。 | +| dst | dst | 接收者的标识符。 | +| group | group | new_group 返回的 Group 实例,或者设置为 None 表示默认地全局组。 | +| tag | - | 匹配接收标签,Paddle 无此参数,暂无转写方式。 | +| - | use_calc_stream | 标识使用计算流还是通信流,PyTorch 无此参数,Paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.categorical.Categorical.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.categorical.Categorical.md new file mode 100644 index 00000000000..41c9b7e6e07 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.categorical.Categorical.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.categorical.Categorical + +### [torch.distributions.categorical.Categorical](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.categorical.Categorical) + +```python +torch.distributions.categorical.Categorical(probs=None, logits=None, validate_args=None) +``` + +### [paddle.distribution.Categorical](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Categorical_cn.html) + +```python +paddle.distribution.Categorical(logits, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | --------------------------------------------- | +| probs | - | 事件概率,Paddle 无此参数,暂无转写方式。 | +| logits | logits | 类别分布对应的 logits。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.dirichlet.Dirichlet.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.dirichlet.Dirichlet.md new file mode 100644 index 00000000000..2223ca8228f --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.dirichlet.Dirichlet.md @@ -0,0 +1,22 @@ +## [torch 参数更多]torch.distributions.dirichlet.Dirichlet + +### [torch.distributions.dirichlet.Dirichlet](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.dirichlet.Dirichlet) + +```python +torch.distributions.dirichlet.Dirichlet(concentration, validate_args=None) +``` + +### [paddle.distribution.Dirichlet](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Dirichlet_cn.html) + +```python +paddle.distribution.Dirichlet(concentration) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | --------------------------------------------- | +| concentration | concentration | 浓度参数,即公式中 α 参数。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.distribution.Distribution.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.distribution.Distribution.md new file mode 100644 index 00000000000..5fdf5264c9e --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.distribution.Distribution.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.distribution.Distribution + +### [torch.distributions.distribution.Distribution](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.distribution.Distribution) + +```python +torch.distributions.distribution.Distribution(batch_shape=torch.Size([]), event_shape=torch.Size([]), validate_args=None) +``` + +### [paddle.distribution.Distribution](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Distribution_cn.html) + +```python +paddle.distribution.Distribution(batch_shape, event_shape) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | --------------------------------------------- | +| batch_shape | batch_shape | 概率分布参数批量形状。 | +| event_shape | event_shape | 多元概率分布维数形状。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.exp_family.ExponentialFamily.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.exp_family.ExponentialFamily.md new file mode 100644 index 00000000000..7b075c1f704 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.exp_family.ExponentialFamily.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.exp_family.ExponentialFamily + +### [torch.distributions.exp_family.ExponentialFamily](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.exp_family.ExponentialFamily) + +```python +torch.distributions.exp_family.ExponentialFamily(batch_shape=torch.Size([]), event_shape=torch.Size([]), validate_args=None) +``` + +### [paddle.distribution.ExponentialFamily](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/ExponentialFamily_cn.html) + +```python +paddle.distribution.ExponentialFamily(batch_shape, event_shape) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | --------------------------------------------- | +| batch_shape | batch_shape, | 概率分布参数批量形状。 | +| event_shape | event_shape | 多元概率分布维数形状。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.independent.Independent.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.independent.Independent.md new file mode 100644 index 00000000000..57d986ea64c --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.independent.Independent.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.independent.Independent + +### [torch.distributions.independent.Independent](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.independent.Independent) + +```python +torch.distributions.independent.Independent(base_distribution, reinterpreted_batch_ndims, validate_args=None) +``` + +### [paddle.distribution.Independent](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Independent_cn.html) + +```python +paddle.distribution.Independent(base, reinterpreted_batch_rank) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------------------- | ------------------------ | ------------------------------------------------ | +| base_distribution | base | 基础分布,仅参数名不一致。 | +| reinterpreted_batch_ndims | reinterpreted_batch_rank | 用于转换为事件维度的批维度数量,仅参数名不一致。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.multinomial.Multinomial.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.multinomial.Multinomial.md new file mode 100644 index 00000000000..0c01800d1b5 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.multinomial.Multinomial.md @@ -0,0 +1,24 @@ +## [torch 参数更多]torch.distributions.multinomial.Multinomial + +### [torch.distributions.multinomial.Multinomial](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.multinomial.Multinomial) + +```python +torch.distributions.multinomial.Multinomial(total_count=1, probs=None, logits=None, validate_args=None) +``` + +### [paddle.distribution.Multinomial](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Multinomial_cn.html) + +```python +paddle.distribution.Multinomial(total_count, probs) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ---------------------------------------------- | +| total_count | total_count | 实验次数。 | +| probs | probs | 每个类别发生的概率。 | +| logits | - | 事件 log 概率,Paddle 无此参数,暂无转写方式。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.normal.Normal.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.normal.Normal.md new file mode 100644 index 00000000000..c833a67111a --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.normal.Normal.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.normal.Normal + +### [torch.distributions.normal.Normal](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.normal.Normal) + +```python +torch.distributions.normal.Normal(loc, scale, validate_args=None) +``` + +### [paddle.distribution.Normal](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Normal_cn.html) + +```python +paddle.distribution.Normal(loc, scale, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | --------------------------------------------- | +| loc | loc | 正态分布平均值。 | +| scale | scale | 正态分布标准差。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.IndependentTransform.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.IndependentTransform.md new file mode 100644 index 00000000000..da1133ba056 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.IndependentTransform.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.transforms.IndependentTransform + +### [torch.distributions.transforms.IndependentTransform](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.transforms.IndependentTransform) + +```python +torch.distributions.transforms.IndependentTransform(base_transform, reinterpreted_batch_ndims, cache_size=0) +``` + +### [paddle.distribution.IndependentTransform](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/IndependentTransform_cn.html) + +```python +paddle.distribution.IndependentTransform(base, reinterpreted_batch_rank) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------------------- | ------------------------ | ---------------------------------------------------- | +| base_transform | base | 基础变换,仅参数名不一致。 | +| reinterpreted_batch_ndims | reinterpreted_batch_rank | 被扩展为事件维度的最右侧批维度数量,仅参数名不一致。 | +| cache_size | - | cache 大小,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.ReshapeTransform.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.ReshapeTransform.md new file mode 100644 index 00000000000..856182457c3 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.transforms.ReshapeTransform.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.transforms.ReshapeTransform + +### [torch.distributions.transforms.ReshapeTransform](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.transforms.ReshapeTransform) + +```python +torch.distributions.transforms.ReshapeTransform(in_shape, out_shape, cache_size=0) +``` + +### [paddle.distribution.ReshapeTransform](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/ReshapeTransform_cn.html) + +```python +paddle.distribution.ReshapeTransform(in_event_shape, out_event_shape) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ---------- | --------------- | ------------------------------------------- | +| in_shape | in_event_shape | Reshape 前的事件形状,仅参数名不一致。 | +| out_shape | out_event_shape | Reshape 后的事件形状,仅参数名不一致。 | +| cache_size | - | cache 大小,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.uniform.Uniform.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.uniform.Uniform.md new file mode 100644 index 00000000000..9c498058b78 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.uniform.Uniform.md @@ -0,0 +1,23 @@ +## [torch 参数更多]torch.distributions.uniform.Uniform + +### [torch.distributions.uniform.Uniform](https://pytorch.org/docs/1.13/distributions.html#torch.distributions.uniform.Uniform) + +```python +torch.distributions.uniform.Uniform(low, high, validate_args=None) +``` + +### [paddle.distribution.Uniform](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distribution/Uniform_cn.html) + +```python +paddle.distribution.Uniform(low, high, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | --------------------------------------------- | +| low | low | 均匀分布的下边界。 | +| high | high | 均匀分布的上边界。 | +| validate_args | - | 有效参数列表,Paddle 无此参数,暂无转写方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gelu.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gelu.md new file mode 100644 index 00000000000..20603b5950d --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gelu.md @@ -0,0 +1,36 @@ +## [参数不一致]torch.nn.functional.gelu + +### [torch.nn.functional.gelu](https://pytorch.org/docs/1.13/generated/torch.nn.functional.gelu.html#torch.nn.functional.gelu) + +```python +torch.nn.functional.gelu(input, approximate='none') +``` + +### [paddle.nn.functional.gelu](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/gelu_cn.html) + +```python +paddle.nn.functional.gelu(x, approximate=False, name=None) +``` + +其中功能一致, 输入参数用法不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ----------- | ------------ | ------------------------------------------------------------------------------------ | +| input | x | 输入的 Tensor,仅参数名不一致。 | +| approximate | approximate | 是否使用近似计算,PyTorch 取值 none 和 tanh,Paddle 取值为 bool 类型,需要进行转写。 | + +### 转写示例 + +#### approximate 参数:是否使用近似计算 + +```python +# PyTorch 写法: +y1 = torch.nn.functional.gelu(x, approximate='tanh') +y2 = torch.nn.functional.gelu(x, approximate='none') + +# Paddle 写法: +y1 = paddle.nn.functional.gelu(x, approximate=True) +y2 = paddle.nn.functional.gelu(x, approximate=False) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.unfold.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.unfold.md new file mode 100644 index 00000000000..f572d9aff27 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.unfold.md @@ -0,0 +1,25 @@ +## [参数名不一致]torch.nn.functional.unfold + +### [torch.nn.functional.unfold](https://pytorch.org/docs/1.13/generated/torch.nn.functional.unfold.html#torch.nn.functional.unfold) + +```python +torch.nn.functional.unfold(input, kernel_size, dilation=1, padding=0, stride=1) +``` + +### [paddle.nn.functional.unfold](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/unfold_cn.html) + +```python +paddle.nn.functional.unfold(x, kernel_size, strides=1, paddings=0, dilation=1, name=None) +``` + +其中功能一致, 仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ----------- | ------------ | --------------------------------- | +| input | x | 输入 4-D Tensor,仅参数名不一致。 | +| kernel_size | kernel_size | 卷积核的尺寸。 | +| dilation | dilation | 卷积膨胀。 | +| padding | paddings | 每个维度的扩展,仅参数名不一致。 | +| stride | strides | 卷积步长,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.cond.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.cond.md new file mode 100644 index 00000000000..cce7bc965b7 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.cond.md @@ -0,0 +1,35 @@ +## [torch 参数更多]torch.linalg.cond + +### [torch.linalg.cond](https://pytorch.org/docs/1.13/generated/torch.linalg.cond.html#torch.linalg.cond) + +```python +torch.linalg.cond(A, p=None, *, out=None) +``` + +### [paddle.linalg.cond](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/cond_cn.html) + +```python +paddle.linalg.cond(x, p=None, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| p | p | 范数种类。 | +| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.cond(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.cond(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigh.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigh.md new file mode 100644 index 00000000000..dcc40984947 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigh.md @@ -0,0 +1,35 @@ +## [torch 参数更多]torch.linalg.eigh + +### [torch.linalg.eigh](https://pytorch.org/docs/1.13/generated/torch.linalg.eigh.html#torch.linalg.eigh) + +```python +torch.linalg.eigh(A, UPLO='L', *, out=None) +``` + +### [paddle.linalg.eigh](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/eigh_cn.html) + +```python +paddle.linalg.eigh(x, UPLO='L', name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| UPLO | UPLO | 表示计算上三角或者下三角矩阵 | +| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.eigh(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.eigh(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigvalsh.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigvalsh.md new file mode 100644 index 00000000000..fe44c3d6445 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.eigvalsh.md @@ -0,0 +1,35 @@ +## [torch 参数更多]torch.linalg.eigvalsh + +### [torch.linalg.eigvalsh](https://pytorch.org/docs/1.13/generated/torch.linalg.eigvalsh.html#torch.linalg.eigvalsh) + +```python +torch.linalg.eigvalsh(A, UPLO='L', *, out=None) +``` + +### [paddle.linalg.eigvalsh](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/eigvalsh_cn.html) + +```python +paddle.linalg.eigvalsh(x, UPLO='L', name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| UPLO | UPLO | 表示计算上三角或者下三角矩阵 | +| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.eigvalsh(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.eigvalsh(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.inv.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.inv.md new file mode 100644 index 00000000000..30655a116f7 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.inv.md @@ -0,0 +1,34 @@ +## [torch 参数更多]torch.linalg.inv + +### [torch.linalg.inv](https://pytorch.org/docs/1.13/generated/torch.linalg.inv.html#torch.linalg.inv) + +```python +torch.linalg.inv(A, *, out=None) +``` + +### [paddle.linalg.inv](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/inv_cn.html) + +```python +paddle.linalg.inv(x, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.inv(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.inv(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matmul.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matmul.md new file mode 100644 index 00000000000..04636d429f8 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matmul.md @@ -0,0 +1,37 @@ +## [torch 参数更多]torch.linalg.matmul + +### [torch.linalg.matmul](https://pytorch.org/docs/1.13/generated/torch.linalg.matmul.html#torch.linalg.matmul) + +```python +torch.linalg.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 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | --------------------------------------------------------- | +| input | x | 输入变量,仅参数名不一致。 | +| other | y | 输入变量,仅参数名不一致。 | +| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | +| - | transpose_x | 相乘前是否转置 x,PyTorch 无此参数,Paddle 保持默认即可。 | +| - | transpose_y | 相乘前是否转置 y,PyTorch 无此参数,Paddle 保持默认即可。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.matmul(x1, x2, out=y) + +# Paddle 写法: +paddle.assign(paddle.matmul(x1, x2), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.pinv.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.pinv.md new file mode 100644 index 00000000000..f9c6b263282 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.pinv.md @@ -0,0 +1,37 @@ +## [torch 参数更多]torch.linalg.pinv + +### [torch.linalg.pinv](https://pytorch.org/docs/1.13/generated/torch.linalg.pinv.html#torch.linalg.pinv) + +```python +torch.linalg.pinv(A, *, atol=None, rtol=None, hermitian=False, out=None) +``` + +### [paddle.linalg.pinv](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/pinv_cn.html) + +```python +paddle.linalg.pinv(x, rcond=1e-15, hermitian=False, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| --------- | ------------ | -------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| atol | - | 绝对阈值,Paddle 无此参数,暂无转写方式。 | +| rtol | rcond | 奇异值(特征值)被截断的阈值,仅参数名不一致。 | +| hermitian | hermitian | 是否为 hermitian 矩阵或者实对称矩阵。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.pinv(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.pinv(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.qr.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.qr.md new file mode 100644 index 00000000000..5eb22e9a522 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.qr.md @@ -0,0 +1,35 @@ +## [torch 参数更多]torch.linalg.qr + +### [torch.linalg.qr](https://pytorch.org/docs/1.13/generated/torch.linalg.qr.html#torch.linalg.qr) + +```python +torch.linalg.qr(A, mode='reduced', *, out=None) +``` + +### [paddle.linalg.qr](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/qr_cn.html) + +```python +paddle.linalg.qr(x, mode='reduced', name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------- | +| A | x | 输入 Tensor,仅参数名不一致。 | +| mode | mode | 控制正交三角分解的行为。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.qr(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.qr(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.solve.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.solve.md new file mode 100644 index 00000000000..a2aaffe7fe2 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.solve.md @@ -0,0 +1,36 @@ +## [torch 参数更多]torch.linalg.solve + +### [torch.linalg.solve](https://pytorch.org/docs/1.13/generated/torch.linalg.solve.html#torch.linalg.solve) + +```python +torch.linalg.solve(A, B, *, left=True, out=None) +``` + +### [paddle.linalg.solve](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/solve_cn.html) + +```python +paddle.linalg.solve(x, y, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ------------------------------------------------------------ | +| A | x | 输入线性方程组求解的一个或一批方阵,仅参数名不一致。 | +| B | y | 输入线性方程组求解的右值,仅参数名不一致。 | +| left | - | 是否求解 AX = B 或 XA = B,Paddle 无此参数,暂无转写方式。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.linalg.solve(x1, x2, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.solve(x1, x2), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GELU.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GELU.md new file mode 100644 index 00000000000..575e58142e9 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GELU.md @@ -0,0 +1,43 @@ +## [参数不一致]torch.nn.GELU + +### [torch.nn.GELU](https://pytorch.org/docs/1.13/generated/torch.nn.GELU.html#torch.nn.GELU) + +```python +torch.nn.GELU(approximate='none') +``` + +### [paddle.nn.GELU](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/GELU_cn.html) + +```python +paddle.nn.GELU(approximate=False, name=None) +``` + +其中功能一致, 输入参数用法不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ----------- | ------------ | ------------------------------------------------------------------------------------ | +| approximate | approximate | 是否使用近似计算,PyTorch 取值 none 和 tanh,Paddle 取值为 bool 类型,需要进行转写。 | + +### 转写示例 + +#### approximate 参数:是否使用近似计算 + +```python +# 取值为 tanh,PyTorch 写法: +m = torch.nn.GELU(approximate='tanh') +y = m(x) + +# Paddle 写法: +m = paddle.nn.GELU(approximate=True) +y = m(x) + +# 取值为 none,PyTorch 写法: +m = torch.nn.GELU(approximate='none') +y = m(x) + +# Paddle 写法: +m = paddle.nn.GELU(approximate=False) +y = m(x) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.InstanceNorm3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.InstanceNorm3d.md new file mode 100644 index 00000000000..3b6bdb8287f --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.InstanceNorm3d.md @@ -0,0 +1,69 @@ +## [torch 参数更多]torch.nn.InstanceNorm3d + +### [torch.nn.InstanceNorm3d](https://pytorch.org/docs/1.13/generated/torch.nn.InstanceNorm3d.html#torch.nn.InstanceNorm3d) + +```python +torch.nn.InstanceNorm3d(num_features, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False, device=None, dtype=None) +``` + +### [paddle.nn.InstanceNorm3D](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/InstanceNorm3D_cn.html) + +```python +paddle.nn.InstanceNorm3D(num_features, epsilon=1e-05, momentum=0.9, weight_attr=None, bias_attr=None, data_format="NCDHW", name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------------- | ------------ | --------------------------------------------------------------- | +| num_features | num_features | 输入 Tensor 的通道数量。 | +| eps | epsilon | 为了数值稳定加在分母上的值,仅参数名不一致。 | +| momentum | momentum | 此值用于计算 moving_mean 和 moving_var。 | +| affine | - | 是否进行仿射变换,Paddle 无此参数,需要进行转写。 | +| track_running_stats | - | 是否跟踪运行统计,Paddle 无此参数,暂无转写方式。 | +| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要进行转写。 | +| dtype | - | 参数类型,Paddle 无此参数,需要进行转写。 | +| - | weight_attr | 指定权重参数属性的对象,PyTorch 无此参数,Paddle 保持默认即可。 | +| - | bias_attr | 指定偏置参数属性的对象,PyTorch 无此参数,Paddle 保持默认即可。 | +| - | data_format | 指定输入数据格式,PyTorch 无此参数,Paddle 保持默认即可。 | + +### 转写示例 + +#### affine:是否进行仿射变换 + +```python +# 当 PyTorch 的 affine 为`False`,表示 weight 和 bias 不进行更新,torch 写法 +torch.nn.InstanceNorm3d(num_features, affine=False) + +# paddle 写法 +paddle.nn.InstanceNorm3d(num_features, weight_attr=False, bias_attr=False) + +# 当 PyTorch 的 affine 为`True`,torch 写法 +torch.nn.InstanceNorm3d(num_features, affine=True) + +# paddle 写法 +paddle.nn.InstanceNorm3d(num_features) +``` + +#### device 参数:表示 Tensor 存放设备位置 + +```python +# PyTorch 写法: +torch.nn.InstanceNorm3d(x, device=torch.device('cpu')) + +# Paddle 写法: +y = paddle.nn.InstanceNorm3D(x) +y.cpu() +``` + +#### dtype 参数:参数类型 + +```python +# PyTorch 写法: +torch.nn.InstanceNorm3d(x, dtype=torch.float32) + +# Paddle 写法: +paddle.nn.InstanceNorm3D(x).astype(paddle.float32) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Sequential.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Sequential.md new file mode 100644 index 00000000000..7d0a67858a1 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Sequential.md @@ -0,0 +1,21 @@ +## [参数用法不一致]torch.nn.Sequential + +### [torch.nn.Sequential](https://pytorch.org/docs/1.13/generated/torch.nn.Sequential.html#torch.nn.Sequential) + +```python +torch.nn.Sequential(arg: OrderedDict[str, Module]) +``` + +### [paddle.nn.Sequential](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Sequential_cn.html) + +```python +paddle.nn.Sequential(*layers) +``` + +其中功能一致, 参数用法不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ------------------------------------------------------------------------------------------ | +| arg | layers | Paddle 支持 Layers 或可迭代的 name Layer 对,PyTorch 支持类型更多,包含 OrderedDict 类型。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.broadcast_shapes.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.broadcast_shapes.md new file mode 100644 index 00000000000..3b4977ef6ae --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.broadcast_shapes.md @@ -0,0 +1,33 @@ +## [参数不一致]torch.broadcast_shapes + +### [torch.broadcast_shapes](https://pytorch.org/docs/1.13/generated/torch.broadcast_shapes.html#torch.broadcast_shapes) + +```python +torch.broadcast_shapes(*shapes) +``` + +### [paddle.broadcast_shape](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/broadcast_shape_cn.html) + +```python +paddle.broadcast_shape(x_shape, y_shape) +``` + +其中功能一致, 参数用法不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------- | ---------------- | --------------------------------------------------------------------------------------------------------- | +| \*shapes | x_shape, y_shape | 输入 Tensor 的 shape,输入参数数量不一致,PyTorch 可以输入多项,Paddle 输入为两项,需要多次调用进行转写。 | + +### 转写示例 + +#### shapes 参数:输入 Tensor 的 shape + +```python +# PyTorch 写法: +torch.broadcast_shapes(x1, x2, x3) + +# Paddle 写法: +paddle.broadcast_shape(paddle.broadcast_shape(x1, x2), x3) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.concat.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.concat.md new file mode 100644 index 00000000000..112b6abab7c --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.concat.md @@ -0,0 +1,35 @@ +## [torch 参数更多]torch.concat + +### [torch.concat](https://pytorch.org/docs/1.13/generated/torch.concat.html#torch.concat) + +```python +torch.concat(tensors, dim=0, *, out=None) +``` + +### [paddle.concat](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/concat_cn.html) + +```python +paddle.concat(x, axis=0, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------------- | +| tensors | x | 待联结的 Tensor list 或者 Tensor tuple,仅参数名不一致。 | +| dim | axis | 指定对输入 x 进行运算的轴,仅参数名不一致。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.concat(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.concat(x), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.einsum.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.einsum.md new file mode 100644 index 00000000000..824f7b4c473 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.einsum.md @@ -0,0 +1,22 @@ +## [参数完全一致]torch.einsum + +### [torch.einsum](https://pytorch.org/docs/1.13/generated/torch.einsum.html#torch.einsum) + +```python +torch.einsum(equation, *operands) +``` + +### [paddle.einsum](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/einsum_cn.html) + +```python +paddle.einsum(equation, *operands) +``` + +其中功能一致, 参数完全一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| -------- | ------------ | ---------- | +| equation | equation | 求和标记。 | +| operands | operands | 输入张量。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.triangular_solve.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.triangular_solve.md new file mode 100644 index 00000000000..039f2d812f5 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.triangular_solve.md @@ -0,0 +1,38 @@ +## [torch 参数更多]torch.triangular_solve + +### [torch.triangular_solve](https://pytorch.org/docs/1.13/generated/torch.triangular_solve.html#torch.triangular_solve) + +```python +torch.triangular_solve(b, A, upper=True, transpose=False, unitriangular=False, *, out=None) +``` + +### [paddle.linalg.triangular_solve](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/triangular_solve_cn.html) + +```python +paddle.linalg.triangular_solve(x, y, upper=True, transpose=False, unitriangular=False, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------- | ----------------------------------------------------------- | +| A | x | 线性方程组左边的系数方阵,仅参数名不一致。 | +| b | y | 线性方程组右边的矩阵,仅参数名不一致。 | +| upper | upper | 对系数矩阵 x 取上三角还是下三角。 | +| transpose | transpose | 是否对系数矩阵 x 进行转置。 | +| unitriangular | unitriangular | 如果为 True,则将系数矩阵 x 对角线元素假设为 1 来求解方程。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.triangular_solve(x2, x1, out=y) + +# Paddle 写法: +paddle.assign(paddle.linalg.triangular_solve(x1, x2), y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.log_softmax.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.log_softmax.md new file mode 100644 index 00000000000..1a463969169 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.log_softmax.md @@ -0,0 +1,23 @@ +## [参数名不一致]torch.special.log_softmax + +### [torch.special.log_softmax](https://pytorch.org/docs/1.13/special.html#torch.special.log_softmax) + +```python +torch.special.log_softmax(input, dim, *, dtype=None) +``` + +### [paddle.nn.functional.log_softmax](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/log_softmax_cn.html) + +```python +paddle.nn.functional.log_softmax(x, axis=- 1, dtype=None, name=None) +``` + +其中功能一致, 仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ------------------------------------------- | +| input | x | 输入的 Tensor,仅参数名不一致。 | +| dim | axis | 指定对输入 x 进行运算的轴,仅参数名不一致。 | +| dtype | dtype | 输出 Tensor 的数据类型。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.round.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.round.md new file mode 100644 index 00000000000..ab8d38347ee --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.round.md @@ -0,0 +1,34 @@ +## [torch 参数更多]torch.special.round + +### [torch.special.round](https://pytorch.org/docs/1.13/special.html#torch.special.round) + +```python +torch.special.round(input, *, out=None) +``` + +### [paddle.round](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/round_cn.html) + +```python +paddle.round(x, name=None) +``` + +其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------- | +| input | x | 输入的 Tensor,仅参数名不一致。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out 参数:输出的 Tensor + +```python +# PyTorch 写法: +torch.special.round(x, out=y) + +# Paddle 写法: +paddle.assign(paddle.round(x), y) +```