Skip to content

Commit

Permalink
Fix gather kernel bug for handling 5 and 6 dimensions (openvinotoolki…
Browse files Browse the repository at this point in the history
…t#26894)

### Details:
The calculation to generate INDICES_INDEX_ORDER is wrong.

For 5 dimension, INDICES_INDEX_ORDER should be
b, f, 0, z, 0 or b, f, 0, 0, z

For 6 dimension, INDICES_INDEX_ORDER should be
b, f, 0, w, z, 0 or b, f, 0, w, 0,z

To simplify the generation, generate b,f,0,z,0 for 5 dims and
b,f,0,w,z,0 for 6 dimsm

### Tickets:
 - [*CVS-150766*](https://jira.devtools.intel.com/browse/CVS-150766)

Co-authored-by: Pavel Durandin <[email protected]>
  • Loading branch information
clee30 and p-durandin authored Oct 14, 2024
1 parent 136e59c commit 9c432a3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ static inline std::vector<std::string> GetOrder(size_t size) {
return idx_order;
}

static inline std::vector<std::string> GetFinalIndexOrder(size_t size) {
std::vector<std::string> idx_order;

OPENVINO_ASSERT(size > 4, "[GPU] Only support 5 or 6 dimensions");

if (size == 5) {
idx_order = {"b", "f", "0", "z", "0"};
} else if (size == 6) {
idx_order = {"b", "f", "0", "w", "z", "0"};
}
return idx_order;
}

static std::string GetDictionaryIndexOrder(const gather_params& params, size_t axis) {
auto idx_order = GetOrder(params.outputs[0].GetDims().size());
auto input_axis_index_macro = "INPUT_AXIS_INDEX";
Expand All @@ -181,21 +194,27 @@ static std::string GetDictionaryIndexOrder(const gather_params& params, size_t a
}

static std::string GetIndicesIdxOrder(const gather_params& params, size_t axis, int64_t batch_dim) {
std::vector<std::string> idx_order = GetOrder(params.outputs[0].GetDims().size());
auto zero_val = "0";
std::vector<std::string> idx_order;

size_t indices_dims_num = GetNonEmptyDimsNumber(params.inputs[1]);
if ((axis == (size_t)batch_dim) && (axis > 1) && (params.inputs[1].GetDims().size() > 4)) {
idx_order = GetFinalIndexOrder(params.outputs[0].GetDims().size());
} else {
idx_order = GetOrder(params.outputs[0].GetDims().size());
auto zero_val = "0";

// Shift indices of Gather indices input related to output dims
for (size_t i = batch_dim; i < indices_dims_num; i++)
idx_order[i] = idx_order[axis + i - batch_dim];
size_t indices_dims_num = GetNonEmptyDimsNumber(params.inputs[1]);

for (size_t i = indices_dims_num; i < idx_order.size(); i++)
idx_order[i] = zero_val;
// Shift indices of Gather indices input related to output dims
for (size_t i = batch_dim; i < indices_dims_num; i++)
idx_order[i] = idx_order[axis + i - batch_dim];

// Fix size to inputs[1] dims size
for (size_t i = 0; i < params.outputs[0].GetDims().size() - params.inputs[1].GetDims().size(); i++)
idx_order.pop_back();
for (size_t i = indices_dims_num; i < idx_order.size(); i++)
idx_order[i] = zero_val;

// Fix size to inputs[1] dims size
for (size_t i = 0; i < params.outputs[0].GetDims().size() - params.inputs[1].GetDims().size(); i++)
idx_order.pop_back();
}

return GetOrderString(idx_order);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/layer_tests/tensorflow_tests/test_tf_AdjustHue.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def create_adjust_hue_net(self, input_shape, input_type, special_case):
def test_adjust_hue_basic(self, input_shape, input_type, special_case,
ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
if ie_device == 'GPU' and (input_shape == [2, 4, 4, 3] or input_shape == [3, 4, 12, 12, 3]):
pytest.skip('150766: Accuracy issue on GPU')
self._test(*self.create_adjust_hue_net(input_shape, input_type, special_case),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)

0 comments on commit 9c432a3

Please sign in to comment.