From 53c6021391de649239aa59b8cef608e0081cd220 Mon Sep 17 00:00:00 2001 From: wenyin Date: Fri, 5 May 2023 22:24:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=96=87=E6=A1=A3=20No.?= =?UTF-8?q?=2059?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tensor/torch.Tensor.bernoulli.md | 33 +++++++++++++++++++ .../Tensor/torch.Tensor.bfloat16.md | 33 +++++++++++++++++++ .../Tensor/torch.Tensor.bool.md | 33 +++++++++++++++++++ .../Tensor/torch.Tensor.byte.md | 33 +++++++++++++++++++ .../Tensor/torch.Tensor.char.md | 31 +++++++++++++++++ .../Tensor/torch.Tensor.clone.md | 21 ++++++++++++ .../api_difference/Tensor/torch.Tensor.div.md | 22 +++++++++++++ .../Tensor/torch.Tensor.divide.md | 22 +++++++++++++ .../Tensor/torch.Tensor.double.md | 31 +++++++++++++++++ 9 files changed, 259 insertions(+) create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md new file mode 100644 index 00000000000..213390e11d1 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md @@ -0,0 +1,33 @@ +## [ torch 参数更多 ] torch.Tensor.bernoulli + +### [torch.Tensor.bernoulli](https://pytorch.org/docs/stable/generated/torch.Tensor.bernoulli.html#torch-tensor-bernoulli) + +```python +torch.Tensor.bernoulli(*, generator=None) +``` + +### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bernoulli_cn.html#bernoulli) + +```python +paddle.bernoulli(x, name=None) +``` + +其中 torch 是类成员函数,而 paddle 是非类成员函数,因此第一个参数 `x` 不进行对比,Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.tensor([0.2, 0.6, 0.8]) +y = x.bernoulli() + +# paddle 写法 +x = paddle.to_tensor([0.2, 0.6, 0.8]) +y = paddle.bernoulli(x) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md new file mode 100644 index 00000000000..6c3f0481be3 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md @@ -0,0 +1,33 @@ +## [ torch 参数更多 ] torch.Tensor.bfloat16 + +### [torch.Tensor.bfloat16](https://pytorch.org/docs/stable/generated/torch.Tensor.bfloat16.html#torch-tensor-bfloat16) + +```python +torch.Tensor.bfloat16(memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) + +```python +paddle.Tensor.astype('bfloat16') +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.randn(3, 3) +y = x.bfloat16() + +# paddle 写法 +x = paddle.randn([3, 3]) +y = x.astype('bfloat16') +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md new file mode 100644 index 00000000000..8ad7979e7ab --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md @@ -0,0 +1,33 @@ +## [ torch 参数更多 ] torch.Tensor.bool + +### [torch.Tensor.bool](https://pytorch.org/docs/stable/generated/torch.Tensor.bool.html#torch.Tensor.bool) + +```python +torch.Tensor.bool(memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) + +```python +paddle.Tensor.astype('bool') +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.tensor([-1, 0, 1]) +y = x.bool() + +# paddle 写法 +x = paddle.to_tensor([-1, 0, 1]) +y = x.astype('bool') +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md new file mode 100644 index 00000000000..8603f70f059 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md @@ -0,0 +1,33 @@ +## [ torch 参数更多 ] torch.Tensor.byte + +### [torch.Tensor.byte](https://pytorch.org/docs/stable/generated/torch.Tensor.byte.html#torch.Tensor.byte) + +```python +torch.Tensor.byte(memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) + +```python +paddle.Tensor.astype('uint8') +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.tensor([0, 1, 2, 3]) +y = x.byte() + +# paddle 写法 +x = paddle.to_tensor([0, 1, 2, 3]) +y = x.astype('uint8') +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md new file mode 100644 index 00000000000..98956f89a62 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md @@ -0,0 +1,31 @@ +## [ torch 参数更多 ] torch.Tensor.char + +### [torch.Tensor.char](https://pytorch.org/docs/stable/generated/torch.Tensor.char.html#torch-tensor-char) + +```python +torch.Tensor.char(memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) + +```python +paddle.Tensor.astype('int8') +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x.char() + +# paddle 写法 +x.astype('int8') +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md new file mode 100644 index 00000000000..b0e73b6c357 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md @@ -0,0 +1,21 @@ +## [ torch 参数更多 ] torch.Tensor.clone + +### [torch.Tensor.clone](https://pytorch.org/docs/stable/generated/torch.Tensor.clone.html#torch.Tensor.clone) + +```python +torch.Tensor.clone(*, memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.clone](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#clone) + +```python +paddle.Tensor.clone() +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md new file mode 100644 index 00000000000..b00bf87b22d --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md @@ -0,0 +1,22 @@ +## [ torch 参数更多 ] torch.Tensor.div + +### [torch.Tensor.div](https://pytorch.org/docs/stable/generated/torch.Tensor.div.html#torch.Tensor.div) + +```python +torch.Tensor.div(other, *, rounding_mode=None) +``` + +### [paddle.Tensor.divide](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#divide-y-name-none) + +```python +paddle.Tensor.divide(y, name=None) +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| other | y | 表示输入的 Tensor ,仅参数名不一致。 | +| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(截断)。Paddle 无此功能,暂无转写方式。| diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md new file mode 100644 index 00000000000..de4fdf3721d --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md @@ -0,0 +1,22 @@ +## [ torch 参数更多 ] torch.Tensor.divide + +### [torch.Tensor.divide](https://pytorch.org/docs/stable/generated/torch.Tensor.divide.html#torch-tensor-divide) + +```python +torch.Tensor.divide(other, *, rounding_mode=None) +``` + +### [paddle.Tensor.divide](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#divide-y-name-none) + +```python +paddle.Tensor.divide(y, name=None) +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| other | y | 表示输入的 Tensor ,仅参数名不一致。 | +| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(截断)。Paddle 无此功能,暂无转写方式。| diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md new file mode 100644 index 00000000000..c1270765eea --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md @@ -0,0 +1,31 @@ +## [ torch 参数更多 ] torch.Tensor.double + +### [torch.Tensor.double](https://pytorch.org/docs/stable/generated/torch.Tensor.char.html#torch-tensor-char) + +```python +torch.Tensor.double(memory_format=torch.preserve_format) +``` + +### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) + +```python +paddle.Tensor.astype('float64') +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ----------------------------------------------------------------------------------- | +| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | + +### 转写示例 + +```python +# torch 写法 +x.double() + +# paddle 写法 +x.astype('float64') +``` From 10933d54915dc7f01575a4c43982cbbb0afed2b4 Mon Sep 17 00:00:00 2001 From: wenyin Date: Sat, 6 May 2023 20:34:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=96=87=E6=A1=A3=20No.?= =?UTF-8?q?=2059?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tensor/torch.Tensor.bernoulli.md | 4 ++-- .../Tensor/torch.Tensor.bfloat16.md | 2 +- .../Tensor/torch.Tensor.bool.md | 2 +- .../Tensor/torch.Tensor.byte.md | 2 +- .../Tensor/torch.Tensor.char.md | 2 +- .../Tensor/torch.Tensor.clone.md | 2 +- .../api_difference/Tensor/torch.Tensor.div.md | 20 +++++++++++++++++-- .../Tensor/torch.Tensor.divide.md | 20 +++++++++++++++++-- .../Tensor/torch.Tensor.double.md | 2 +- 9 files changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md index 213390e11d1..528bf116391 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.bernoulli -### [torch.Tensor.bernoulli](https://pytorch.org/docs/stable/generated/torch.Tensor.bernoulli.html#torch-tensor-bernoulli) +### [torch.Tensor.bernoulli](https://pytorch.org/docs/1.13/generated/torch.Tensor.bernoulli.html#torch.Tensor.bernoulli) ```python torch.Tensor.bernoulli(*, generator=None) @@ -12,7 +12,7 @@ torch.Tensor.bernoulli(*, generator=None) paddle.bernoulli(x, name=None) ``` -其中 torch 是类成员函数,而 paddle 是非类成员函数,因此第一个参数 `x` 不进行对比,Pytorch 相比 Paddle 支持更多其他参数,具体如下: +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: ### 参数映射 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md index 6c3f0481be3..d5a54a49f18 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.bfloat16 -### [torch.Tensor.bfloat16](https://pytorch.org/docs/stable/generated/torch.Tensor.bfloat16.html#torch-tensor-bfloat16) +### [torch.Tensor.bfloat16](https://pytorch.org/docs/1.13/generated/torch.Tensor.bfloat16.html#torch.Tensor.bfloat16) ```python torch.Tensor.bfloat16(memory_format=torch.preserve_format) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md index 8ad7979e7ab..6476ef09200 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.bool -### [torch.Tensor.bool](https://pytorch.org/docs/stable/generated/torch.Tensor.bool.html#torch.Tensor.bool) +### [torch.Tensor.bool](https://pytorch.org/docs/1.13/generated/torch.Tensor.bool.html#torch.Tensor.bool) ```python torch.Tensor.bool(memory_format=torch.preserve_format) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md index 8603f70f059..405c99817a3 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.byte -### [torch.Tensor.byte](https://pytorch.org/docs/stable/generated/torch.Tensor.byte.html#torch.Tensor.byte) +### [torch.Tensor.byte](https://pytorch.org/docs/1.13/generated/torch.Tensor.byte.html#torch.Tensor.byte) ```python torch.Tensor.byte(memory_format=torch.preserve_format) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md index 98956f89a62..a29cf358426 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.char -### [torch.Tensor.char](https://pytorch.org/docs/stable/generated/torch.Tensor.char.html#torch-tensor-char) +### [torch.Tensor.char](https://pytorch.org/docs/1.13/generated/torch.Tensor.char.html#torch.Tensor.char) ```python torch.Tensor.char(memory_format=torch.preserve_format) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md index b0e73b6c357..cae5feeb191 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.clone -### [torch.Tensor.clone](https://pytorch.org/docs/stable/generated/torch.Tensor.clone.html#torch.Tensor.clone) +### [torch.Tensor.clone](https://pytorch.org/docs/1.13/generated/torch.Tensor.clone.html#torch.Tensor.clone) ```python torch.Tensor.clone(*, memory_format=torch.preserve_format) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md index b00bf87b22d..1aaad8a3874 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.div -### [torch.Tensor.div](https://pytorch.org/docs/stable/generated/torch.Tensor.div.html#torch.Tensor.div) +### [torch.Tensor.div](https://pytorch.org/docs/1.13/generated/torch.Tensor.div.html#torch.Tensor.div) ```python torch.Tensor.div(other, *, rounding_mode=None) @@ -19,4 +19,20 @@ paddle.Tensor.divide(y, name=None) | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ----------------------------------------------------------------------------------- | | other | y | 表示输入的 Tensor ,仅参数名不一致。 | -| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(截断)。Paddle 无此功能,暂无转写方式。| +| rounding_mode | - | 用于指定在执行截断除法时的舍入模式,可选值为 'floor'(向下取整) 或 'trunc'(向零取整)。 Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.tensor([4, 8, 12], dtype=torch.float32) +y = torch.tensor([3, 4, 5], dtype=torch.float32) +z1 = x.div(y, rounding_mode='floor') # 向下取整 +z2 = x.div(y, rounding_mode='trunc') # 向零取整 + +# paddle 写法 +x = paddle.to_tensor([4, 8, 12], dtype='float32') +y = paddle.to_tensor([3, 4, 5], dtype='float32') +z1 = x.divide(y).floor() # 向下取整 +z2 = x.divide(y).trunc() # 向零取整 +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md index de4fdf3721d..098ed923f55 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.divide -### [torch.Tensor.divide](https://pytorch.org/docs/stable/generated/torch.Tensor.divide.html#torch-tensor-divide) +### [torch.Tensor.divide](https://pytorch.org/docs/1.13/generated/torch.Tensor.divide.html#torch.Tensor.divide) ```python torch.Tensor.divide(other, *, rounding_mode=None) @@ -19,4 +19,20 @@ paddle.Tensor.divide(y, name=None) | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ----------------------------------------------------------------------------------- | | other | y | 表示输入的 Tensor ,仅参数名不一致。 | -| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(截断)。Paddle 无此功能,暂无转写方式。| +| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(向零取整)。 Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +```python +# torch 写法 +x = torch.tensor([4, 8, 12], dtype=torch.float32) +y = torch.tensor([3, 4, 5], dtype=torch.float32) +z1 = x.divide(y, rounding_mode='floor') # 向下取整 +z2 = x.divide(y, rounding_mode='trunc') # 向零取整 + +# paddle 写法 +x = paddle.to_tensor([4, 8, 12], dtype='float32') +y = paddle.to_tensor([3, 4, 5], dtype='float32') +z1 = x.divide(y).floor() # 向下取整 +z2 = x.divide(y).trunc() # 向零取整 +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md index c1270765eea..2c80c2f4e5a 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.md @@ -1,6 +1,6 @@ ## [ torch 参数更多 ] torch.Tensor.double -### [torch.Tensor.double](https://pytorch.org/docs/stable/generated/torch.Tensor.char.html#torch-tensor-char) +### [torch.Tensor.double](https://pytorch.org/docs/1.13/generated/torch.Tensor.double.html#torch-Tensor-double) ```python torch.Tensor.double(memory_format=torch.preserve_format) From 8c73326f37aa31279473cf17f4e0274ce127d16b Mon Sep 17 00:00:00 2001 From: wenyin Date: Sat, 6 May 2023 22:52:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=96=87=E6=A1=A3=20No.?= =?UTF-8?q?=2059?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_difference/Tensor/torch.Tensor.copy_.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.copy_.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.copy_.md index a0f4a067370..07292bf3492 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.copy_.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.copy_.md @@ -1,5 +1,6 @@ -## torch.Tensor.copy_ -### [torch.Tensor.copy_](https://pytorch.org/docs/stable/generated/torch.Tensor.copy_.html?highlight=copy_#torch.Tensor.copy_) +## [ torch 参数更多 ] torch.Tensor.copy_ + +### [torch.Tensor.copy_](https://pytorch.org/docs/1.13/generated/torch.Tensor.copy_.html#torch.Tensor.copy_) ```python torch.Tensor.copy_(src, non_blocking=False)