diff --git a/mobile/src/framework/cl/cl_helper.h b/mobile/src/framework/cl/cl_helper.h index 09beb7c72f5739d0d997055b59eadadd40239a3f..893456211d0429701b49d0f0be654beaad16e0e2 100644 --- a/mobile/src/framework/cl/cl_helper.h +++ b/mobile/src/framework/cl/cl_helper.h @@ -66,9 +66,9 @@ class CLHelper { auto h = image_dim[2]; auto w = image_dim[3]; auto image_width = image.ImageWidth(); - auto work_size_0 = image_width / w; - auto work_size_1 = w; - auto work_size_2 = n * h; + size_t work_size_0 = image_width / w; + size_t work_size_1 = w; + size_t work_size_2 = n * h; return {work_size_0, work_size_1, work_size_2}; } else if (image_dim.size() == 2) { auto h = image_dim[0]; @@ -77,9 +77,9 @@ class CLHelper { } else if (image_dim.size() == 1) { return {1, image.ImageWidth(), 1}; } else if (image_dim.size() == 3) { - int c = image_dim[0]; - int h = image_dim[1]; - int w = image_dim[2]; + size_t c = image_dim[0]; + size_t h = image_dim[1]; + size_t w = image_dim[2]; return {(c + 3) / 4, w, h}; } PADDLE_MOBILE_THROW_EXCEPTION(" not support this dim, need imp "); diff --git a/mobile/src/framework/cl/cl_image.cpp b/mobile/src/framework/cl/cl_image.cpp index 4f4b0d8883586e221b9178a104a7f295fab06f83..0d4cf87db0d34953936d107b6bb6c9adbd985560 100644 --- a/mobile/src/framework/cl/cl_image.cpp +++ b/mobile/src/framework/cl/cl_image.cpp @@ -119,8 +119,8 @@ void TensorToCLImage(Tensor *tensor, CLImage *cl_image, cl_context context, #ifdef PADDLE_MOBILE_DEBUG Print &operator<<(Print &printer, const CLImage &cl_image) { - int width = cl_image.ImageDims()[0]; - int height = cl_image.ImageDims()[1]; + size_t width = cl_image.ImageDims()[0]; + size_t height = cl_image.ImageDims()[1]; half_t *image_data = new half_t[height * width * 4]; cl_int err; diff --git a/mobile/src/framework/cl/cl_image.h b/mobile/src/framework/cl/cl_image.h index f648ca04436c2f639e5ad1881075d471e8f54a25..3a09436a1f57d164bd51cb16f2a453faaf88b5e7 100644 --- a/mobile/src/framework/cl/cl_image.h +++ b/mobile/src/framework/cl/cl_image.h @@ -177,7 +177,7 @@ class CLImage { * init cl mem with a exist cl mem */ void InitWithExistMem(cl_context context, cl_command_queue command_queue, - DDim need_dims, CLImage &src) { + DDim need_dims, const CLImage &src) { CLImageConverterNormal *normal_converter = new CLImageConverterNormal(); real_image_dims_ = src.real_image_dims_; @@ -271,7 +271,8 @@ class CLImage { CLImageConverterBase *Converter() const { return image_converter_; } private: - void InitCLImage(cl_context context, int width, int height, void *data) { + void InitCLImage(cl_context context, size_t width, size_t height, + void *data) { cl_image_format cf = {.image_channel_order = CL_RGBA, .image_channel_data_type = CL_HALF_FLOAT}; cl_image_desc cid = { diff --git a/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp b/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp index 1506956280a489ebf9631099101c1ac0f0bf03ec..06d718601cc885ac100dc29a4879b88ce9384736 100644 --- a/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp +++ b/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp @@ -77,8 +77,8 @@ void ElementwiseAddKernel::Compute( status = clSetKernelArg(kernel, 2, sizeof(cl_mem), reinterpret_cast(&output_image)); CL_CHECK_ERRORS(status); - int width = input->ImageWidth(); - int height = input->ImageHeight(); + auto width = input->ImageWidth(); + auto height = input->ImageHeight(); size_t global_work_size[2] = {width, height}; status = clEnqueueNDRangeKernel(this->cl_helper_.CLCommandQueue(), kernel, 2, @@ -103,8 +103,8 @@ void ElementwiseAddKernel::Compute( status = clSetKernelArg(kernel, 3, sizeof(cl_int), reinterpret_cast(&tensor_w)); CL_CHECK_ERRORS(status); - int width = input->ImageWidth(); - int height = input->ImageHeight(); + auto width = input->ImageWidth(); + auto height = input->ImageHeight(); DLOG << "dede:" << width << "," << height; size_t global_work_size[2] = {width, height}; cl_event out_event = param.Out()->GetClEvent(); diff --git a/mobile/src/operators/kernel/cl/prior_box_kernel.cpp b/mobile/src/operators/kernel/cl/prior_box_kernel.cpp index 92764b379e8dad8070407fcf012b4bad73fd19a1..c10bfed8d1a21d6578258a28259e883422342085 100644 --- a/mobile/src/operators/kernel/cl/prior_box_kernel.cpp +++ b/mobile/src/operators/kernel/cl/prior_box_kernel.cpp @@ -121,9 +121,9 @@ void PriorBoxKernel::Compute( auto kernel = this->cl_helper_.KernelAt(0); auto default_work_size = this->cl_helper_.DefaultWorkSize(*param.OutputBoxes()); - int c_block = default_work_size[0]; - int w = default_work_size[1]; - int nh = default_work_size[2]; + auto c_block = default_work_size[0]; + auto w = default_work_size[1]; + auto nh = default_work_size[2]; std::vector box_shape({num_priors}); framework::DDim ddim = framework::make_ddim(box_shape); diff --git a/mobile/test/net/test_net.cpp b/mobile/test/net/test_net.cpp index 74a124e46cd45f83b552119d99e8b831aed8c446..0251d774dd457195341fd53ba27add3903ee2c63 100644 --- a/mobile/test/net/test_net.cpp +++ b/mobile/test/net/test_net.cpp @@ -185,8 +185,8 @@ void test(int argc, char *argv[]) { if (len == 0) { continue; } - int width = cl_image->ImageDims()[0]; - int height = cl_image->ImageDims()[1]; + size_t width = cl_image->ImageDims()[0]; + size_t height = cl_image->ImageDims()[1]; paddle_mobile::framework::half_t *image_data = new paddle_mobile::framework::half_t[height * width * 4]; cl_int err;