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-13]Replace Program.random_seed #61525

Merged
merged 1 commit 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/ipu/test_model_parallel_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def _test_base(self, run_ipu=True):
scope = paddle.static.Scope()
main_prog = paddle.static.Program()
startup_prog = paddle.static.Program()
main_prog.random_seed = self.SEED
startup_prog.random_seed = self.SEED
paddle.seed(self.SEED)

bs = self.ipu_bs if run_ipu else self.cpu_bs
with paddle.static.scope_guard(scope):
Expand Down
2 changes: 0 additions & 2 deletions test/ipu/test_modelruntime_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def build_model(self):
def reset_seeds(self):
np.random.seed(self.SEED)
paddle.seed(self.SEED)
self.main_prog.random_seed = self.SEED
self.startup_prog.random_seed = self.SEED

def _test(self, use_ipu=False):
self.reset_seeds()
Expand Down
4 changes: 2 additions & 2 deletions test/legacy_test/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import paddle.nn.functional as F
from paddle import base
from paddle.base import core, dygraph
from paddle.base.framework import Program, default_main_program, program_guard
from paddle.base.framework import Program, program_guard
from paddle.incubate.layers.nn import (
batch_fc,
partial_concat,
Expand Down Expand Up @@ -2230,7 +2230,7 @@ def test_shuffle_batch(self):
name='X', shape=[-1, 4, 50], dtype='float32', lod_level=0
)
out1 = shuffle_batch(x)
default_main_program().random_seed = 1000
paddle.seed(1000)
out2 = shuffle_batch(x)
self.assertIsNotNone(out1)
self.assertIsNotNone(out2)
Expand Down
3 changes: 1 addition & 2 deletions test/legacy_test/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def test_main(self):

main_prog = base.Program()
startup_prog = base.Program()
main_prog.random_seed = 1024
startup_prog.random_seed = 1024
paddle.seed(1024)
with base.program_guard(main_prog, startup_prog):
pred = paddle.static.data(
name='pred', shape=[None, self.class_num], dtype='float32'
Expand Down
4 changes: 1 addition & 3 deletions test/quantization/test_llm_int8_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
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
from paddle.pir_utils import test_with_pir_api

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


@unittest.skipIf(
Expand Down