From 80fbcd5f4d7b362360963af1df0121aa6b561576 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Thu, 7 Jan 2021 13:28:47 +0000 Subject: IVGCVSW-5483 'Implement Loading and Saving to File' * Implemented Serialization and Deserialization of CLContext. * Fixed flatbuffers android-nn-driver dependency. !android-nn-driver:4772 Signed-off-by: Matthew Sloyan Signed-off-by: Sadik Armagan Change-Id: If806f050535ffaa70922ba0f1ffe7bb10f902329 --- src/backends/cl/ClWorkloadFactory.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/backends/cl/ClWorkloadFactory.cpp') diff --git a/src/backends/cl/ClWorkloadFactory.cpp b/src/backends/cl/ClWorkloadFactory.cpp index 5a5cb89204..d65b26314e 100644 --- a/src/backends/cl/ClWorkloadFactory.cpp +++ b/src/backends/cl/ClWorkloadFactory.cpp @@ -5,6 +5,8 @@ #include "ClWorkloadFactory.hpp" #include "ClBackendId.hpp" #include "ClBackendModelContext.hpp" +#include "ClContextDeserializer.hpp" +#include "ClContextSerializer.hpp" #include @@ -28,6 +30,7 @@ #include #include +#include namespace armnn { @@ -68,7 +71,11 @@ void ClWorkloadFactory::AfterWorkloadsCreated() auto filePath = modelOptions->GetCachedNetworkFilePath(); if (filePath != "" && fs::exists(filePath) && fs::is_regular_file(filePath)) { - /// Saving will be implemented within IVGCVSW-5483 story. + // Serialize ClContext to the file specified + ClContextSerializer serializer; + serializer.Serialize(m_CLCompileContext); + std::ofstream file(filePath, std::ios::out | std::ios::binary); + serializer.SaveSerializedToStream(file); } } } @@ -121,7 +128,9 @@ void ClWorkloadFactory::InitializeCLCompileContext() && fs::is_regular_file(filePath) && !(modelOptions->SaveCachedNetwork())) { - /// Loading will be implemented within IVGCVSW-5483 story. + // Deserialize binary file and load into m_CLCompileContext + ClContextDeserializer deserializer; + deserializer.Deserialize(m_CLCompileContext, context, device, filePath); } } } -- cgit v1.2.1