-
Notifications
You must be signed in to change notification settings - Fork 55
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
转换规则No65 torch.nn.functional.threshold #121
Closed
Closed
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
05eaa38
torch.nn.functional.threshold
Liyulingyue c0abac1
torch.nn.functional.threshold
Liyulingyue ba79698
FunctionalThresholdMatcher
Liyulingyue 0b714c5
Merge branch 'master' into case65
Liyulingyue 4ca3441
FunctionalThresholdMatcher
Liyulingyue 8231c61
Merge branch 'master' into case65
Liyulingyue 2798c44
threshold
Liyulingyue e62f874
Merge remote-tracking branch 'origin/case65' into case65
Liyulingyue f23b708
threshold
Liyulingyue 6dbb783
Merge branch 'master' into case65
Liyulingyue 9cfc834
add json
Liyulingyue 89eb63d
Update api_mapping.json
Liyulingyue 3d29656
Update api_mapping.json
Liyulingyue 8de8ddf
Update api_mapping.json
Liyulingyue 09bcd0c
Apply suggestions from code review
Liyulingyue b15e1dc
Apply suggestions from code review
Liyulingyue f0e124f
Apply suggestions from code review
Liyulingyue 5109672
Merge branch 'PaddlePaddle:master' into case65
Liyulingyue b4f22a7
Merge branch 'PaddlePaddle:master' into case65
Liyulingyue a6d0d60
Apply suggestions from code review
Liyulingyue eb6349e
Update test_nn_functional_threshold.py
Liyulingyue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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,71 @@ | ||
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import textwrap | ||
|
||
from apibase import APIBase | ||
|
||
obj = APIBase("torch.nn.functional.threshold") | ||
|
||
|
||
def test_case_1(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn.functional as F | ||
x = torch.tensor([[[-1.3020, -0.1005, 0.5766, 0.6351, -0.8893, 0.0253, -0.1756, 1.2913], | ||
[-0.8833, -0.1369, -0.0168, -0.5409, -0.1511, -0.1240, -1.1870, -1.8816]]]) | ||
result = F.threshold(x, 0, 0, inplace=False) | ||
Liyulingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
Liyulingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def test_case_2(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn.functional as F | ||
x = torch.tensor([[[-1.3020, -0.1005, 0.5766, 0.6351, -0.8893, 0.0253, -0.1756, 1.2913], | ||
[-0.8833, -0.1369, -0.0168, -0.5409, -0.1511, -0.1240, -1.1870, -1.8816]]]) | ||
result = F.threshold(x, 1, 0, inplace=False) | ||
Liyulingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_3(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn.functional as F | ||
x = torch.tensor([[[-1.3020, -0.1005, 0.5766, 0.6351, -0.8893, 0.0253, -0.1756, 1.2913], | ||
[-0.8833, -0.1369, -0.0168, -0.5409, -0.1511, -0.1240, -1.1870, -1.8816]]]) | ||
result = F.threshold(x, 0, 1, inplace=False) | ||
Liyulingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn.functional as F | ||
x = torch.tensor([[[-1.3020, -0.1005, 0.5766, 0.6351, -0.8893, 0.0253, -0.1756, 1.2913], | ||
[-0.8833, -0.1369, -0.0168, -0.5409, -0.1511, -0.1240, -1.1870, -1.8816]]]) | ||
result = F.threshold(x, 0, 0, inplace=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
Liyulingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个inplace可以改写到kwargs_change里去直接删除: