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-15]Replace Program.random_seed #61527

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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_optimizer_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def _test_optimizer(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)
np.random.seed(self.SEED)

with paddle.static.scope_guard(scope):
Expand Down
6 changes: 2 additions & 4 deletions test/legacy_test/test_optimizer_in_control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def static(
):
startup_program = Program()
main_program = Program()
startup_program.random_seed = SEED
main_program.random_seed = SEED
paddle.seed(SEED)

with program_guard(main_program, startup_program):

Expand Down Expand Up @@ -175,8 +174,7 @@ def forward(self, inputs):
def dynamic(train_data, use_cuda=False, use_parallel_exe=False):
place = base.CUDAPlace(0) if use_cuda else base.CPUPlace()
with base.dygraph.guard(place):
base.default_startup_program().random_seed = SEED
base.default_main_program().random_seed = SEED
paddle.seed(SEED)
dy_layer = DygraphLayer()
adam = paddle.optimizer.Adam(
learning_rate=LR, parameters=dy_layer.parameters()
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_prune_with_input_type_error(self):
def test_random_seed_error(self):
program = base.default_main_program()
with self.assertRaises(ValueError):
program.random_seed = "seed"
paddle.seed("seed")
SigureMo marked this conversation as resolved.
Show resolved Hide resolved

def test_copy_info_from_error(self):
program = base.default_main_program()
Expand Down
3 changes: 1 addition & 2 deletions test/quantization/test_quantization_mkldnn_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def isinteger(self, x):
return np.equal(np.mod(x, 1), 0)

def build_program(self, main, startup, is_test, seed):
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
3 changes: 1 addition & 2 deletions test/quantization/test_quantization_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ def freeze_graph(
quant_skip_pattern='skip_quant',
):
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