-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 5th No.47】API转换 torch.histogramdd -part (#6400)
* Add docs * Add histogramdd * Fix * Fix * Fix * Fix
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...odel_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.signbit.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` | ||
|
||
两者功能一致,均无参数。 |
22 changes: 22 additions & 0 deletions
22
...ert/convert_from_pytorch/api_difference/functional/torch.nn.functional.pdist.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 参数。 | |
25 changes: 25 additions & 0 deletions
25
...ides/model_convert/convert_from_pytorch/api_difference/ops/torch.histogramdd.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 是否包含权重。 | |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.signbit.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |