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.97 #6149

Merged
merged 2 commits into from
Aug 29, 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,20 @@
## [ 组合替代实现 ]torch.Tensor.resize_as_

### [torch.Tensor.resize_as_](https://pytorch.org/docs/stable/generated/torch.Tensor.resize_as_.html?highlight=resize_as#torch.Tensor.resize_as_)

```python
# PyTorch 文档有误,测试第一个参数为 the_template
torch.Tensor.resize_as_(the_template, memory_format=torch.contiguous_format)
```

Paddle 无此 API,需要组合实现。

### 转写示例

```python
# Pytorch 写法
y = a.resize_as_(b)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个API是不是一个inplace的操作,更适合对应x.reshape_?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改


# Paddle 写法
y = a.reshape_(b.shape)
```