Skip to content
7 changes: 5 additions & 2 deletions lite/backends/metal/metal_image.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion lite/operators/is_empty_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool IsEmptyOp::CheckShape() const {
}

bool IsEmptyOp::InferShapeImpl() const {
param_.Out->Resize({1});
param_.Out->Resize(std::vector<int64_t>({}));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lite/operators/mean_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool MeanOp::CheckShape() const {
}

bool MeanOp::InferShapeImpl() const {
param_.Out->Resize(std::vector<int64_t>{1});
param_.Out->Resize(std::vector<int64_t>{});
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions lite/operators/norm_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool PNormOpLite::InferShapeImpl() const {
std::vector<int64_t> reduce_dims;
const bool asvector = param_.asvector;
if (asvector) {
reduce_dims.emplace_back(1);
// reduce_dims.emplace_back(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接删了就行,不用注释

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改

if (keepdim) {
for (int64_t i = 1; i < x_dim.size(); ++i) {
reduce_dims.emplace_back(1);
Expand All @@ -85,9 +85,9 @@ 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);
}
// if (reduce_dims.size() == 0) {
// reduce_dims.emplace_back(1);
// }
}
x_dim[axis] = 1;

Expand Down
28 changes: 15 additions & 13 deletions lite/operators/reduce_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ bool ReduceOp::CheckShape() const {
auto dims = param_.dim;
auto x_dims = param_.X->dims();
int x_rank = x_dims.size();
return x_rank >= 0;
// 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;
// CHECK_GT(dims.size(), 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改

// << "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;
}

bool ReduceOp::InferShapeImpl() const {
Expand All @@ -58,10 +59,10 @@ 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;
// CHECK(dims[i] <= x_rank && dims[i] + x_rank >= 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉,不要注释

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

// << "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
Expand All @@ -79,8 +80,9 @@ bool ReduceOp::InferShapeImpl() const {
if (reduce_all) {
if (keep_dim)
param_.Out->Resize(std::vector<int64_t>(x_rank, 1));
else
param_.Out->Resize(std::vector<int64_t>({1}));
else {
param_.Out->Resize(std::vector<int64_t>({}));
}
} else {
std::vector<int64_t> dims_vector(x_rank, 1);
for (int i = 0; i < x_rank; i++) dims_vector[i] = x_dims[i];
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_abs_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_acos_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_arg_max_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ def _teller7(program_config, predictor_config):
_teller5, IgnoreReasons.PADDLELITE_NOT_SUPPORT,
"Lite does not support 'in_shape_size == 1' on kunlunxin_xtcl.")

self.add_ignore_check_case(_teller6,
IgnoreReasons.PADDLELITE_NOT_SUPPORT,
"Only test 0D-tensor on CPU(ARM/Host) now.")
self.add_ignore_check_case(
_teller6, IgnoreReasons.PADDLELITE_NOT_SUPPORT,
"0D-tensor is not supported on this target now.")

self.add_ignore_check_case(_teller7,
IgnoreReasons.PADDLELITE_NOT_SUPPORT,
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_asin_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_assign_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_atan_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_bitwise_and_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_bitwise_not_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_cast_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_ceil_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_clip_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_compare_less_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_cos_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lite/tests/unittest_py/op/test_dropout_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_div_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_floordiv_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_max_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_min_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_mod_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 test(self, *args, **kwargs):
self.run_and_statis(quant=False, max_examples=300)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_mul_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_pow_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elementwise_sub_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lite/tests/unittest_py/op/test_elu_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading