Skip to content

Commit 8998050

Browse files
[GPU] Add condition which empty layout is regareded as 1 dim with value 1 at check memory
1 parent 5a8d75d commit 8998050

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/plugins/intel_gpu/src/graph/primitive_inst.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,21 @@ kernel_impl_params primitive_impl::static_canonicalize_shapes(const kernel_impl_
199199

200200
uint32_t primitive_inst::get_network_id() const { return _network.get_id(); }
201201

202-
void primitive_inst::check_memory_to_set(const memory& mem, const layout& layout) const {
203-
OPENVINO_ASSERT((mem.get_layout() == layout) || layout.is_dynamic(), "[GPU] Unexpected layout of input memory for ", id(), " node!\n",
204-
"Node layout: ", layout.to_short_string(), "\n",
205-
"Memory layout: ", mem.get_layout().to_short_string());
202+
void primitive_inst::check_memory_to_set(const memory& mem, const layout& l) const {
203+
// The layout with empty tensor (scalar) is regarded as 1 dimension with value 1
204+
bool single_value_layout = false;
205+
if (!l.is_dynamic()) {
206+
auto layout_ps = l.get_partial_shape();
207+
single_value_layout = (layout_ps.size() == 1 && layout_ps[0] == 1);
208+
}
209+
210+
auto mem_layout = mem.get_layout();
211+
OPENVINO_ASSERT((mem_layout == l)
212+
|| l.is_dynamic()
213+
|| (mem_layout.get_partial_shape().size() == 0 && single_value_layout),
214+
"[GPU] Unexpected layout of input memory for ", id(), " node!\n",
215+
"Node layout: ", l.to_short_string(), "\n",
216+
"Memory layout: ", mem_layout.to_short_string());
206217

207218
// check shared image/buffer compatibility, if applicable
208219
auto params = mem.get_internal_params();
@@ -218,11 +229,11 @@ void primitive_inst::check_memory_to_set(const memory& mem, const layout& layout
218229
switch (params.mem_type) {
219230
case shared_mem_type::shared_mem_vasurface:
220231
case shared_mem_type::shared_mem_image:
221-
OPENVINO_ASSERT(layout.format.is_image_2d(), "Attempt to set user-supplied input or output image instead of a buffer");
232+
OPENVINO_ASSERT(l.format.is_image_2d(), "Attempt to set user-supplied input or output image instead of a buffer");
222233
break;
223234
case shared_mem_type::shared_mem_buffer:
224235
case shared_mem_type::shared_mem_dxbuffer:
225-
OPENVINO_ASSERT(!layout.format.is_image_2d(), "Attempt to set user-supplied input or output buffer instead of an image");
236+
OPENVINO_ASSERT(!l.format.is_image_2d(), "Attempt to set user-supplied input or output buffer instead of an image");
226237
break;
227238
case shared_mem_type::shared_mem_usm:
228239
break;

0 commit comments

Comments
 (0)