Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Handling the case where get_state was called before set_state (#27276)

Roman Lyamin2e87aad94024
diff --git a/src/plugins/intel_gpu/src/plugin/variable_state.cpp b/src/plugins/intel_gpu/src/plugin/variable_state.cpp
index 6b1c8d0cfc9..2b7a26ba35a 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<ov::ITensor> 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());