Skip to content

Commit abccd24

Browse files
committed
code clean up
Signed-off-by: Min, Byungil <[email protected]>
1 parent 124eedd commit abccd24

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/plugins/intel_gpu/src/kernel_selector/cl_kernels/col_to_im_opt.cl

+5-10
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,20 @@ KERNEL(col_to_im_opt)(const __global INPUT0_TYPE* input,
1818
const uint pads_begin[2] = {PAD_BEGIN_SIZE_X, PAD_BEGIN_SIZE_Y};
1919
const uint pads_end[2] = {PAD_END_SIZE_X, PAD_END_SIZE_Y};
2020

21-
const uint num_blocks = INPUT0_SIZE_Y;
22-
const uint kernel_product = KERNEL_SIZE_X * KERNEL_SIZE_Y;
23-
const uint channels_per_column = INPUT0_FEATURE_NUM;
24-
const uint channel_count = channels_per_column / kernel_product;
25-
2621
const uint batch_count = INPUT0_BATCH_NUM;
2722
const uint batch = get_global_id(2);
2823

29-
// printf("batch(%d) num_blocks(%u) output(%u, %u), channel(%u, %u) original_height(%u) original_width(%u) \n",
24+
// printf("batch(%d) num_blocks(%u) output(%u, %u), kernel(%u, %u) original_height(%u) original_width(%u) \n",
3025
// batch, num_blocks, (uint)OUT_SIZE_X, (uint)OUT_SIZE_Y, (uint)KERNEL_SIZE_X, (uint)KERNEL_SIZE_Y, ORIG_HEIGHT, ORIG_WIDTH);
3126

3227
// for (uint batch = 0; batch < batch_count; ++batch) {
33-
for (uint column = 0; column < channels_per_column; ++column) {
28+
for (uint column = 0; column < NUM_ELEMENTS_FOR_BLOCK; ++column) {
3429
const uint width_offset = column % kernel_size[1];
3530
const uint height_offset = (column / kernel_size[1]) % kernel_size[0];
36-
const uint channel_idx = column / kernel_product;
31+
const uint channel_idx = column / KERNEL_PRODUCT;
3732

38-
const uint out_idx = (batch * channel_count + channel_idx) * output_size[0];
39-
const uint height_idx = (batch * channels_per_column + column) * ORIG_HEIGHT;
33+
const uint out_idx = (batch * NUM_CHANNELS + channel_idx) * output_size[0];
34+
const uint height_idx = (batch * NUM_ELEMENTS_FOR_BLOCK + column) * ORIG_HEIGHT;
4035

4136
for (uint column_height_idx = 0; column_height_idx < ORIG_HEIGHT; ++column_height_idx) {
4237
// get_image_dimension_index(column_height_idx, height_offset, 0);

src/plugins/intel_gpu/src/kernel_selector/kernels/col_to_im/col_to_im_kernel_base.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,28 @@ bool ColToImKernelBase::Validate(const Params& p) const {
2828

2929
JitConstants ColToImKernelBase::GetJitConstants(const col_to_im_params& params) const {
3030
JitConstants jit = MakeBaseParamsJitConstants(params);
31+
auto input = params.inputs[0];
3132
const auto& output_size = params.output_size;
3233
const auto& stride = params.stride;
3334
const auto& dilation = params.dilation;
3435
const auto& pads_begin = params.padding_begin;
3536
const auto& pads_end = params.padding_begin;
3637

37-
// Get original dimension
38-
const uint orig_height = (output_size.x + pads_begin.x + pads_end.x - (dilation.x * (params.kernel_size.x - 1) + 1)) / stride.x + 1;
39-
const uint orig_width = (output_size.y + pads_begin.y + pads_end.y - (dilation.y * (params.kernel_size.y - 1) + 1)) / stride.y + 1;
38+
const auto orig_height = (output_size.x + pads_begin.x + pads_end.x - (dilation.x * (params.kernel_size.x - 1) + 1)) / stride.x + 1;
39+
const auto orig_width = (output_size.y + pads_begin.y + pads_end.y - (dilation.y * (params.kernel_size.y - 1) + 1)) / stride.y + 1;
4040
jit.AddConstant(MakeJitConstant("ORIG_HEIGHT", orig_height));
4141
jit.AddConstant(MakeJitConstant("ORIG_WIDTH", orig_width));
4242

43+
// Consider input tensor : (N, C * Product(kernel_size), L)
44+
const auto num_elements_for_block = input.Feature().v;
45+
const auto num_blocks = input.Y().v;
46+
const auto kernel_product = params.kernel_size.x * params.kernel_size.y;
47+
const auto num_channels = num_elements_for_block / kernel_product;
48+
jit.AddConstant(MakeJitConstant("NUM_ELEMENTS_FOR_BLOCK", num_elements_for_block));
49+
jit.AddConstant(MakeJitConstant("KERNEL_PRODUCT", kernel_product));
50+
jit.AddConstant(MakeJitConstant("NUM_CHANNELS", num_channels));
51+
jit.AddConstant(MakeJitConstant("NUM_BLOCKS", num_blocks));
52+
4353
jit.AddConstant(MakeJitConstant("OUT", params.output_size));
4454
jit.AddConstant(MakeJitConstant("KERNEL", params.kernel_size));
4555
jit.AddConstant(MakeJitConstant("STRIDE", stride));

src/plugins/intel_gpu/src/kernel_selector/kernels/col_to_im/col_to_im_kernel_opt.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ CommonDispatchData ColToImKernelOpt::SetDefault(const col_to_im_params& params)
5656
// dispatchData.gws = {1, 1, 1};
5757
dispatchData.lws = {1, 1, 1};
5858

59-
std::cout << " Select ColToImKernelOpt : gws(" << dispatchData.gws[0] << ", " << dispatchData.gws[1] << ", " << dispatchData.gws[2] << ")" << std::endl;
60-
std::cout << " Select ColToImKernelOpt : lws(" << dispatchData.lws[0] << ", " << dispatchData.lws[1] << ", " << dispatchData.lws[2] << ")" << std::endl;
59+
// std::cout << " Select ColToImKernelOpt : gws(" << dispatchData.gws[0] << ", " << dispatchData.gws[1] << ", " << dispatchData.gws[2] << ")" << std::endl;
60+
// std::cout << " Select ColToImKernelOpt : lws(" << dispatchData.lws[0] << ", " << dispatchData.lws[1] << ", " << dispatchData.lws[2] << ")" << std::endl;
6161

6262
return dispatchData;
6363
}

src/plugins/intel_gpu/src/plugin/ops/col_to_im.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static void CreateCol2ImOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v15:
3333
for (auto p: op->get_pads_end())
3434
padding_end.push_back(p);
3535

36+
// std::cout << ">> col2im : " << op->get_friendly_name() << std::endl;
37+
3638
auto output_shape_const = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(1));
3739
auto vec_output_shape = output_shape_const->cast_vector<size_t>();
3840
ov::Shape output_shape(vec_output_shape);
@@ -41,7 +43,11 @@ static void CreateCol2ImOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v15:
4143
auto kernel_size = kernel_size_const->cast_vector<size_t>();
4244
ov::Shape kernel_shape(kernel_size);
4345

46+
// std::cout << " -- output shape : " << vec_output_shape[0] << ", " << vec_output_shape[1] << std::endl;
47+
// std::cout << " -- kernel size : " << kernel_shape.to_string() << std::endl;
48+
4449
// Create col2im prim
50+
// iputs : data, output size, kernel_size(required)
4551
auto CallToImPrim = cldnn::col_to_im(layerName,
4652
inputPrimitives[0],
4753
inputPrimitives[1],

0 commit comments

Comments
 (0)