Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 0d autoscan for X86, Metal, OpenCL #10275

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions lite/kernels/opencl/activation_image_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,6 @@ class ActivationComputeImageDefault
CL_CHECK_FATAL(status);
}

#ifdef LITE_WITH_LOG
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个Log信息为啥要删除呀,是因为 x_dims[1] << " " << x_dims[2] << " " << x_dims[3] 这种会访存越界吗

Copy link
Contributor Author

@lishicheng1996 lishicheng1996 May 17, 2023

Choose a reason for hiding this comment

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

是的,x_dims的size可能为0, 引发错误。这个pr还没有完全ok,metal elementwise op暂时屏蔽掉了,我还在看。

const auto& x_dims = act_param_->X->dims();
const auto& y_dims = act_param_->Out->dims(); // useless: check dim only
VLOG(4) << TargetToStr(act_param_->X->target());
VLOG(4) << TargetToStr(act_param_->Out->target());
VLOG(4) << "x_img_shape_(w,h):" << x_img_shape_[0] << " "
<< x_img_shape_[1];
VLOG(4) << "x_dims[" << x_dims.size() << "D]:" << x_dims[0] << " "
<< x_dims[1] << " " << x_dims[2] << " " << x_dims[3];
VLOG(4) << "y_dims[" << y_dims.size() << "D]:" << y_dims[0] << " "
<< y_dims[1] << " " << y_dims[2] << " " << y_dims[3];
VLOG(4) << "threshold:" << threshold_;
VLOG(4) << "scale:" << scale_;
VLOG(4) << "kernel func name:" << kernel_func_name_;
#endif

auto& context = ctx_->As<OpenCLContext>();
CHECK(context.cl_context() != nullptr);
status = EnqueueNDRangeKernel(context,
Expand Down Expand Up @@ -349,20 +333,6 @@ class SqrtComputeImageDefault : public ActivationComputeImageDefault {
status = kernel.setArg(1, *out_img);
CL_CHECK_FATAL(status);

#ifdef LITE_WITH_LOG
const auto& x_dims = act_param_->X->dims();
const auto& y_dims = act_param_->Out->dims(); // useless: check dim only
VLOG(4) << TargetToStr(act_param_->X->target());
VLOG(4) << TargetToStr(act_param_->Out->target());
VLOG(4) << "x_img_shape_(w,h):" << x_img_shape_[0] << " "
<< x_img_shape_[1];
VLOG(4) << "x_dims[" << x_dims.size() << "D]:" << x_dims[0] << " "
<< x_dims[1] << " " << x_dims[2] << " " << x_dims[3];
VLOG(4) << "y_dims[" << y_dims.size() << "D]:" << y_dims[0] << " "
<< y_dims[1] << " " << y_dims[2] << " " << y_dims[3];
VLOG(4) << "kernel func name:" << kernel_func_name_;
#endif

auto& context = ctx_->As<OpenCLContext>();
CHECK(context.cl_context() != nullptr);
status = EnqueueNDRangeKernel(context,
Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_abs_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_acos_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_arg_max_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ def _teller5(program_config, predictor_config):
def _teller6(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
2 changes: 1 addition & 1 deletion lite/tests/unittest_py/op/test_argsort_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
#if target_type != TargetType.ARM and target_type != TargetType.Host:
#if target_type not in [TargetType.ARM, TargetType.Host, TargetType.X86, TargetType.Metal, TargetType.OpenCL]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_asin_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_assign_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def teller1(program_config, predictor_config):
def _teller2(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_atan_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_bitwise_and_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
in_y_shape = list(program_config.inputs["input_data1"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_bitwise_not_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
7 changes: 5 additions & 2 deletions lite/tests/unittest_py/op/test_cast_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=metal_places)
# self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(TargetType.NNAdapter, PrecisionType.FP32)
self.enable_devices_on_nnadapter(device_names=[
"cambricon_mlu", "nvidia_tensorrt", "intel_openvino"
Expand Down Expand Up @@ -140,7 +140,10 @@ def _teller2(program_config, predictor_config):
def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_ceil_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_clip_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def teller2(program_config, predictor_config):
def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_compare_less_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["data_x"].shape)
in_y_shape = list(program_config.inputs["data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_cos_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

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 @@ -172,7 +172,7 @@ def _teller1(program_config, predictor_config):
# def _teller2(program_config, predictor_config):
# target_type = predictor_config.target()
# in_x_shape = list(program_config.inputs["input_data"].shape)
# if target_type != TargetType.ARM and target_type != TargetType.Host:
# if target_type not in [TargetType.ARM, TargetType.Host, TargetType.X86, TargetType.Metal, TargetType.OpenCL]:
# if len(in_x_shape) == 0:
# return True

Expand Down
7 changes: 5 additions & 2 deletions lite/tests/unittest_py/op/test_elementwise_add_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=metal_places)
# self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(
TargetType.ARM,
PrecisionType.FP16,
Expand Down Expand Up @@ -186,7 +186,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
7 changes: 5 additions & 2 deletions lite/tests/unittest_py/op/test_elementwise_div_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=metal_places)
# self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(
TargetType.ARM,
PrecisionType.FP16,
Expand Down Expand Up @@ -191,7 +191,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elementwise_floordiv_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elementwise_max_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elementwise_min_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elementwise_mod_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
7 changes: 5 additions & 2 deletions lite/tests/unittest_py/op/test_elementwise_mul_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=metal_places)
# self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(
TargetType.ARM,
PrecisionType.FP16,
Expand Down Expand Up @@ -186,7 +186,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elementwise_pow_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
7 changes: 5 additions & 2 deletions lite/tests/unittest_py/op/test_elementwise_sub_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=metal_places)
# self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(
TargetType.ARM,
PrecisionType.FP16,
Expand Down Expand Up @@ -187,7 +187,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_elu_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def add_ignore_pass_case(self):
def _teller1(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0:
return True

Expand Down
5 changes: 4 additions & 1 deletion lite/tests/unittest_py/op/test_equal_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def _teller3(program_config, predictor_config):
target_type = predictor_config.target()
in_x_shape = list(program_config.inputs["input_data_x"].shape)
in_y_shape = list(program_config.inputs["input_data_y"].shape)
if target_type != TargetType.ARM and target_type != TargetType.Host:
if target_type not in [
TargetType.ARM, TargetType.Host, TargetType.X86,
TargetType.Metal, TargetType.OpenCL
]:
if len(in_x_shape) == 0 or len(in_y_shape) == 0:
return True

Expand Down
Loading