From 019212bcebb0bda23a52d98766209530e9965a68 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 3 Aug 2023 01:23:43 +0800 Subject: [PATCH 1/2] add torch.copysign.md --- .../api_difference/ops/torch.copysign.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md new file mode 100644 index 00000000000..7db63b82ba8 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md @@ -0,0 +1,26 @@ +## [ 组合替代实现 ]torch.copysign + +### [torch.copysign](https://pytorch.org/docs/stable/generated/torch.copysign.html#torch.copysign) + +```python +torch.copysign(input, + other, + *, + out=None) +``` +创建一个新的浮点张量,其大小与` input `相同,正负符号与` other `相同 + +PaddlePaddle 目前无对应 API,可使用如下代码组合替代实现: + +### 转写示例 + +#### out:指定输出 +```python +# Pytorch 写法 +torch.copysign(input, other, out=y) + +# Paddle 写法 +paddle.assign(paddle.abs(input) * paddle.sign(other), y) +``` + +``` From eb42a531b952817209a8faa050629509a09e88d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=A7=E5=A4=9C?= <20467386+mrcangye@users.noreply.github.com> Date: Thu, 3 Aug 2023 01:26:45 +0800 Subject: [PATCH 2/2] Update torch.copysign.md --- .../convert_from_pytorch/api_difference/ops/torch.copysign.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md index 7db63b82ba8..b2bd53578ab 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md @@ -22,5 +22,3 @@ torch.copysign(input, other, out=y) # Paddle 写法 paddle.assign(paddle.abs(input) * paddle.sign(other), y) ``` - -```