From fc9e8d9dcdc2632a0755baab5c5bd44f57e92d77 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 | 6 ++++++ 1 file changed, 6 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..2b7a26ba35a292 100644 --- a/src/plugins/intel_gpu/src/plugin/variable_state.cpp +++ b/src/plugins/intel_gpu/src/plugin/variable_state.cpp @@ -123,6 +123,12 @@ 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(); + const auto& shape = get_tensor_shape(pshape); + 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());