diff --git a/lite/backends/metal/metal_image.mm b/lite/backends/metal/metal_image.mm index b0486308250..b21887a3a72 100644 --- a/lite/backends/metal/metal_image.mm +++ b/lite/backends/metal/metal_image.mm @@ -71,8 +71,11 @@ dim.emplace_back(pad_to_four_dim_[i]); }); } break; - case 0: - break; + case 0: { + for (int i = 0; i < 4; ++i) { + dim.emplace_back(pad_to_four_dim_[i]); + } + } break; default: LOG(FATAL) << "metal_image: Dim size is error"; } diff --git a/lite/operators/gather_op.cc b/lite/operators/gather_op.cc index eb324beeee4..ad725ec93e6 100644 --- a/lite/operators/gather_op.cc +++ b/lite/operators/gather_op.cc @@ -52,7 +52,10 @@ bool GatherOp::InferShapeImpl() const { inner_dim_size *= input_dim[i]; out_dim_vec.push_back(input_dim[i]); } - out_dim_vec.push_back(index_size); + auto index_rank = param_.Index->dims().size(); + if (index_rank) { + out_dim_vec.push_back(index_size); + } for (int i = axis_index + 1; i < input_dim.size(); i++) { outer_dim_size *= input_dim[i]; out_dim_vec.push_back(input_dim[i]); diff --git a/lite/operators/is_empty_op.cc b/lite/operators/is_empty_op.cc index 7c742cee967..9bae13e7e5d 100644 --- a/lite/operators/is_empty_op.cc +++ b/lite/operators/is_empty_op.cc @@ -26,7 +26,7 @@ bool IsEmptyOp::CheckShape() const { } bool IsEmptyOp::InferShapeImpl() const { - param_.Out->Resize({1}); + param_.Out->Resize(std::vector({})); return true; } diff --git a/lite/operators/mean_op.cc b/lite/operators/mean_op.cc index 9a66d4fbda3..c28ccff713a 100644 --- a/lite/operators/mean_op.cc +++ b/lite/operators/mean_op.cc @@ -28,7 +28,7 @@ bool MeanOp::CheckShape() const { } bool MeanOp::InferShapeImpl() const { - param_.Out->Resize(std::vector{1}); + param_.Out->Resize(std::vector{}); return true; } diff --git a/lite/operators/norm_op.cc b/lite/operators/norm_op.cc index b1dce211690..acf9bd9c35c 100644 --- a/lite/operators/norm_op.cc +++ b/lite/operators/norm_op.cc @@ -71,7 +71,6 @@ bool PNormOpLite::InferShapeImpl() const { std::vector reduce_dims; const bool asvector = param_.asvector; if (asvector) { - reduce_dims.emplace_back(1); if (keepdim) { for (int64_t i = 1; i < x_dim.size(); ++i) { reduce_dims.emplace_back(1); @@ -85,9 +84,6 @@ bool PNormOpLite::InferShapeImpl() const { for (int i = 0; i < x_dim.size(); ++i) { if (i != axis) reduce_dims.emplace_back(x_dim[i]); } - if (reduce_dims.size() == 0) { - reduce_dims.emplace_back(1); - } } x_dim[axis] = 1; diff --git a/lite/operators/reduce_ops.cc b/lite/operators/reduce_ops.cc index 9bf8c32aceb..a0ca83fed34 100644 --- a/lite/operators/reduce_ops.cc +++ b/lite/operators/reduce_ops.cc @@ -39,15 +39,7 @@ bool ReduceOp::CheckShape() const { auto dims = param_.dim; auto x_dims = param_.X->dims(); int x_rank = x_dims.size(); - // dim at least is [0] - CHECK_GT(dims.size(), 0) - << "The input dim should be greater than 0. But received the dim = " - << dims.size(); - for (int i = 0; i < dims.size(); i++) { - CHECK(dims[i] <= x_rank && dims[i] + x_rank >= 0) - << "dims[i] is " << dims[i] << ", x_rank is " << x_rank; - } - return true; + return x_rank >= 0; } bool ReduceOp::InferShapeImpl() const { @@ -58,10 +50,8 @@ bool ReduceOp::InferShapeImpl() const { bool keep_dim = param_.keep_dim; for (int i = 0; i < dims.size(); i++) { - CHECK(dims[i] <= x_rank && dims[i] + x_rank >= 0) - << "dims[i] is " << dims[i] << ", x_rank is " << x_rank; if (dims[i] < 0) { - dims[i] = x_rank + dims[i]; + dims[i] = x_rank + dims[i] >= 0 ? x_rank + dims[i] : 0; } } // recompute reduce_all @@ -79,8 +69,9 @@ bool ReduceOp::InferShapeImpl() const { if (reduce_all) { if (keep_dim) param_.Out->Resize(std::vector(x_rank, 1)); - else - param_.Out->Resize(std::vector({1})); + else { + param_.Out->Resize(std::vector({})); + } } else { std::vector dims_vector(x_rank, 1); for (int i = 0; i < x_rank; i++) dims_vector[i] = x_dims[i]; diff --git a/lite/tests/kernels/is_empty_compute_test.cc b/lite/tests/kernels/is_empty_compute_test.cc index 1b366497043..966509b4e47 100644 --- a/lite/tests/kernels/is_empty_compute_test.cc +++ b/lite/tests/kernels/is_empty_compute_test.cc @@ -37,7 +37,7 @@ class IsEmptyComputeTester : public arena::TestCase { const auto* x = scope->FindTensor(x_); auto* out = scope->NewTensor(out_); - out->Resize(DDim({1})); + out->Resize(DDim(std::vector{})); auto* out_data = out->mutable_data(); out_data[0] = (x->numel() == 0) ? true : false; } diff --git a/lite/tests/kernels/mean_compute_test.cc b/lite/tests/kernels/mean_compute_test.cc index c6db7a31c05..fcb1eb28b84 100644 --- a/lite/tests/kernels/mean_compute_test.cc +++ b/lite/tests/kernels/mean_compute_test.cc @@ -37,7 +37,7 @@ class MeanComputeTester : public arena::TestCase { auto input = scope->FindTensor(input_); auto output = scope->NewTensor(output_); - std::vector out_dims{1}; + std::vector out_dims{}; output->Resize(out_dims); auto input_data = input->data(); diff --git a/lite/tests/kernels/reduce_all_compute_test.cc b/lite/tests/kernels/reduce_all_compute_test.cc index aa6a1684648..5418b1b3291 100644 --- a/lite/tests/kernels/reduce_all_compute_test.cc +++ b/lite/tests/kernels/reduce_all_compute_test.cc @@ -232,16 +232,17 @@ class ReduceAllComputeTester : public arena::TestCase { } } reduce_all_ = (reduce_all_ || full_dim); - if (dim_.size() == 0) { + if (dim_.size() == 0 || x_rank == 0 || dim_.size() == x_rank) { reduce_all_ = true; } std::vector out_dims; if (reduce_all_) { - if (keep_dim_) + if (keep_dim_) { out_dims = std::vector(x_rank, 1); - else - out_dims = std::vector{1}; + } else { + out_dims = std::vector(); + } } else { size_t out_rank = keep_dim_ ? x_rank : x_rank - dim_.size(); out_dims.resize(out_rank); @@ -345,6 +346,8 @@ void test_reduce_all(Place place, float abs_err) { default: x_dims = DDim(std::vector({n, c, h, w})); } + // 0d output tensor is not supported in NNAdapter Now + if (dims == 2 && dim.size() > 1) continue; int last_dim = dim.back(); if (dim.back() < 0) { diff --git a/lite/tests/kernels/reduce_any_compute_test.cc b/lite/tests/kernels/reduce_any_compute_test.cc index 8039cd736e3..042d5728e6a 100644 --- a/lite/tests/kernels/reduce_any_compute_test.cc +++ b/lite/tests/kernels/reduce_any_compute_test.cc @@ -232,16 +232,17 @@ class ReduceAnyComputeTester : public arena::TestCase { } } reduce_all_ = (reduce_all_ || full_dim); - if (dim_.size() == 0) { + if (dim_.size() == 0 || x_rank == 0 || dim_.size() == x_rank) { reduce_all_ = true; } std::vector out_dims; if (reduce_all_) { - if (keep_dim_) + if (keep_dim_) { out_dims = std::vector(x_rank, 1); - else - out_dims = std::vector{1}; + } else { + out_dims = std::vector(); + } } else { size_t out_rank = keep_dim_ ? x_rank : x_rank - dim_.size(); out_dims.resize(out_rank); @@ -347,6 +348,8 @@ void test_reduce_any(Place place, float abs_err) { x_dims = DDim(std::vector({n, c, h, w})); } + // 0d output tensor is not supported in NNAdapter Now + if (dims == 2 && dim.size() > 1) continue; int last_dim = dim.back(); if (dim.back() < 0) { last_dim += x_dims.size(); diff --git a/lite/tests/kernels/reduce_max_compute_test.cc b/lite/tests/kernels/reduce_max_compute_test.cc index 0511a2fad24..10ea8bd079f 100644 --- a/lite/tests/kernels/reduce_max_compute_test.cc +++ b/lite/tests/kernels/reduce_max_compute_test.cc @@ -283,16 +283,15 @@ class ReduceMaxComputeTester : public arena::TestCase { } std::stable_sort(dim_.begin(), dim_.end()); - if (dim_.size() == 0) { + if (dim_.size() == 0 || x_rank == 0 || dim_.size() == x_rank) { reduce_all_ = true; } std::vector out_dims; if (reduce_all_) { if (keep_dim_) { - out_dims.push_back(x_rank); - out_dims.push_back(1); + out_dims = std::vector(x_rank, 1); } else { - out_dims.push_back(1); + out_dims = std::vector(); } } else { for (size_t i = 0; i < x_dims_.size(); i++) { @@ -313,8 +312,8 @@ class ReduceMaxComputeTester : public arena::TestCase { if (!keep_dim_ && out_dims.empty()) { out_dims.push_back(1); } - out->Resize(DDim(out_dims)); } + out->Resize(DDim(out_dims)); auto* out_data = out->mutable_data(); diff --git a/lite/tests/kernels/reduce_mean_compute_test.cc b/lite/tests/kernels/reduce_mean_compute_test.cc index c85bc72f37e..64ced82f510 100644 --- a/lite/tests/kernels/reduce_mean_compute_test.cc +++ b/lite/tests/kernels/reduce_mean_compute_test.cc @@ -224,16 +224,15 @@ class ReduceMeanComputeTester : public arena::TestCase { } std::stable_sort(dim_.begin(), dim_.end()); - if (dim_.size() == 0) { + if (dim_.size() == 0 || x_rank == 0 || dim_.size() == x_rank) { reduce_all_ = true; } std::vector out_dims; if (reduce_all_) { if (keep_dim_) { - out_dims.push_back(x_rank); - out_dims.push_back(1); + out_dims = std::vector(x_rank, 1); } else { - out_dims.push_back(1); + out_dims = std::vector(); } } else { for (size_t i = 0; i < x_dims_.size(); i++) { @@ -254,8 +253,8 @@ class ReduceMeanComputeTester : public arena::TestCase { if (!keep_dim_ && out_dims.empty()) { out_dims.push_back(1); } - out->Resize(DDim(out_dims)); } + out->Resize(DDim(out_dims)); auto* out_data = out->mutable_data(); size_t new_dims[] = {1, 1, 1, 1}; @@ -342,7 +341,8 @@ void test_reduce_mean(Place place, default: x_dims = DDim(std::vector({n, c, h, w})); } - + // 0d output tensor is not supported in NNAdapter Now + if (dims == 2 && dim.size() > 1) continue; int last_dim = dim.back(); if (dim.back() < 0) { last_dim += x_dims.size(); diff --git a/lite/tests/kernels/reduce_min_compute_test.cc b/lite/tests/kernels/reduce_min_compute_test.cc index 32c5bd0591f..ca15e5f2cfe 100644 --- a/lite/tests/kernels/reduce_min_compute_test.cc +++ b/lite/tests/kernels/reduce_min_compute_test.cc @@ -283,16 +283,15 @@ class ReduceMinComputeTester : public arena::TestCase { } std::stable_sort(dim_.begin(), dim_.end()); - if (dim_.size() == 0) { + if (dim_.size() == 0 || x_rank == 0 || dim_.size() == x_rank) { reduce_all_ = true; } std::vector out_dims; if (reduce_all_) { if (keep_dim_) { - out_dims.push_back(x_rank); - out_dims.push_back(1); + out_dims = std::vector(x_rank, 1); } else { - out_dims.push_back(1); + out_dims = std::vector(); } } else { for (size_t i = 0; i < x_dims_.size(); i++) { @@ -313,8 +312,8 @@ class ReduceMinComputeTester : public arena::TestCase { if (!keep_dim_ && out_dims.empty()) { out_dims.push_back(1); } - out->Resize(DDim(out_dims)); } + out->Resize(DDim(out_dims)); auto* out_data = out->mutable_data(); diff --git a/lite/tests/kernels/reduce_prod_compute_test.cc b/lite/tests/kernels/reduce_prod_compute_test.cc index 7245d310278..da804e74cb1 100644 --- a/lite/tests/kernels/reduce_prod_compute_test.cc +++ b/lite/tests/kernels/reduce_prod_compute_test.cc @@ -208,15 +208,14 @@ class ReduceProdComputeTester : public arena::TestCase { } } std::stable_sort(dim_.begin(), dim_.end()); - + std::vector out_dims; if (reduce_all_ || dim_.size() == 0) { if (keep_dim_) { - out->Resize({static_cast(x_rank), 1}); + out_dims = std::vector(x_rank, 1); } else { - out->Resize({1}); + out_dims = std::vector(); } } else { - std::vector out_dims; for (size_t i = 0; i < x_dims_.size(); i++) { out_dims.push_back(x_dims_[i]); } diff --git a/lite/tests/kernels/reduce_sum_compute_test.cc b/lite/tests/kernels/reduce_sum_compute_test.cc index a3e604eee07..c9e8e1e506b 100644 --- a/lite/tests/kernels/reduce_sum_compute_test.cc +++ b/lite/tests/kernels/reduce_sum_compute_test.cc @@ -228,12 +228,9 @@ class ReduceSumComputeTester : public arena::TestCase { std::vector out_dims; if (reduce_all_) { if (keep_dim_) { - out_dims.resize(x_rank); - for (int i = 0; i < x_rank; ++i) { - out_dims[i] = 1; - } + out_dims = std::vector(x_rank, 1); } else { - out_dims.push_back(1); + out_dims = std::vector(); } } else { for (int i = 0; i < x_dims_.size(); i++) { @@ -331,6 +328,8 @@ void test_reduce_sum(Place place, if (std::find(dim.begin(), dim.end(), 0) == dim.end() && !keep_dim) continue; + // 0d output tensor is not supported in NNAdapter Now + if (reduce_all) continue; #endif auto x_dims = DDim(std::vector({n, c, h, w})); std::unique_ptr tester( diff --git a/lite/tests/unittest_py/op/test_abs_op.py b/lite/tests/unittest_py/op/test_abs_op.py index f2e6c70d7f6..017acc94182 100644 --- a/lite/tests/unittest_py/op/test_abs_op.py +++ b/lite/tests/unittest_py/op/test_abs_op.py @@ -93,9 +93,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, min_success_num=25, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_acos_op.py b/lite/tests/unittest_py/op/test_acos_op.py index cc60b5aabd9..56b2e631428 100644 --- a/lite/tests/unittest_py/op/test_acos_op.py +++ b/lite/tests/unittest_py/op/test_acos_op.py @@ -120,9 +120,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_asin_op.py b/lite/tests/unittest_py/op/test_asin_op.py index 171d20db894..cf7c88a417c 100644 --- a/lite/tests/unittest_py/op/test_asin_op.py +++ b/lite/tests/unittest_py/op/test_asin_op.py @@ -121,9 +121,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_assign_op.py b/lite/tests/unittest_py/op/test_assign_op.py index cf91d6b98fa..dbec1a13249 100644 --- a/lite/tests/unittest_py/op/test_assign_op.py +++ b/lite/tests/unittest_py/op/test_assign_op.py @@ -84,9 +84,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=25) diff --git a/lite/tests/unittest_py/op/test_atan_op.py b/lite/tests/unittest_py/op/test_atan_op.py index f1829302b29..bd7d4ad7387 100644 --- a/lite/tests/unittest_py/op/test_atan_op.py +++ b/lite/tests/unittest_py/op/test_atan_op.py @@ -81,9 +81,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_bitwise_and_op.py b/lite/tests/unittest_py/op/test_bitwise_and_op.py index c3c9f65c776..05d0f6ae3ab 100644 --- a/lite/tests/unittest_py/op/test_bitwise_and_op.py +++ b/lite/tests/unittest_py/op/test_bitwise_and_op.py @@ -124,9 +124,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=500) diff --git a/lite/tests/unittest_py/op/test_bitwise_not_op.py b/lite/tests/unittest_py/op/test_bitwise_not_op.py index 571ce980184..2f7b019e5c0 100644 --- a/lite/tests/unittest_py/op/test_bitwise_not_op.py +++ b/lite/tests/unittest_py/op/test_bitwise_not_op.py @@ -98,9 +98,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=200) diff --git a/lite/tests/unittest_py/op/test_cast_op.py b/lite/tests/unittest_py/op/test_cast_op.py index da63dc6203c..9e2268c6df5 100644 --- a/lite/tests/unittest_py/op/test_cast_op.py +++ b/lite/tests/unittest_py/op/test_cast_op.py @@ -147,9 +147,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_ceil_op.py b/lite/tests/unittest_py/op/test_ceil_op.py index 38202b3be11..83617cab68b 100644 --- a/lite/tests/unittest_py/op/test_ceil_op.py +++ b/lite/tests/unittest_py/op/test_ceil_op.py @@ -72,9 +72,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_clip_op.py b/lite/tests/unittest_py/op/test_clip_op.py index 00e9076d46e..f1e9cdfbc26 100644 --- a/lite/tests/unittest_py/op/test_clip_op.py +++ b/lite/tests/unittest_py/op/test_clip_op.py @@ -163,9 +163,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_compare_less_op.py b/lite/tests/unittest_py/op/test_compare_less_op.py index 1aad7a624ab..ae79c1f292b 100644 --- a/lite/tests/unittest_py/op/test_compare_less_op.py +++ b/lite/tests/unittest_py/op/test_compare_less_op.py @@ -124,9 +124,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=60) diff --git a/lite/tests/unittest_py/op/test_cos_op.py b/lite/tests/unittest_py/op/test_cos_op.py index ff62e224462..0e96e80588e 100644 --- a/lite/tests/unittest_py/op/test_cos_op.py +++ b/lite/tests/unittest_py/op/test_cos_op.py @@ -86,9 +86,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_dropout_op.py b/lite/tests/unittest_py/op/test_dropout_op.py index 7c2d7888a19..24184000a0e 100644 --- a/lite/tests/unittest_py/op/test_dropout_op.py +++ b/lite/tests/unittest_py/op/test_dropout_op.py @@ -178,7 +178,7 @@ def _teller1(program_config, predictor_config): # self.add_ignore_check_case(_teller2, # IgnoreReasons.PADDLELITE_NOT_SUPPORT, - # "Only test 0D-tensor on CPU(ARM/Host) now.") + # "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_elementwise_div_op.py b/lite/tests/unittest_py/op/test_elementwise_div_op.py index 1ab68be5d2a..2b704b3a20a 100644 --- a/lite/tests/unittest_py/op/test_elementwise_div_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_div_op.py @@ -198,9 +198,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_elementwise_floordiv_op.py b/lite/tests/unittest_py/op/test_elementwise_floordiv_op.py index 5c10469297c..386849a60ac 100644 --- a/lite/tests/unittest_py/op/test_elementwise_floordiv_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_floordiv_op.py @@ -149,9 +149,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_elementwise_max_op.py b/lite/tests/unittest_py/op/test_elementwise_max_op.py index 9f204220ad6..62d0626e466 100644 --- a/lite/tests/unittest_py/op/test_elementwise_max_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_max_op.py @@ -146,9 +146,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_elementwise_min_op.py b/lite/tests/unittest_py/op/test_elementwise_min_op.py index a063506ddcd..b4f53ba62cc 100644 --- a/lite/tests/unittest_py/op/test_elementwise_min_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_min_op.py @@ -146,9 +146,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_elementwise_mod_op.py b/lite/tests/unittest_py/op/test_elementwise_mod_op.py index ae405d42352..61ee63c7f88 100644 --- a/lite/tests/unittest_py/op/test_elementwise_mod_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_mod_op.py @@ -136,9 +136,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def _teller4(program_config, predictor_config): target_type = predictor_config.target() diff --git a/lite/tests/unittest_py/op/test_elementwise_mul_op.py b/lite/tests/unittest_py/op/test_elementwise_mul_op.py index e9604f44749..85286706301 100644 --- a/lite/tests/unittest_py/op/test_elementwise_mul_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_mul_op.py @@ -193,9 +193,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_elementwise_pow_op.py b/lite/tests/unittest_py/op/test_elementwise_pow_op.py index 2e9fd9728b1..17dcd9d2b96 100644 --- a/lite/tests/unittest_py/op/test_elementwise_pow_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_pow_op.py @@ -170,9 +170,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_elementwise_sub_op.py b/lite/tests/unittest_py/op/test_elementwise_sub_op.py index 79623d98e56..4f110bf16e0 100644 --- a/lite/tests/unittest_py/op/test_elementwise_sub_op.py +++ b/lite/tests/unittest_py/op/test_elementwise_sub_op.py @@ -194,9 +194,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_elu_op.py b/lite/tests/unittest_py/op/test_elu_op.py index 52cfbc893a0..8a68b001e7e 100644 --- a/lite/tests/unittest_py/op/test_elu_op.py +++ b/lite/tests/unittest_py/op/test_elu_op.py @@ -79,9 +79,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_equal_op.py b/lite/tests/unittest_py/op/test_equal_op.py index 639a7dbb8b4..40a687ecda8 100644 --- a/lite/tests/unittest_py/op/test_equal_op.py +++ b/lite/tests/unittest_py/op/test_equal_op.py @@ -146,9 +146,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_erf_op.py b/lite/tests/unittest_py/op/test_erf_op.py index f316a3f2a35..05892926ffe 100644 --- a/lite/tests/unittest_py/op/test_erf_op.py +++ b/lite/tests/unittest_py/op/test_erf_op.py @@ -72,9 +72,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_exp_op.py b/lite/tests/unittest_py/op/test_exp_op.py index 2be58b87941..3d61f6fec6f 100644 --- a/lite/tests/unittest_py/op/test_exp_op.py +++ b/lite/tests/unittest_py/op/test_exp_op.py @@ -130,9 +130,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_fill_any_like_op.py b/lite/tests/unittest_py/op/test_fill_any_like_op.py index 5e3c8135bcf..5b805fcce0e 100644 --- a/lite/tests/unittest_py/op/test_fill_any_like_op.py +++ b/lite/tests/unittest_py/op/test_fill_any_like_op.py @@ -103,9 +103,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=25) diff --git a/lite/tests/unittest_py/op/test_fill_zeros_like_op.py b/lite/tests/unittest_py/op/test_fill_zeros_like_op.py index 2589d5e5dd8..e592aef7836 100644 --- a/lite/tests/unittest_py/op/test_fill_zeros_like_op.py +++ b/lite/tests/unittest_py/op/test_fill_zeros_like_op.py @@ -97,9 +97,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_flatten2_op.py b/lite/tests/unittest_py/op/test_flatten2_op.py index 0a252eea11f..6ca905e2df2 100644 --- a/lite/tests/unittest_py/op/test_flatten2_op.py +++ b/lite/tests/unittest_py/op/test_flatten2_op.py @@ -173,9 +173,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_flatten_op.py b/lite/tests/unittest_py/op/test_flatten_op.py index c30f3a77ed7..33a9e767b3b 100644 --- a/lite/tests/unittest_py/op/test_flatten_op.py +++ b/lite/tests/unittest_py/op/test_flatten_op.py @@ -163,9 +163,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_floor_op.py b/lite/tests/unittest_py/op/test_floor_op.py index 0fca6e52c15..e6f8324ff61 100644 --- a/lite/tests/unittest_py/op/test_floor_op.py +++ b/lite/tests/unittest_py/op/test_floor_op.py @@ -80,9 +80,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_gather_op.py b/lite/tests/unittest_py/op/test_gather_op.py index 4b61accb507..99b15539f88 100644 --- a/lite/tests/unittest_py/op/test_gather_op.py +++ b/lite/tests/unittest_py/op/test_gather_op.py @@ -31,20 +31,6 @@ def __init__(self, *args, **kwargs): PrecisionType.FP32, DataLayoutType.NCHW, thread=[1, 2]) - opencl_places = [ - Place(TargetType.OpenCL, PrecisionType.FP16, - DataLayoutType.ImageDefault), Place( - TargetType.OpenCL, PrecisionType.FP16, - DataLayoutType.ImageFolder), - Place(TargetType.OpenCL, PrecisionType.FP32, DataLayoutType.NCHW), - Place(TargetType.OpenCL, PrecisionType.Any, - DataLayoutType.ImageDefault), Place( - TargetType.OpenCL, PrecisionType.Any, - DataLayoutType.ImageFolder), - Place(TargetType.OpenCL, PrecisionType.Any, DataLayoutType.NCHW), - Place(TargetType.Host, PrecisionType.FP32) - ] - self.enable_testing_on_place(places=opencl_places) self.enable_testing_on_place(TargetType.NNAdapter, PrecisionType.FP32) self.enable_devices_on_nnadapter( device_names=["cambricon_mlu", "intel_openvino"]) @@ -58,12 +44,19 @@ def sample_program_configs(self, draw): in_shape = draw( st.lists( st.integers( - min_value=4, max_value=4), min_size=2, max_size=2)) + min_value=4, max_value=4), min_size=1, max_size=2)) + axis = draw(st.integers(min_value=0, max_value=len(in_shape) - 1)) + index = draw( st.sampled_from([[0], [2], [3], [1, 2], [1, 2, 3], [ in_shape[axis] - 1 ], [in_shape[axis] - 2, in_shape[axis] - 1]])) + + if len(in_shape) == 1: + axis = 0 + index = draw(st.sampled_from([0, 1, 2])) + axis_type = draw(st.sampled_from(["int32", "int64"])) index_type = draw(st.sampled_from(["int32", "int64"])) with_tenor_axis = draw(st.booleans()) @@ -160,6 +153,20 @@ def _teller1(program_config, predictor_config): "The op output has diff in a specific case on opencl. We need to fix it as soon as possible." ) + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + in_shape = list(program_config.inputs["input_data"].shape) + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if len(in_shape) == 1: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): target_str = self.get_target() max_examples = 200 diff --git a/lite/tests/unittest_py/op/test_gelu_op.py b/lite/tests/unittest_py/op/test_gelu_op.py index 60bb3aa9ec0..3afdec67334 100644 --- a/lite/tests/unittest_py/op/test_gelu_op.py +++ b/lite/tests/unittest_py/op/test_gelu_op.py @@ -96,9 +96,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_greater_op.py b/lite/tests/unittest_py/op/test_greater_op.py index 730ee6bae52..9ec0d04cf07 100644 --- a/lite/tests/unittest_py/op/test_greater_op.py +++ b/lite/tests/unittest_py/op/test_greater_op.py @@ -124,9 +124,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=300) diff --git a/lite/tests/unittest_py/op/test_hard_activation_op.py b/lite/tests/unittest_py/op/test_hard_activation_op.py index 40e98f8b39c..4c0c9df649d 100644 --- a/lite/tests/unittest_py/op/test_hard_activation_op.py +++ b/lite/tests/unittest_py/op/test_hard_activation_op.py @@ -156,9 +156,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_increment_op.py b/lite/tests/unittest_py/op/test_increment_op.py index 66dd5386d72..cd44bff0716 100644 --- a/lite/tests/unittest_py/op/test_increment_op.py +++ b/lite/tests/unittest_py/op/test_increment_op.py @@ -109,9 +109,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_inverse_op.py b/lite/tests/unittest_py/op/test_inverse_op.py index 8401f1aa003..7d57356a1b0 100644 --- a/lite/tests/unittest_py/op/test_inverse_op.py +++ b/lite/tests/unittest_py/op/test_inverse_op.py @@ -85,9 +85,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=25) diff --git a/lite/tests/unittest_py/op/test_leaky_relu_op.py b/lite/tests/unittest_py/op/test_leaky_relu_op.py index 4404837a409..aeb257067f4 100644 --- a/lite/tests/unittest_py/op/test_leaky_relu_op.py +++ b/lite/tests/unittest_py/op/test_leaky_relu_op.py @@ -133,9 +133,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_log_op.py b/lite/tests/unittest_py/op/test_log_op.py index 6a0e3a18724..b5856dd24e6 100644 --- a/lite/tests/unittest_py/op/test_log_op.py +++ b/lite/tests/unittest_py/op/test_log_op.py @@ -115,9 +115,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_logical_op.py b/lite/tests/unittest_py/op/test_logical_op.py index 14e38c027d3..01f5d19e838 100644 --- a/lite/tests/unittest_py/op/test_logical_op.py +++ b/lite/tests/unittest_py/op/test_logical_op.py @@ -134,9 +134,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0 or len(in_y_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_mish_op.py b/lite/tests/unittest_py/op/test_mish_op.py index f63d738d020..b3c4c434115 100644 --- a/lite/tests/unittest_py/op/test_mish_op.py +++ b/lite/tests/unittest_py/op/test_mish_op.py @@ -92,9 +92,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_norm_op.py b/lite/tests/unittest_py/op/test_norm_op.py index 2e7183c6463..7e2ed5aa9e2 100644 --- a/lite/tests/unittest_py/op/test_norm_op.py +++ b/lite/tests/unittest_py/op/test_norm_op.py @@ -55,7 +55,7 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=128), - min_size=1, + min_size=0, max_size=3)) in_shape = in_num + in_c_h_w axis = draw(st.sampled_from([-1, 0, 1, 2, 3])) @@ -79,10 +79,22 @@ def sample_predictor_configs(self): return self.get_predictor_configs(), ["norm"], (1e-5, 1e-5) def add_ignore_pass_case(self): - pass + def _teller1(program_config, predictor_config): + target_type = predictor_config.target() + in_x_shape = list(program_config.inputs["input_data"].shape) + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if len(in_x_shape) == 1 or len(in_x_shape) == 2: + return True + + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): - self.run_and_statis(quant=False, max_examples=50) + self.run_and_statis(quant=False, max_examples=500) if __name__ == "__main__": diff --git a/lite/tests/unittest_py/op/test_p_norm_op.py b/lite/tests/unittest_py/op/test_p_norm_op.py index c6e691bc423..1c8acc8cc5a 100644 --- a/lite/tests/unittest_py/op/test_p_norm_op.py +++ b/lite/tests/unittest_py/op/test_p_norm_op.py @@ -50,14 +50,14 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=128), - min_size=1, + min_size=0, max_size=3)) in_shape = in_num + in_c_h_w axis = draw(st.sampled_from([-1, 0, 1, 2, 3])) assume(len(in_shape) >= axis + 1) epsilon = draw(st.sampled_from([1.0e-12, 1.0e-13])) keepdim = draw(st.booleans()) - asvector = draw(st.booleans()) + asvector = False p_norm_op = OpConfig( type="p_norm", inputs={"X": ["input_data"]}, diff --git a/lite/tests/unittest_py/op/test_pow_op.py b/lite/tests/unittest_py/op/test_pow_op.py index 93517df7770..cb656e1106b 100644 --- a/lite/tests/unittest_py/op/test_pow_op.py +++ b/lite/tests/unittest_py/op/test_pow_op.py @@ -89,9 +89,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_print_op.py b/lite/tests/unittest_py/op/test_print_op.py index 48dfb01cbd4..8e0b6c01178 100644 --- a/lite/tests/unittest_py/op/test_print_op.py +++ b/lite/tests/unittest_py/op/test_print_op.py @@ -84,9 +84,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reciprocal_op.py b/lite/tests/unittest_py/op/test_reciprocal_op.py index 55a6fabfb6d..f2da45defef 100644 --- a/lite/tests/unittest_py/op/test_reciprocal_op.py +++ b/lite/tests/unittest_py/op/test_reciprocal_op.py @@ -81,9 +81,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reduce_all_op.py b/lite/tests/unittest_py/op/test_reduce_all_op.py index f3d9a5f2357..623d2583a75 100644 --- a/lite/tests/unittest_py/op/test_reduce_all_op.py +++ b/lite/tests/unittest_py/op/test_reduce_all_op.py @@ -47,12 +47,16 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=64), min_size=4, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis = draw(st.integers(min_value=-1, max_value=3)) assume(axis < len(in_shape)) if isinstance(axis, int): axis = [axis] - reduce_all_data = True if axis == None or axis == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis == None or axis == [] else False + if len(in_shape) == 0: + axis = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.randint( @@ -97,7 +101,18 @@ def sample_predictor_configs(self): return self.get_predictor_configs(), ["reduce_all"], (1e-5, 1e-5) def add_ignore_pass_case(self): - pass + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reduce_max_op.py b/lite/tests/unittest_py/op/test_reduce_max_op.py index 4adff4c3a34..23d32ca17db 100644 --- a/lite/tests/unittest_py/op/test_reduce_max_op.py +++ b/lite/tests/unittest_py/op/test_reduce_max_op.py @@ -55,15 +55,6 @@ def __init__(self, *args, **kwargs): Place(TargetType.Host, PrecisionType.FP32) ] self.enable_testing_on_place(places=opencl_places) - metal_places = [ - Place(TargetType.Metal, PrecisionType.FP32, - DataLayoutType.MetalTexture2DArray), - Place(TargetType.Metal, PrecisionType.FP16, - DataLayoutType.MetalTexture2DArray), - Place(TargetType.ARM, PrecisionType.FP32), - Place(TargetType.Host, PrecisionType.FP32) - ] - self.enable_testing_on_place(places=metal_places) self.enable_testing_on_place(TargetType.NNAdapter, PrecisionType.FP32) self.enable_devices_on_nnadapter(device_names=["intel_openvino"]) @@ -77,6 +68,7 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=10), min_size=1, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis_list = [ draw(st.integers( @@ -91,7 +83,10 @@ def sample_program_configs(self, draw): axis_list = draw( st.sampled_from([[0], [1], [2], [3], [0, 1], [1, 2], [2, 3]])) - reduce_all_data = True if axis_list == None or axis_list == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis_list == None or axis_list == [] else False + if len(in_shape) == 0: + axis_list = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.random(in_shape).astype(np.float32) @@ -147,6 +142,19 @@ def _teller3(program_config, predictor_config): IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Expected kernel_type false.") + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): target_str = self.get_target() max_examples = 300 diff --git a/lite/tests/unittest_py/op/test_reduce_mean_op.py b/lite/tests/unittest_py/op/test_reduce_mean_op.py index 17349af14ca..72cba7f7b49 100644 --- a/lite/tests/unittest_py/op/test_reduce_mean_op.py +++ b/lite/tests/unittest_py/op/test_reduce_mean_op.py @@ -67,11 +67,15 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=10), min_size=4, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis_list = draw( st.sampled_from([[0], [1], [2], [3], [0, 1], [1, 2], [2, 3]])) - reduce_all_data = True if axis_list == None or axis_list == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis_list == None or axis_list == [] else False + if len(in_shape) == 0: + axis_list = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.random(in_shape).astype(np.float32) @@ -120,6 +124,19 @@ def _teller3(program_config, predictor_config): IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Expected kernel_type false.") + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reduce_min_op.py b/lite/tests/unittest_py/op/test_reduce_min_op.py index cb40be59f57..bc9b92f9b24 100644 --- a/lite/tests/unittest_py/op/test_reduce_min_op.py +++ b/lite/tests/unittest_py/op/test_reduce_min_op.py @@ -52,6 +52,7 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=10), min_size=1, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis_list = [ draw(st.integers( @@ -66,7 +67,10 @@ def sample_program_configs(self, draw): axis_list = draw( st.sampled_from([[0], [1], [2], [3], [0, 1], [1, 2], [2, 3]])) - reduce_all_data = True if axis_list == None or axis_list == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis_list == None or axis_list == [] else False + if len(in_shape) == 0: + axis_list = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.random(in_shape).astype(np.float32) @@ -102,6 +106,19 @@ def _teller3(program_config, predictor_config): IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Expected kernel_type false.") + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=250) diff --git a/lite/tests/unittest_py/op/test_reduce_prod_op.py b/lite/tests/unittest_py/op/test_reduce_prod_op.py index 48691c29f22..3e195886d53 100644 --- a/lite/tests/unittest_py/op/test_reduce_prod_op.py +++ b/lite/tests/unittest_py/op/test_reduce_prod_op.py @@ -49,11 +49,16 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=10), min_size=4, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis_list = draw( st.sampled_from([[0], [1], [2], [3], [0, 1], [1, 2], [2, 3]])) - reduce_all_data = True if axis_list == None or axis_list == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis_list == None or axis_list == [] else False + + if len(in_shape) == 0: + axis_list = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.random(in_shape).astype(np.float32) @@ -89,6 +94,19 @@ def _teller3(program_config, predictor_config): IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Expected kernel_type false.") + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reduce_sum_op.py b/lite/tests/unittest_py/op/test_reduce_sum_op.py index 222af3195f8..af4c7b1f739 100644 --- a/lite/tests/unittest_py/op/test_reduce_sum_op.py +++ b/lite/tests/unittest_py/op/test_reduce_sum_op.py @@ -52,12 +52,17 @@ def sample_program_configs(self, draw): st.lists( st.integers( min_value=1, max_value=10), min_size=4, max_size=4)) + in_shape = draw(st.sampled_from([in_shape, []])) keep_dim = draw(st.booleans()) axis_list = draw( st.sampled_from([[-1], [-2], [-3], [-4], [-2, -1], [-3, -2], [0], - [1], [2], [3], [0, 1], [1, 2], [2, 3]])) + [1], [2], [3], [0, 1], [1, 2], [2, 3], []])) - reduce_all_data = True if axis_list == None or axis_list == [] else False + reduce_all_data = True if len( + in_shape) == 0 or axis_list == None or axis_list == [] else False + + if len(in_shape) == 0: + axis_list = draw(st.sampled_from([[-1], []])) def generate_input(*args, **kwargs): return np.random.random(in_shape).astype(np.float32) @@ -108,6 +113,19 @@ def _teller3(program_config, predictor_config): IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Expected kernel_type false.") + def _teller4(program_config, predictor_config): + target_type = predictor_config.target() + if target_type not in [ + TargetType.ARM, TargetType.Host, TargetType.X86, + TargetType.Metal, TargetType.OpenCL + ]: + if program_config.attr["reduce_all"]: + return True + + self.add_ignore_check_case( + _teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") + def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_relu6_op.py b/lite/tests/unittest_py/op/test_relu6_op.py index c8a803ef57b..3983e36c90a 100644 --- a/lite/tests/unittest_py/op/test_relu6_op.py +++ b/lite/tests/unittest_py/op/test_relu6_op.py @@ -130,9 +130,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_relu_op.py b/lite/tests/unittest_py/op/test_relu_op.py index 7104e1bccb4..92ebc42f4b3 100644 --- a/lite/tests/unittest_py/op/test_relu_op.py +++ b/lite/tests/unittest_py/op/test_relu_op.py @@ -134,9 +134,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_reshape_op.py b/lite/tests/unittest_py/op/test_reshape_op.py index a8c18dcf8b3..6854032ed17 100644 --- a/lite/tests/unittest_py/op/test_reshape_op.py +++ b/lite/tests/unittest_py/op/test_reshape_op.py @@ -182,9 +182,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def teller3(program_config, predictor_config): if self.get_nnadapter_device_name() == "intel_openvino": diff --git a/lite/tests/unittest_py/op/test_round_op.py b/lite/tests/unittest_py/op/test_round_op.py index 4b57bbd1995..47253d7c951 100644 --- a/lite/tests/unittest_py/op/test_round_op.py +++ b/lite/tests/unittest_py/op/test_round_op.py @@ -79,9 +79,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_rsqrt_op.py b/lite/tests/unittest_py/op/test_rsqrt_op.py index 38d4278933c..1d3590da9a7 100644 --- a/lite/tests/unittest_py/op/test_rsqrt_op.py +++ b/lite/tests/unittest_py/op/test_rsqrt_op.py @@ -107,9 +107,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_scale_op.py b/lite/tests/unittest_py/op/test_scale_op.py index 56fd8585aab..aabcad0c8a8 100644 --- a/lite/tests/unittest_py/op/test_scale_op.py +++ b/lite/tests/unittest_py/op/test_scale_op.py @@ -222,9 +222,9 @@ def _teller5(program_config, predictor_config): teller4, IgnoreReasons.PADDLELITE_NOT_SUPPORT, "Lite does not support 'in_shape_size == 1' on nvidia_tensorrt.") - self.add_ignore_check_case(_teller5, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller5, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_sigmoid_op.py b/lite/tests/unittest_py/op/test_sigmoid_op.py index 92bce71441f..9f76400a6cc 100644 --- a/lite/tests/unittest_py/op/test_sigmoid_op.py +++ b/lite/tests/unittest_py/op/test_sigmoid_op.py @@ -138,9 +138,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_silu_op.py b/lite/tests/unittest_py/op/test_silu_op.py index 3e9d92e3a90..ad011e953f3 100644 --- a/lite/tests/unittest_py/op/test_silu_op.py +++ b/lite/tests/unittest_py/op/test_silu_op.py @@ -103,9 +103,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_sin_op.py b/lite/tests/unittest_py/op/test_sin_op.py index c8735c2d339..a700bb7a3e6 100644 --- a/lite/tests/unittest_py/op/test_sin_op.py +++ b/lite/tests/unittest_py/op/test_sin_op.py @@ -86,9 +86,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_softplus_op.py b/lite/tests/unittest_py/op/test_softplus_op.py index b8969640a9f..dc66fa5f385 100644 --- a/lite/tests/unittest_py/op/test_softplus_op.py +++ b/lite/tests/unittest_py/op/test_softplus_op.py @@ -87,9 +87,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_softsign_op.py b/lite/tests/unittest_py/op/test_softsign_op.py index d9ba9596261..b0199395a3e 100644 --- a/lite/tests/unittest_py/op/test_softsign_op.py +++ b/lite/tests/unittest_py/op/test_softsign_op.py @@ -78,9 +78,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_sqrt_op.py b/lite/tests/unittest_py/op/test_sqrt_op.py index 74b3ef3ced1..a1b7a62f5da 100644 --- a/lite/tests/unittest_py/op/test_sqrt_op.py +++ b/lite/tests/unittest_py/op/test_sqrt_op.py @@ -98,9 +98,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_square_op.py b/lite/tests/unittest_py/op/test_square_op.py index 6140956a481..26945a5d7b5 100644 --- a/lite/tests/unittest_py/op/test_square_op.py +++ b/lite/tests/unittest_py/op/test_square_op.py @@ -102,9 +102,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=25) diff --git a/lite/tests/unittest_py/op/test_stack_op.py b/lite/tests/unittest_py/op/test_stack_op.py index 71e9405b3da..dfa27d6980e 100644 --- a/lite/tests/unittest_py/op/test_stack_op.py +++ b/lite/tests/unittest_py/op/test_stack_op.py @@ -127,9 +127,9 @@ def _teller2(program_config, predictor_config): if len(stack_input1_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_sum_op.py b/lite/tests/unittest_py/op/test_sum_op.py index 56a578aabcd..6437c01e5fa 100644 --- a/lite/tests/unittest_py/op/test_sum_op.py +++ b/lite/tests/unittest_py/op/test_sum_op.py @@ -85,9 +85,9 @@ def _teller1(program_config, predictor_config): if len(X_data_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=25) diff --git a/lite/tests/unittest_py/op/test_swish_op.py b/lite/tests/unittest_py/op/test_swish_op.py index e79f314c57f..2258dca6fd2 100644 --- a/lite/tests/unittest_py/op/test_swish_op.py +++ b/lite/tests/unittest_py/op/test_swish_op.py @@ -139,9 +139,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_tanh_op.py b/lite/tests/unittest_py/op/test_tanh_op.py index 8c27f1ccec2..c2a22cdb0da 100644 --- a/lite/tests/unittest_py/op/test_tanh_op.py +++ b/lite/tests/unittest_py/op/test_tanh_op.py @@ -116,9 +116,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_thresholded_relu_op.py b/lite/tests/unittest_py/op/test_thresholded_relu_op.py index ea87faf3e1c..f5a24618c27 100644 --- a/lite/tests/unittest_py/op/test_thresholded_relu_op.py +++ b/lite/tests/unittest_py/op/test_thresholded_relu_op.py @@ -80,9 +80,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): self.run_and_statis(quant=False, max_examples=100) diff --git a/lite/tests/unittest_py/op/test_unsqueeze2_op.py b/lite/tests/unittest_py/op/test_unsqueeze2_op.py index 659fa5c415a..33c61a426c1 100644 --- a/lite/tests/unittest_py/op/test_unsqueeze2_op.py +++ b/lite/tests/unittest_py/op/test_unsqueeze2_op.py @@ -174,9 +174,9 @@ def _teller3(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller3, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller3, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_unsqueeze_op.py b/lite/tests/unittest_py/op/test_unsqueeze_op.py index 4f03c7cb87a..6d0da2ac0ba 100644 --- a/lite/tests/unittest_py/op/test_unsqueeze_op.py +++ b/lite/tests/unittest_py/op/test_unsqueeze_op.py @@ -170,9 +170,9 @@ def _teller2(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller2, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller2, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): target_str = self.get_target() diff --git a/lite/tests/unittest_py/op/test_unstack_op.py b/lite/tests/unittest_py/op/test_unstack_op.py index 626356d5844..c3f835f5571 100644 --- a/lite/tests/unittest_py/op/test_unstack_op.py +++ b/lite/tests/unittest_py/op/test_unstack_op.py @@ -47,14 +47,14 @@ def sample_program_configs(self, draw): C = draw(st.integers(min_value=2, max_value=128)) H = draw(st.integers(min_value=2, max_value=128)) W = draw(st.integers(min_value=2, max_value=128)) - in_shape = draw(st.sampled_from([[N, C, H, W], [N, H, W]])) + in_shape = draw(st.sampled_from([[N, C, H, W], [N, H, W], [N]])) in_dtype = draw(st.sampled_from([np.float32, np.int32])) def generate_X_data(): return np.random.normal(0.0, 5.0, in_shape).astype(in_dtype) - axis_data = draw(st.integers(min_value=0, max_value=2)) + axis_data = draw(st.integers(min_value=0, max_value=len(in_shape) - 1)) num_data = draw(st.integers(min_value=1, max_value=2)) # declare multiple outputs @@ -86,7 +86,7 @@ def add_ignore_pass_case(self): pass def test(self, *args, **kwargs): - self.run_and_statis(quant=False, max_examples=25) + self.run_and_statis(quant=False, max_examples=1000) if __name__ == "__main__": diff --git a/lite/tests/unittest_py/op/test_where_op.py b/lite/tests/unittest_py/op/test_where_op.py index c5d052246b0..64b210bff95 100644 --- a/lite/tests/unittest_py/op/test_where_op.py +++ b/lite/tests/unittest_py/op/test_where_op.py @@ -111,9 +111,9 @@ def _teller1(program_config, predictor_config): if len(in_x_shape) == 0: return True - self.add_ignore_check_case(_teller1, - IgnoreReasons.PADDLELITE_NOT_SUPPORT, - "Only test 0D-tensor on CPU(ARM/Host) now.") + self.add_ignore_check_case( + _teller1, IgnoreReasons.PADDLELITE_NOT_SUPPORT, + "0D-tensor is not supported on this target now.") def test(self, *args, **kwargs): max_examples = 25