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. 299/305/316/317/319 #6021

Merged
merged 1 commit into from
Jul 20, 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.cumulative_trapezoid

### [torch.cumulative_trapezoid](https://pytorch.org/docs/stable/generated/torch.cumulative_trapezoid.html#torch.cumulative_trapezoid)

```python
torch.cumulative_trapezoid(y, x=None, *, dx=None, dim=-1)
```

### [paddle.cumulative_trapezoid](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cumulative_trapezoid_cn.html)

```python
paddle.cumulative_trapezoid(y, x=None, dx=None, axis=-1, name=None)
```

两者功能一致且参数用法一致,仅参数名不同,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------------------------- |
| y | y | 输入多维 Tensor。 |
| x | x | y 中数值对应的浮点数所组成的 Tensor。 |
| dx | dx | 相邻采样点之间的常数间隔。 |
| dim | axis | 计算 trapezoid rule 时 y 的维度,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## [参数不一致]torch.histogram

### [torch.histogram](https://pytorch.org/docs/stable/generated/torch.histogram.html#torch.histogram)

```python
torch.histogram(input, bins, *, range=None, weight=None, density=False, out=None)
```

### [paddle.histogram](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/histogram_cn.html)

```python
paddle.histogram(input, bins=100, min=0, max=0, name=None)
```

其中 Pytorch 相比 Paddle 支持更多其他参数,返回参数 Tensor 数量不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------------------------------------------------------------------------- |
| input | input | 输入 Tensor。 |
| bins | bins | 直方图 bins(直条)的个数。 |
| range | min, max | PyTorch 为 bins 的范围,类型为 float,Paddle 为 range 的下边界,上边界,类型为 int,需要进行转写。 |
| weight | - | 权重,Paddle 无此参数,暂无转写方式。 |
| density | - | 结果中每个 bin 是否包含权重数,Paddle 无此参数,暂无转写方式。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

加一个返回值的对比

这两个API返回的Tensor数量不同对不上

分类为 参数不一致

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

| 返回值 | 返回值 | PyTorch 返回 hist 和 bin_edges,Paddle 返回 hist,暂无转写方式。 |

### 转写示例

#### range 参数:bins 的范围

```python
# PyTorch 写法:
x = torch.tensor([1., 2, 1])
y = torch.histogram(x, bins=5, range=(0., 3.))

# Paddle 写法:
x = paddle.to_tensor([1, 2, 1])
y = paddle.histogram(x, bins=5, min=0, max=3)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## [torch 参数更多]torch.special.i0

### [torch.special.i0](https://pytorch.org/docs/stable/special.html#torch.special.i0)

```python
torch.special.i0(input, *, out=None)
```

### [paddle.i0](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/i0_cn.html)

```python
paddle.i0(x, name=None)
```

其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------------------------- |
| input | x | 表示输入的 Tensor,仅参数名不一致。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
x = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float32)
torch.special.i0(x, out=y)

# Paddle 写法
x = paddle.to_tensor([1, 2, 3, 4, 5], dtype="float32")
paddle.assign(paddle.i0(x), y)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## [torch 参数更多]torch.special.i1

### [torch.special.i1](https://pytorch.org/docs/stable/special.html#torch.special.i1)

```python
torch.special.i1(input, *, out=None)
```

### [paddle.i1](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/i1_cn.html)

```python
paddle.i1(x, name=None)
```

其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------------------------- |
| input | x | 表示输入的 Tensor,仅参数名不一致。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
x = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float32)
torch.special.i1(x, out=y)

# Paddle 写法
x = paddle.to_tensor([1, 2, 3, 4, 5], dtype="float32")
paddle.assign(paddle.i1(x), y)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## [torch 参数更多]torch.special.i1e

### [torch.special.i1e](https://pytorch.org/docs/stable/special.html#torch.special.i1e)

```python
torch.special.i1e(input, *, out=None)
```

### [paddle.i1e](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/i1e_cn.html)

```python
paddle.i1e(x, name=None)
```

其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------------------------- |
| input | x | 表示输入的 Tensor,仅参数名不一致。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
x = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float32)
torch.special.i1e(x, out=y)

# Paddle 写法
x = paddle.to_tensor([1, 2, 3, 4, 5], dtype="float32")
paddle.assign(paddle.i1e(x), y)
```