Skip to content

Commit

Permalink
【Hackathon 5th No.47】API转换 torch.histogramdd -part (#6400)
Browse files Browse the repository at this point in the history
* Add docs

* Add histogramdd

* Fix

* Fix

* Fix

* Fix
  • Loading branch information
co63oc authored Dec 19, 2023
1 parent 70e6a72 commit 1ea6ebc
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [无参数]torch.Tensor.signbit

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

```python
torch.Tensor.signbit()
```

### [paddle.Tensor.signbit](https://github.com/PaddlePaddle/Paddle/blob/9ce3a54f456011c664c70fbcd318f2e1af0a7d81/python/paddle/tensor/math.py#L7175)

```python
paddle.Tensor.signbit()
```

两者功能一致,均无参数。
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## [仅参数名不一致]torch.nn.functional.pdist

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

```python
torch.nn.functional.pdist(input, p=2)
```

### [paddle.nn.functional.pdist](https://github.com/PaddlePaddle/Paddle/blob/210442ec30e5038809865a6105dd38308d1df2e0/python/paddle/nn/functional/distance.py#L111)

```python
paddle.nn.functional.pdist(x, p=2.0)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------- |
| input | x | 输入的 Tensor,仅参数名不一致。 |
| p | p | 计算 p-norm 距离的 p 参数。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## [仅参数名不一致]torch.histogramdd

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

```python
torch.histogramdd(input, bins, *, range=None, weight=None, density=False) -> (Tensor, Tensor[])
```

### [paddle.histogramdd](https://github.com/PaddlePaddle/Paddle/blob/a19227d9ee0e351363a4bb27b50b1becbec58a6c/python/paddle/tensor/linalg.py#L3875)

```python
paddle.histogramdd(x, bins=10, ranges=None, density=False, weights=None, name=None)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ----------------------------- |
| input | x | 输入 Tensor,仅参数名不一致。 |
| bins | bins | 直方图 bins(直条)的个数序列。 |
| range | ranges | bins 的范围,仅参数名不一致。 |
| weight | weights | 权重,仅参数名不一致。 |
| density | density | 结果中每个 bin 是否包含权重。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## [torch 参数更多]torch.signbit

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

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

### [paddle.signbit](https://github.com/PaddlePaddle/Paddle/blob/9ce3a54f456011c664c70fbcd318f2e1af0a7d81/python/paddle/tensor/math.py#L7175)

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

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

### 参数映射

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

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
torch.signbit([1., 2., 3., -1.], out=y)

# Paddle 写法
paddle.assign(paddle.signbit([1., 2., 3., -1.]), y)
```

0 comments on commit 1ea6ebc

Please sign in to comment.