Skip to content

Commit

Permalink
映射文档 No. 86/244 (#6054)
Browse files Browse the repository at this point in the history
* Add api_difference

* 'Fix'
  • Loading branch information
co63oc authored Jul 26, 2023
1 parent 6007168 commit a52bad2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## [ 组合替代实现 ]torch.Tensor.is_signed

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

```python
torch.Tensor.is_signed()
```

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

### 转写示例

```python
# Pytorch 写法
y = x.is_signed()

# Paddle 写法
y = x.dtype not in [paddle.uint8]
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## [ 组合替代实现 ]torch.testing.assert_close

### [torch.testing.assert_close](https://pytorch.org/docs/stable/testing.html?highlight=assert_close#torch.testing.assert_close)

```python
torch.testing.assert_close(actual, expected, *, allow_subclasses=True, rtol=None, atol=None, equal_nan=False, check_device=True, check_dtype=True, check_layout=True, check_stride=False, msg=None)
```

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

### 转写示例

```python
# Pytorch 写法
torch.testing.assert_close(actual, expected, rtol=rtol, atol=atol, equal_nan=True, msg='error messege')

# Paddle 写法
assert paddle.allclose(actual, expected, rtol=rtol, atol=atol, equal_nan=True).item(), 'error messege'
```

0 comments on commit a52bad2

Please sign in to comment.