From bbe88d8d7907a3450ebc9a286e8f0a837f11da5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=A7=E5=A4=9C?= Date: Mon, 14 Aug 2023 16:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=96=87=E6=A1=A3=20No.4=20(?= =?UTF-8?q?#6082)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add torch.copysign.md * Update torch.copysign.md --- .../api_difference/ops/torch.copysign.md | 24 +++++++++++++++++++ 1 file changed, 24 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..b2bd53578ab --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md @@ -0,0 +1,24 @@ +## [ 组合替代实现 ]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) +```