Skip to content

Commit f0171f1

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

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

+16-6
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,20 @@ 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_dims = l.get_dims();
207+
single_value_layout = (layout_dims.size() == 1 && layout_dims[0] == 1);
208+
}
209+
210+
auto mem_layout = mem.get_layout();
211+
if ( !(mem_layout.get_tensor() == tensor({}) && single_value_layout) ) {
212+
OPENVINO_ASSERT((mem_layout == l) || l.is_dynamic(), "[GPU] Unexpected layout of input memory for ", id(), " node!\n",
213+
"Node layout: ", l.to_short_string(), "\n",
214+
"Memory layout: ", mem_layout.to_short_string());
215+
}
206216

207217
// check shared image/buffer compatibility, if applicable
208218
auto params = mem.get_internal_params();
@@ -218,11 +228,11 @@ void primitive_inst::check_memory_to_set(const memory& mem, const layout& layout
218228
switch (params.mem_type) {
219229
case shared_mem_type::shared_mem_vasurface:
220230
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");
231+
OPENVINO_ASSERT(l.format.is_image_2d(), "Attempt to set user-supplied input or output image instead of a buffer");
222232
break;
223233
case shared_mem_type::shared_mem_buffer:
224234
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");
235+
OPENVINO_ASSERT(!l.format.is_image_2d(), "Attempt to set user-supplied input or output buffer instead of an image");
226236
break;
227237
case shared_mem_type::shared_mem_usm:
228238
break;

0 commit comments

Comments
 (0)