-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add torch.copysign.md * Update torch.copysign.md
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
.../guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
``` |