Skip to content

Commit

Permalink
Fix PartialShape comparison related issues on TensorIterator/LSTMSequ…
Browse files Browse the repository at this point in the history
…enceTest

Signed-off-by: Andrew Park <[email protected]>
  • Loading branch information
andrew-k-park committed May 26, 2022
1 parent f2f83f8 commit 664175c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ struct layout {

layout convert_to_weights_layout(bool is_grouped) const;

layout get_layout_with_dims() const;

std::string to_string() const;

bool is_dynamic() const;
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/intel_gpu/src/graph/input_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ void input_layout_inst::set_data(memory::ptr mem) {

_has_valid_input = true;
_output_changed = true;
_shape_changed = mem->get_layout() != ol;
auto check_shape_changed = [&]() {
if (ol.is_dynamic())
return mem->get_layout() != ol;
else
return mem->get_layout().get_layout_with_dims() != ol.get_layout_with_dims();
};
_shape_changed = check_shape_changed();

if (_shape_changed) {
node.invalidate_users();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_gpu/src/graph/primitive_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ void primitive_inst::update_impl() {
void primitive_inst::check_memory_to_set(const memory& mem, const layout& layout) const {
CLDNN_ERROR_LAYOUT_MISMATCH("network layout",
"set memory layout",
mem.get_layout(),
mem.get_layout().get_layout_with_dims(),
"expected layout",
layout,
layout.get_layout_with_dims(),
"");

// check shared image/buffer compatibility, if applicable
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/intel_gpu/src/graph/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ layout reshape_inst::calc_output_layout(reshape_node const& node) {

if (input_layout.is_static()) {
auto sizes = prim->output_shape;
if (sizes.size() < input_layout.format.dimension()) {
sizes.insert(sizes.end(), input_layout.format.dimension() - sizes.size(), 1);
}
auto input_sizes = input_layout.get_dims();
int64_t need_recalc = -1;
ov::Dimension::value_type shape_count = 1;
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/intel_gpu/src/runtime/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ layout layout::convert_to_weights_layout(bool is_grouped) const {
return layout{data_type, fmt, size};
}

layout layout::get_layout_with_dims() const {
if (is_dynamic())
throw std::runtime_error("[GPU] get_layout_with_dims() is called for dynamic shape");

if (size.size() < format.dimension()) {
auto dims = get_dims();
auto pshape = ov::PartialShape(ov::Shape(dims.begin(), dims.end()));
return layout{data_type, format, pshape, data_padding};
}
return layout{data_type, format, size, data_padding};
}

std::vector<tensor::value_type> layout::get_ordered_dims() const {
throw std::runtime_error("get_ordered_dims is not implemented yet");
}
Expand Down

0 comments on commit 664175c

Please sign in to comment.