Skip to content

Commit

Permalink
映射文档 No.4 (#6082)
Browse files Browse the repository at this point in the history
* add torch.copysign.md

* Update torch.copysign.md
  • Loading branch information
mrcangye authored Aug 14, 2023
1 parent 5b05ce7 commit bbe88d8
Showing 1 changed file with 24 additions and 0 deletions.
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)
```

0 comments on commit bbe88d8

Please sign in to comment.