From 2c05abda1d5d2f9f60da5a6bb90d344f9182cc02 Mon Sep 17 00:00:00 2001 From: Yuan Shuai Date: Sat, 14 Mar 2020 17:03:16 +0800 Subject: [PATCH] [LITE][DEMO] Fix mobile light demo (#3180) * [LITE][OPENCL] Change fp32 fc to fp16's. test=develop * fix act in conv3x3opt opencl kernel. test=develop * [LITE][DEMO] fix input arg. test=develop * fix shutdownlog for std::endl. test=develop --- .../cl_kernel/image/conv2d_3x3_opt_kernel.cl | 30 +++++++++---------- .../cxx/mobile_light/mobilenetv1_light_api.cc | 8 ++--- lite/kernels/opencl/conv_image_compute.cc | 4 +-- .../elementwise_add_buffer_compute_test.cc | 2 +- .../elementwise_add_image_compute_test.cc | 2 +- .../elementwise_mul_image_compute_test.cc | 2 +- .../elementwise_sub_image_compute_test.cc | 2 +- .../opencl/grid_sampler_image_compute_test.cc | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl b/lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl index a9d3d4d44a..468dd1a8a3 100644 --- a/lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl +++ b/lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl @@ -14,23 +14,23 @@ limitations under the License. */ #include -__kernel void conv2d_3x3(__private const int item_ch, - __private const int item_w, - __private const int item_h, - __read_only image2d_t input_image, - __read_only image2d_t filter_image, +__kernel void conv2d_3x3_opt(__private const int item_ch, + __private const int item_w, + __private const int item_h, + __read_only image2d_t input_image, + __read_only image2d_t filter_image, #if defined(BIASE_CH) || defined(BIASE_ELE) - __read_only image2d_t bias, + __read_only image2d_t bias, #endif - __write_only image2d_t output_image, - __private const int stride, - __private const int pad, - __private const int dilation, - __private const int in_ch, - __private const int in_w, - __private const int in_h, - __private const int out_w, - __private const int out_h) { + __write_only image2d_t output_image, + __private const int stride, + __private const int pad, + __private const int dilation, + __private const int in_ch, + __private const int in_w, + __private const int in_h, + __private const int out_w, + __private const int out_h) { const sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST; diff --git a/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc b/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc index 0d09c6e928..3eaf63e7f9 100644 --- a/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc +++ b/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc @@ -31,7 +31,7 @@ int64_t ShapeProduction(const shape_t& shape) { std::string ShapePrint(const shape_t& shape) { std::string shape_str{""}; for (auto i : shape) { - shape_str = shape_str + std::to_string(i) + " "; + shape_str += std::to_string(i) + " "; } return shape_str; } @@ -153,9 +153,9 @@ int main(int argc, char** argv) { std::string model_dir = argv[1]; if (argc >= 9) { input_shape[0] = atoi(argv[2]); - input_shape[1] = atoi(argv[4]); - input_shape[2] = atoi(argv[5]); - input_shape[3] = atoi(argv[6]); + input_shape[1] = atoi(argv[3]); + input_shape[2] = atoi(argv[4]); + input_shape[3] = atoi(argv[5]); repeats = atoi(argv[6]); warmup = atoi(argv[7]); print_output_elem = atoi(argv[8]); diff --git a/lite/kernels/opencl/conv_image_compute.cc b/lite/kernels/opencl/conv_image_compute.cc index 859db34f0c..04692d9d75 100644 --- a/lite/kernels/opencl/conv_image_compute.cc +++ b/lite/kernels/opencl/conv_image_compute.cc @@ -98,7 +98,7 @@ void ConvImageCompute::PrepareForRun() { filter_image_dims[0], filter_image_dims[1], filter_image_v.data()); impl_ = &ConvImageCompute::Conv2d1x1; -// # define DEPTH_CONV_USE_SPL +// #define DEPTH_CONV_USE_SPL #ifdef DEPTH_CONV_USE_SPL } else if (filter_dims[1] == 1 && x_dims[1] == output_dims[1] && kernel_h == 3 && kernel_w == 3 && groups > 1) { @@ -142,7 +142,7 @@ void ConvImageCompute::PrepareForRun() { impl_ = &ConvImageCompute::DepthwiseConv2d; } else if (kernel_h == 3 && kernel_h == 3) { // conv2d_3x3 - kernel_func_names_.push_back("conv2d_3x3"); + kernel_func_names_.push_back("conv2d_3x3_opt"); kernel_func_paths_.push_back("image/conv2d_3x3_opt_kernel.cl"); CLImageConverterFolder converter; diff --git a/lite/kernels/opencl/elementwise_add_buffer_compute_test.cc b/lite/kernels/opencl/elementwise_add_buffer_compute_test.cc index 06f946bca7..67b56c7477 100644 --- a/lite/kernels/opencl/elementwise_add_buffer_compute_test.cc +++ b/lite/kernels/opencl/elementwise_add_buffer_compute_test.cc @@ -87,7 +87,7 @@ void elementwise_compute_ref(const dtype *x_data, } } } else { - LOG(FATAL) << "unsupported Elementwise type: " << elt_type << std::endl; + LOG(FATAL) << "unsupported Elementwise type: " << elt_type; } } diff --git a/lite/kernels/opencl/elementwise_add_image_compute_test.cc b/lite/kernels/opencl/elementwise_add_image_compute_test.cc index ecc9e789c4..c7fb0b07b2 100644 --- a/lite/kernels/opencl/elementwise_add_image_compute_test.cc +++ b/lite/kernels/opencl/elementwise_add_image_compute_test.cc @@ -87,7 +87,7 @@ void elementwise_compute_ref(const dtype *x_data, } } } else { - LOG(FATAL) << "unsupported Elementwise type: " << elt_type << std::endl; + LOG(FATAL) << "unsupported Elementwise type: " << elt_type; } } diff --git a/lite/kernels/opencl/elementwise_mul_image_compute_test.cc b/lite/kernels/opencl/elementwise_mul_image_compute_test.cc index 06d0d4f7b4..cb63f333e6 100644 --- a/lite/kernels/opencl/elementwise_mul_image_compute_test.cc +++ b/lite/kernels/opencl/elementwise_mul_image_compute_test.cc @@ -106,7 +106,7 @@ void elementwise_compute_ref(const dtype *x_data, out_data[x] = x_data[x] * y_data[y]; } } else { - LOG(FATAL) << "unsupported Elementwise type: " << elt_type << std::endl; + LOG(FATAL) << "unsupported Elementwise type: " << elt_type; } } diff --git a/lite/kernels/opencl/elementwise_sub_image_compute_test.cc b/lite/kernels/opencl/elementwise_sub_image_compute_test.cc index 0593747547..61a7aa4447 100644 --- a/lite/kernels/opencl/elementwise_sub_image_compute_test.cc +++ b/lite/kernels/opencl/elementwise_sub_image_compute_test.cc @@ -87,7 +87,7 @@ void elementwise_compute_ref(const dtype *x_data, } } } else { - LOG(FATAL) << "unsupported Elementwise type: " << elt_type << std::endl; + LOG(FATAL) << "unsupported Elementwise type: " << elt_type; } } diff --git a/lite/kernels/opencl/grid_sampler_image_compute_test.cc b/lite/kernels/opencl/grid_sampler_image_compute_test.cc index afdebc0e64..5851950bec 100644 --- a/lite/kernels/opencl/grid_sampler_image_compute_test.cc +++ b/lite/kernels/opencl/grid_sampler_image_compute_test.cc @@ -224,7 +224,7 @@ TEST(grid_samler_image2d, compute) { #ifdef GRID_FP16_PRINT_RESULT LOG(INFO) << "---- print kernel result (input -> output) ----"; for (int eidx = 0; eidx < in_dim.production(); ++eidx) { - std::cout << input_v[eidx] << " -> " << out_data[eidx] << std::endl; + std::cout << input_v[eidx] << " -> " << out_data[eidx] << "\n"; } #endif // GRID_FP16_PRINT_RESULT for (int i = 0; i < out_dim.production(); i++) { -- GitLab