Skip to content

Commit f36c480

Browse files
[GPU] Fix not to request 0 bytes layout allocation to OpenCL
1 parent ea09d6b commit f36c480

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/plugins/intel_gpu/src/graph/loop.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,17 @@ void loop_inst::preprocess_input_memory(const int64_t num_iterations) {
501501
// Because internal input memory's data will be updated through backedge process.
502502
if (iter != _back_edges.end()) {
503503
internal_input_memory = body_network->get_engine().allocate_memory(memory->get_layout(), false);
504-
internal_input_memory->copy_from(body_network->get_stream(), *memory);
505-
GPU_DEBUG_LOG << "Input memory of internal node(" << internal_id.to_string() << ") is set to new memory("
506-
<< internal_input_memory << ", " << internal_input_memory->get_layout().to_short_string()
507-
<< ") instead of external node(" << external_id.to_string()
508-
<<")'s memory(" << memory << "," << memory->get_layout().to_short_string() << ")" << std::endl;
504+
if (internal_input_memory) {
505+
internal_input_memory->copy_from(body_network->get_stream(), *memory);
506+
GPU_DEBUG_LOG << "Input memory of internal node(" << internal_id.to_string() << ") is set to new memory("
507+
<< internal_input_memory << ", " << internal_input_memory->get_layout().to_short_string()
508+
<< ") instead of external node(" << external_id.to_string()
509+
<<")'s memory(" << memory << "," << memory->get_layout().to_short_string() << ")" << std::endl;
510+
}
509511
}
510512

511-
body_network->set_input_data(internal_id.pid, internal_input_memory);
513+
if (internal_input_memory)
514+
body_network->set_input_data(internal_id.pid, internal_input_memory);
512515
} else {
513516
OPENVINO_ASSERT(memory != nullptr, "In preprocessing concat input mapping, concat memory should be allocated");
514517
auto memory_mapping_info = create_concat_memory_map(*input_map, memory, num_iterations);

src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ allocation_type ocl_engine::detect_usm_allocation_type(const void* memory) const
128128
bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) {
129129
OPENVINO_ASSERT(supports_allocation(type) || type == allocation_type::cl_mem, "[GPU] Unsupported allocation type: ", type);
130130

131+
if (layout.bytes_count() == 0) {
132+
return false;
133+
}
134+
131135
bool exceed_allocatable_mem_size = (layout.bytes_count() > get_device_info().max_alloc_mem_size);
132136

133137
// When dynamic shape upper bound makes bigger buffer, then return false.
@@ -172,7 +176,8 @@ bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) {
172176
memory::ptr ocl_engine::allocate_memory(const layout& layout, allocation_type type, bool reset) {
173177
OPENVINO_ASSERT(!layout.is_dynamic() || layout.has_upper_bound(), "[GPU] Can't allocate memory for dynamic layout");
174178

175-
check_allocatable(layout, type);
179+
if (!check_allocatable(layout, type))
180+
return nullptr;
176181

177182
try {
178183
memory::ptr res = nullptr;

0 commit comments

Comments
 (0)