Skip to content

Commit

Permalink
映射文档 No. 18 (PaddlePaddle#5742)
Browse files Browse the repository at this point in the history
* 映射文档 No. 18

* Update torch.Tensor.nanquantile.md

* Update torch.Tensor.negative.md

* Update torch.Tensor.nelement.md

* Update torch.Tensor.nonzero.md

* Update torch.Tensor.numel.md

* Update torch.Tensor.numpy.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.pin_memory.md

* Update torch.Tensor.nanquantile.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.nanquantile.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.nanquantile.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.nanquantile.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.prod.md

* Update torch.Tensor.prod.md

* try pre-commit

* try again pre-commit

* try again again pre-commitpre-commitpre-commit

* Update torch.Tensor.nelement.md

* Update torch.Tensor.numel.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.numpy.md

* Update torch.Tensor.numpy.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.pow.md

* try pre-commit

* Update torch.Tensor.numpy.md

* Update torch.Tensor.outer.md

* Create torch.Tensor.pow.md

* Update torch.Tensor.nelement.md

* Update torch.Tensor.numel.md

* Update torch.Tensor.nelement.md

* Update torch.Tensor.pow.md

* Update torch.Tensor.outer.md

* Update torch.Tensor.numpy.md
  • Loading branch information
jjyaoao authored Apr 11, 2023
1 parent 3f43c97 commit d6d8a60
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## [ torch 参数更多 ] torch.Tensor.nanquantile

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

```python
torch.Tensor.nanquantile(q, dim=None, keepdim=False, *, interpolation='linear')
```

### [paddle.Tensor.nanquantile](https://github.com/PaddlePaddle/Paddle/pull/41343)

```python
paddle.Tensor.nanquantile(q, axis=None, keepdim=False)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ----------------------------------------------------------------------------------- |
| q | q | 一个 [0, 1] 范围内的分位数值的标量或一维张量,仅参数名不一致。 |
| dim | axis | 求乘积运算的维度,仅参数名不一致。 |
| keepdim | keepdim | 是否在输出 Tensor 中保留输入的维度,仅参数名不一致。 |
| interpolation | - | 指定当所需分位数位于两个数据点之间时使用的插值方法,Paddle 无此功能,暂无转写方式。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [ 无参数 ] torch.Tensor.negative

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

```python
torch.Tensor.negative()
```

### [paddle.Tensor.neg](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/neg_cn.html#cn-api-paddle-neg)

```python
paddle.Tensor.neg()
```

两者功能一致,均无参数,用于计算输入 x 的相反数并返回。
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## [ 无参数 ] torch.Tensor.nelement

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

```python
torch.Tensor.nelement()
```

### [paddle.Tensor.size](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/layers/size_cn.html#cn-api-fluid-layers-size)

```python
paddle.Tensor.size()
```



两者功能一致,均无参数,用于返回张量的单元数量,是一个 int 型的整数。
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [ 无参数 ] torch.Tensor.nonzero

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

```python
torch.Tensor.nonzero()
```

### [paddle.Tensor.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nonzero_cn.html#cn-api-tensor-search-nonzero)

```python
paddle.Tensor.nonzero()
```

两者功能一致,均无参数,用于返回输入 `x` 中非零元素的坐标。
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [ 无参数 ] torch.Tensor.numel

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

```python
torch.Tensor.numel()
```

### [paddle.Tensor.size](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/layers/size_cn.html#cn-api-fluid-layers-size)

```python
paddle.Tensor.size()
```

两者功能一致,均无参数,用于返回张量的单元数量,是一个 int 型的整数。
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## [ torch 参数更多 ] torch.Tensor.numpy

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

```python
torch.Tensor.numpy(force=False)
```

### [paddle.Tensor.numpy](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#numpy)

```python
paddle.Tensor.numpy()
```

两者功能一致,用于将当前 Tensor 转化为 numpy.ndarray。

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ---------------------------------------------------------------- |
| force | - | 若 force 为默认,则返回的 ndarray 和 tensor 将共享它们的存储空间 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## [ 仅参数名不一致 ] torch.Tensor.outer

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

```python
torch.Tensor.outer(vec2)
```

### [paddle.outer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/outer_cn.html)

```python
paddle.outer(x, y)
```

两者功能一致,其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------------------------------------------- |
| - | x | 一个 N 维 Tensor 或者标量 Tensor。 |
| vec2 | y | 如果类型是多维 `Tensor`,其数据类型应该和 `x` 相同,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## [ 无参数 ] torch.Tensor.pin_memory

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

```python
torch.Tensor.pin_memory()
```

### [paddle.Tensor.pin_memory](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#pin-memory-y-name-none)

```python
paddle.Tensor.pin_memory()
```



两者功能一致,均无参数,用于将当前 Tensor 的拷贝到固定内存上,且返回的 Tensor 不保留在原计算图中。
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## [ 仅参数名不一致 ] torch.Tensor.pow

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

```python
torch.Tensor.pow(exponent)
```

### [paddle.pow](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/pow_cn.html)

```python
paddle.pow(x, y)
```

两者功能一致,逐元素计算 x 的 y 次幂。

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| -------- | ------------ | -------------------------------------------------- |
| - | x | 多维 Tensor,数据类型为 float16 、 float32 、 float64 、 int32 或 int64 。 |
| exponent | y | 一个 N 维 Tensor 或者标量 Tensor,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## [ 仅参数名不一致 ] torch.Tensor.prod

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

```python
torch.Tensor.prod(dim, keepdim=False, *, dtype=None)
```

### [paddle.Tensor.prod](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/prod_cn.html)

```python
paddle.Tensor.prod(axis=None, keepdim=False, dtype=None, name=None)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------------------------------------- |
| dim | axis | 求乘积运算的维度,仅参数名不一致。 |
| keepdim | keepdim | 是否在输出 Tensor 中保留输入的维度,仅参数名不一致。 |
| dtype | dtype | 输出 Tensor 的数据类型,支持 int32、int64、float32、float64。 |
| - | name | 一般无需设置,默认值为 None。 |

0 comments on commit d6d8a60

Please sign in to comment.