aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl/ClWorkloadFactory.cpp
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2021-01-07 13:28:47 +0000
committerMatthew Sloyan <matthew.sloyan@arm.com>2021-01-11 17:03:54 +0000
commit80fbcd5f4d7b362360963af1df0121aa6b561576 (patch)
tree64c8d2588e55aad2813f6b07e40f87ac3b8e8ce1 /src/backends/cl/ClWorkloadFactory.cpp
parenta20b3129aa1c450ccf867c7b63844e8391753730 (diff)
downloadarmnn-80fbcd5f4d7b362360963af1df0121aa6b561576.tar.gz
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 <matthew.sloyan@arm.com> Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: If806f050535ffaa70922ba0f1ffe7bb10f902329
Diffstat (limited to 'src/backends/cl/ClWorkloadFactory.cpp')
-rw-r--r--src/backends/cl/ClWorkloadFactory.cpp13
1 files changed, 11 insertions, 2 deletions
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 <Layer.hpp>
@@ -28,6 +30,7 @@
#include <arm_compute/runtime/CL/CLScheduler.h>
#include <Filesystem.hpp>
+#include <fstream>
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);
}
}
}