Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

映射文档 No.4 #6082

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:指定输出
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用转写out,直接写组合实现的示例就可以

```python
# Pytorch 写法
torch.copysign(input, other, out=y)

# Paddle 写法
paddle.assign(paddle.abs(input) * paddle.sign(other), y)
```