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

[Cleanup][C-18] clean some Program.random_seed for test #61484

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/dygraph_to_static/test_word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ def train():
base.CUDAPlace(0) if base.is_compiled_with_cuda() else base.CPUPlace()
)
with base.dygraph.guard(place):
base.default_startup_program().random_seed = 1000
base.default_main_program().random_seed = 1000
paddle.seed(1000)

skip_gram_model = paddle.jit.to_static(
SkipGram("skip_gram_model", vocab_size, embedding_size)
Expand Down
3 changes: 1 addition & 2 deletions test/dygraph_to_static/test_yolov3.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ def generator():
def train():
random.seed(0)
np.random.seed(0)
paddle.seed(1000)

paddle.static.default_startup_program().random_seed = 1000
paddle.static.default_main_program().random_seed = 1000
model = paddle.jit.to_static(YOLOv3(3, is_train=True))

boundaries = cfg.lr_steps
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_weight_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def check_weight_decay(
):
main_prog = base.framework.Program()
startup_prog = base.framework.Program()
startup_prog.random_seed = 1
paddle.seed(1)
with prog_scope_guard(main_prog=main_prog, startup_prog=startup_prog):
data = paddle.static.data(
name="words", shape=[-1, 1], dtype="int64", lod_level=1
Expand Down
3 changes: 1 addition & 2 deletions test/quantization/test_user_defined_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def quantization_scale(
weight_quantize_func=None,
):
def build_program(main, startup, is_test):
main.random_seed = seed
startup.random_seed = seed
paddle.seed(seed)
with paddle.utils.unique_name.guard():
with paddle.static.program_guard(main, startup):
img = paddle.static.data(
Expand Down
2 changes: 0 additions & 2 deletions test/quantization/test_weight_only_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
import paddle.nn.quant as Q
from paddle import base
from paddle.base import core
from paddle.base.framework import default_main_program
from paddle.framework import set_default_dtype

np.random.seed(123)
paddle.seed(123)
default_main_program().random_seed = 42


def get_cuda_version():
Expand Down