MCPcopy Create free account
hub / github.com/ARM-software/armnn / AfterWorkloadsCreated

Method AfterWorkloadsCreated

src/backends/cl/ClWorkloadFactory.cpp:66–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ClWorkloadFactory::AfterWorkloadsCreated()
67{
68 if(m_ModelContextPtr)
69 {
70 auto modelOptions = dynamic_cast<ClBackendModelContext*>(m_ModelContextPtr.get());
71 if (modelOptions->SaveCachedNetwork())
72 {
73 ClContextSerializer serializer;
74 serializer.Serialize(m_CLCompileContext);
75 auto cachedFd = modelOptions->GetCachedFileDescriptor();
76 if (cachedFd != -1)
77 {
78 std::vector<uint8_t> compiledContextData;
79 std::stringstream stream;
80 bool serialized = serializer.SaveSerializedToStream(stream);
81 if (serialized)
82 {
83 std::string const serializedString{stream.str()};
84 std::copy(serializedString.begin(),
85 serializedString.end(),
86 std::back_inserter(compiledContextData));
87 auto success = write(cachedFd, compiledContextData.data(), compiledContextData.size());
88 if (success == -1)
89 {
90 ARMNN_LOG(info) << "ClWorkloadFactory:: Could not cache the compiled context!";
91 }
92 }
93 }
94
95 // Save map to a filepath provided in ModelOptions
96 auto filePath = modelOptions->GetCachedNetworkFilePath();
97 if (filePath != "" && fs::exists(filePath) && fs::is_regular_file(filePath))
98 {
99 // Serialize ClContext to the file specified
100 std::ofstream file(filePath, std::ios::out | std::ios::binary);
101 serializer.SaveSerializedToStream(file);
102 }
103 }
104 }
105}
106
107template <typename FloatWorkload, typename Uint8Workload, typename QueueDescriptorType, typename... Args>
108std::unique_ptr<IWorkload> ClWorkloadFactory::MakeWorkload(const QueueDescriptorType& descriptor,

Callers 1

LoadedNetworkMethod · 0.80

Calls 15

copyFunction · 0.85
writeFunction · 0.85
existsFunction · 0.85
is_regular_fileFunction · 0.85
SaveCachedNetworkMethod · 0.80
getMethod · 0.45
SerializeMethod · 0.45
strMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected