Skip to content
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

【Hackathon 5th No.45】为torch.cuda.seed, torch.cuda.seed_all 添加test -part #307

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
14 changes: 14 additions & 0 deletions paconvert/api_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -4599,6 +4599,20 @@
"msg"
]
},
"torch.cuda.seed": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.seed",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个API应该并不是对应的,一个是获取seed,一个是设置seed

"paddle_default_kwargs": {
"seed": 1024
}
},
"torch.cuda.seed_all": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.seed",
"paddle_default_kwargs": {
"seed": 1024
}
},
"torch.cuda.set_device": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.device.set_device",
Expand Down
29 changes: 29 additions & 0 deletions tests/test_cuda_seed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.cuda.seed")


def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
result = torch.cuda.seed()
"""
)
obj.run(pytorch_code, ["result"])
29 changes: 29 additions & 0 deletions tests/test_cuda_seed_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.cuda.seed_all")


def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
result = torch.cuda.seed_all()
"""
)
obj.run(pytorch_code, ["result"])