From 6efb9f59b4d0698d15b1aa9d4c435b908a6dd7d3 Mon Sep 17 00:00:00 2001 From: yaozhixin <522190855@qq.com> Date: Wed, 26 Jan 2022 13:22:41 +0800 Subject: [PATCH] update uts p1 (#39210) --- .../tests/unittests/ipu/ernie_training.py | 19 +++++++++---------- .../unittests/ipu/test_activation_x_op.py | 4 ++-- .../tests/unittests/ipu/test_avg_shard_ipu.py | 10 ++++++---- .../unittests/ipu/test_batch_norm_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_cast_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_concat_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_conv_op_ipu.py | 4 ++-- .../ipu/test_cross_entropy2_op_ipu.py | 4 ++-- .../unittests/ipu/test_dropout_op_ipu.py | 4 ++-- .../unittests/ipu/test_elemetwise_x_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_equal_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_expand_op_ipu.py | 8 ++++---- .../ipu/test_fill_constant_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_gather_op_ipu.py | 4 ++-- .../tests/unittests/ipu/test_gelu_op_ipu.py | 4 ++-- 15 files changed, 43 insertions(+), 42 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/ipu/ernie_training.py b/python/paddle/fluid/tests/unittests/ipu/ernie_training.py index bedf0a3854..ddda666db2 100644 --- a/python/paddle/fluid/tests/unittests/ipu/ernie_training.py +++ b/python/paddle/fluid/tests/unittests/ipu/ernie_training.py @@ -856,16 +856,15 @@ if __name__ == "__main__": paddle.static.load(main_prog, "model/ernie") if args.run_on_ipu: - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.num_ipus = args.num_ipus - ipu_strategy.enable_manual_shard = args.num_ipus > 1 - ipu_strategy.enable_pipelining = args.enable_pipelining - if args.enable_pipelining: - if args.is_training: - ipu_strategy.batches_per_step = args.num_ipus + 1 - else: - ipu_strategy.batches_per_step = args.num_ipus - ipu_strategy.is_training = args.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig( + num_ipus=args.num_ipus, + is_training=args.is_training, + enable_manual_shard=args.num_ipus > 1) + ipu_strategy.SetPipeliningConfig( + enable_pipelining=args.enable_pipelining, + batches_per_step=args.num_ipus + 1) + ipu_compiler = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy) program = ipu_compiler.compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_activation_x_op.py b/python/paddle/fluid/tests/unittests/ipu/test_activation_x_op.py index 0f726accfa..58a88c113f 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_activation_x_op.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_activation_x_op.py @@ -72,8 +72,8 @@ class TestRelu(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IpuCompiler( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_avg_shard_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_avg_shard_ipu.py index c4d8b3ee89..a23cacf476 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_avg_shard_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_avg_shard_ipu.py @@ -81,10 +81,12 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training - # enable avg shard pass - ipu_strategy.need_avg_shard = True + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig( + num_ipus=2, + is_training=self.is_training, + enable_manual_shard=True, + need_avg_shard=True) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_batch_norm_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_batch_norm_op_ipu.py index ee81354c44..87f783dbd1 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_batch_norm_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_batch_norm_op_ipu.py @@ -79,8 +79,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_cast_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_cast_op_ipu.py index 19026f5e05..6e58f80904 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_cast_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_cast_op_ipu.py @@ -81,8 +81,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_concat_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_concat_op_ipu.py index 2b59f2bb72..094b19ce99 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_concat_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_concat_op_ipu.py @@ -83,8 +83,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_conv_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_conv_op_ipu.py index fb237c30d4..f28733de6b 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_conv_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_conv_op_ipu.py @@ -81,8 +81,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py index 9d49b05437..3987c6cd5b 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py @@ -93,8 +93,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py index 1cd2037f22..8b1560edfd 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py @@ -83,8 +83,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py index 4aa202ace2..07b06d77c9 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py @@ -75,8 +75,8 @@ class TestMul(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_equal_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_equal_op_ipu.py index b2548a1763..c319894bfa 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_equal_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_equal_op_ipu.py @@ -84,8 +84,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_expand_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_expand_op_ipu.py index 018c9a7876..5b7ea61568 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_expand_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_expand_op_ipu.py @@ -76,8 +76,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) @@ -142,8 +142,8 @@ class TestCase1(TestBase): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py index 6a43fb46ee..c62e0c08f9 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py @@ -78,8 +78,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_gather_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_gather_op_ipu.py index af220a34dd..d5be8ae0cf 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_gather_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_gather_op_ipu.py @@ -83,8 +83,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_gelu_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_gelu_op_ipu.py index 6c9d3f29ad..ca8c0935d7 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_gelu_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_gelu_op_ipu.py @@ -81,8 +81,8 @@ class TestBase(IPUOpTest): if run_ipu: feed_list = self.feed_list - ipu_strategy = compiler.get_ipu_strategy() - ipu_strategy.is_training = self.is_training + ipu_strategy = paddle.static.IpuStrategy() + ipu_strategy.SetGraphConfig(is_training=self.is_training) program = compiler.IPUCompiledProgram( main_prog, ipu_strategy=ipu_strategy).compile(feed_list, fetch_list) -- GitLab