Skip to content

[IE CLDNN] Add new operation GatherND-5 to IE clDNN plugin#4857

Merged
vladimir-paramuzov merged 2 commits intoopenvinotoolkit:masterfrom
kelvinchoi-intel:kelvin/GatherND
Apr 12, 2021
Merged

[IE CLDNN] Add new operation GatherND-5 to IE clDNN plugin#4857
vladimir-paramuzov merged 2 commits intoopenvinotoolkit:masterfrom
kelvinchoi-intel:kelvin/GatherND

Conversation

@kelvinchoi-intel
Copy link
Copy Markdown
Contributor

@kelvinchoi-intel kelvinchoi-intel commented Mar 18, 2021

Signed-off-by: Kelvin Choi kelvin.choi@intel.com

ID: 48366

Details:

  • Add new operation GatherND-5 to IE clDNN plugin
  • Add fusing with quantize, activation, scale, and eltwise

@kelvinchoi-intel kelvinchoi-intel requested review from a team as code owners March 18, 2021 07:55
@kelvinchoi-intel kelvinchoi-intel requested a review from a team March 18, 2021 07:55
@openvino-pushbot openvino-pushbot added category: GPU OpenVINO GPU plugin category: IE Tests OpenVINO Test: plugins and common labels Mar 18, 2021
@kelvinchoi-intel kelvinchoi-intel force-pushed the kelvin/GatherND branch 2 times, most recently from b57cde3 to 2958651 Compare March 18, 2021 14:01
@kelvinchoi-intel kelvinchoi-intel marked this pull request as draft March 19, 2021 01:33
@kelvinchoi-intel kelvinchoi-intel force-pushed the kelvin/GatherND branch 3 times, most recently from 03f0913 to ccc6ede Compare March 22, 2021 04:44
@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

CI issues:

  • ci/jenkins: can't trigger (Oops icon is displayed)
  • OpenVINO ONNX CI: ssh: connect to host gitlab-icv.inn.intel.com port 22: Connection timed out

@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

@vladimir-paramuzov Please review this.

@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

@sshlyapn Please review this

@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

@vladimir-paramuzov @sshlyapn Please review and merge this if no issue.

Copy link
Copy Markdown
Contributor

@lznamens lznamens left a comment

Choose a reason for hiding this comment

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

In general LGTM. Please make some cosmetic fixes.

{ {15, 12, 20, 15, 2}, {15, 12, 18, 7, 17} })), // Data shape
::testing::ValuesIn(std::vector<std::vector<size_t>>(
{ {15, 12, 2}, {15, 12, 5, 9, 1, 3} })), // Indices shape
::testing::ValuesIn(std::vector<int>({ 1, 2 })) // Batch dims
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please align this comment as others.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

const uint dim1 = get_global_id(1);
const uint dim2 = get_global_id(2);

//Calculate indice index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add space after "//".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.


const uint idx_arr[INPUT1_DIMS*2] = {idx_b, idx_f, idx_z, idx_y, idx_x, 0, 0, 0, 0, 0};
const uint idx_dim[INPUT1_DIMS] = {INPUT1_BATCH_NUM, INPUT1_FEATURE_NUM, INPUT1_SIZE_Z, INPUT1_SIZE_Y, INPUT1_SIZE_X};
#elif INPUT1_DIMS == 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you use "elif" construction here? If there may be another INPUT1_DIMS cases then unexpected result will be here. My point is that we should use "else" construction in cases when all possible variants are under "if" or use "#error" message after #elif INPUT1_DIMS == 6 when there may be something else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, as I can see, we have all input and output dimenshion checks in code lines from 20 to 42. What do you think, may be, it'll be better to add 3 preprocessing "#error" directives here (into lines 20 - 42). And after that in the kernel body to use such construction as:

#if DIMS_NUM == 4
...
#elif DIMS_NUM == 5
...
#else
...
#endif

In this case all unsupported dimension checks will be in a one place before the kernel body. I'm sorry that I didn't see it in my first review attempt...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about DIMS_NUM == 2 or 3? I think DIMS_NUM < 4 case should go else(#error). So the #elif DIMS_NUM ==6 and #else are need.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can process all these variants here:

#if INPUT0_DIMS == 4
    #define IN_ORDER in_b,in_f,in_y,in_x
#elif INPUT0_DIMS == 5
    #define IN_ORDER in_b,in_f,in_z,in_y,in_x
#elif INPUT0_DIMS == 6
    #define IN_ORDER in_b,in_f,in_w,in_z,in_y,in_x
#else
#error gather_nd_ref.cl - not supported INPUT0_DIMS_NUM
#endif

And the same for INPUT1_DIMS and OUTPUT_DIMS. As for me, this will simplify your code in the kernel body. You'll may use only:

#if INPUT1_DIMS == 4
   ...
#elif INPUT1_DIMS == 5
   ...
#else
   ...
#endif

And all checks for DIMS NUM will be placed before the kernel body.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I made the code simple as you your suggestion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought that you'll make error processing before the kernel body but I suppose your variant also'll work corectly because in GetSupportedKeys method we have only simple bfyx, bfzyx, bfwzyx formats for input and output layouts. Thanks.

const uint in_x = indices_val[4];
const uint in_y = indices_val[3];
const uint in_z = indices_val[2];
#elif INPUT0_DIMS == 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same as for line 82 is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

const uint out_x = idx_arr[BATCH_DIMS+3];
const uint out_y = idx_arr[BATCH_DIMS+2];
const uint out_z = idx_arr[BATCH_DIMS+1];
#elif OUTPUT_DIMS == 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same as for line 82 is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

const uint y_pitch = OUTPUT_SIZE_X;
const uint z_pitch = y_pitch * OUTPUT_SIZE_Y;
const uint f_pitch = z_pitch * OUTPUT_SIZE_Z;
#elif OUTPUT_DIMS == 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same as for line 82 is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.


const uint z = f_remain / z_pitch;
const uint y = z_remain / y_pitch;
#elif OUTPUT_DIMS == 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same as for line 82 is here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

const uint f = b_remain / f_pitch;
const uint x = y_remain;

FUSED_OPS;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe it makes sence to try use FUSED_OPS_PRELOAD and FUSED_OPS_CALC macro for getting better perf values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

layout gather_nd_inst::calc_output_layout(gather_nd_node const& node) {
auto op = node.get_primitive();

auto input_layout_orgin = node.input(0).get_output_layout();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I amn't sure but maybe "input_layout_origin"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ooops. It was a typo. I've fixed.

Signed-off-by: Kelvin Choi <kelvin.choi@intel.com>
@kelvinchoi-intel kelvinchoi-intel force-pushed the kelvin/GatherND branch 2 times, most recently from 49c389e to c53e66b Compare April 6, 2021 14:07
@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

@lznamens @vladimir-paramuzov CI passed. Please review this.

Signed-off-by: Kelvin Choi <kelvin.choi@intel.com>
@kelvinchoi-intel
Copy link
Copy Markdown
Contributor Author

@lznamens @vladimir-paramuzov Please merge this unless there is more comment.

@vladimir-paramuzov vladimir-paramuzov dismissed lznamens’s stale review April 12, 2021 04:40

Comments have been addressed

@vladimir-paramuzov vladimir-paramuzov merged commit 9f93509 into openvinotoolkit:master Apr 12, 2021
@kelvinchoi-intel kelvinchoi-intel deleted the kelvin/GatherND branch March 23, 2023 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: GPU OpenVINO GPU plugin category: IE Tests OpenVINO Test: plugins and common

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants