From b0391cf3c4da0179b1c9690cbeae5071d598fa89 Mon Sep 17 00:00:00 2001 From: Lyamin-Roman Date: Mon, 28 Oct 2024 22:43:40 +0900 Subject: [PATCH] [GPU] Handling the case where get_state was called before set_state --- src/plugins/intel_gpu/src/plugin/variable_state.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/intel_gpu/src/plugin/variable_state.cpp b/src/plugins/intel_gpu/src/plugin/variable_state.cpp index 6b1c8d0cfc993f..a524065880c1d8 100644 --- a/src/plugins/intel_gpu/src/plugin/variable_state.cpp +++ b/src/plugins/intel_gpu/src/plugin/variable_state.cpp @@ -123,6 +123,19 @@ ov::element::Type VariableState::get_user_specified_type() const { } ov::SoPtr VariableState::get_state() const { + if (m_memory == nullptr) { + const auto& pshape = m_layout.get_partial_shape(); + ov::Shape shape; + for (const auto& dim : pshape) { + if (dim.is_static()) { + shape.emplace_back(dim.get_length()); + } else { + shape.emplace_back(0ul); + } + } + return m_context->create_host_tensor(get_user_specified_type(), shape); + } + auto tensor = m_context->create_host_tensor(get_user_specified_type(), m_memory->get_layout().get_shape()); convert_and_copy(m_memory, tensor._ptr.get(), m_context->get_engine().get_service_stream());