ArmNN
 24.02
ISerializer::SerializerImpl Class Reference

#include <Serializer.hpp>

Public Member Functions

 SerializerImpl ()=default
 
 ~SerializerImpl ()=default
 
void Serialize (const armnn::INetwork &inNetwork)
 Serializes the network to ArmNN SerializedGraph. More...
 
bool SaveSerializedToStream (std::ostream &stream)
 Serializes the SerializedGraph to the stream. More...
 

Detailed Description

Definition at line 361 of file Serializer.hpp.

Constructor & Destructor Documentation

◆ SerializerImpl()

SerializerImpl ( )
default

◆ ~SerializerImpl()

~SerializerImpl ( )
default

Member Function Documentation

◆ SaveSerializedToStream()

bool SaveSerializedToStream ( std::ostream &  stream)

Serializes the SerializedGraph to the stream.

Parameters
[stream]the stream to save to
Returns
true if graph is Serialized to the Stream, false otherwise

Definition at line 2510 of file Serializer.cpp.

2511 {
2512  flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2513 
2514  auto bytesToWrite = armnn::numeric_cast<std::streamsize>(fbBuilder.GetSize());
2515  stream.write(reinterpret_cast<const char*>(fbBuilder.GetBufferPointer()), bytesToWrite);
2516  return !stream.bad();
2517 }

◆ Serialize()

void Serialize ( const armnn::INetwork inNetwork)

Serializes the network to ArmNN SerializedGraph.

Parameters
[in]inNetworkThe network to be serialized.

Definition at line 2491 of file Serializer.cpp.

2492 {
2493  // Iterate through to network
2494  inNetwork.ExecuteStrategy(m_SerializerStrategy);
2495  flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2496 
2497  // Create FlatBuffer SerializedGraph
2498  auto serializedGraph = serializer::CreateSerializedGraph(
2499  fbBuilder,
2500  fbBuilder.CreateVector(m_SerializerStrategy.GetSerializedLayers()),
2501  fbBuilder.CreateVector(m_SerializerStrategy.GetInputIds()),
2502  fbBuilder.CreateVector(m_SerializerStrategy.GetOutputIds()),
2503  m_SerializerStrategy.GetVersionTable());
2504 
2505  // Serialize the graph
2506  fbBuilder.Finish(serializedGraph);
2507 }

References INetwork::ExecuteStrategy().


The documentation for this class was generated from the following files:
armnn::INetwork::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:666
armnnSerializer::SerializerStrategy::GetFlatBufferBuilder
flatbuffers::FlatBufferBuilder & GetFlatBufferBuilder()
Definition: Serializer.hpp:34
armnnSerializer::SerializerStrategy::GetVersionTable
flatbuffers::Offset< armnnSerializer::FeatureCompatibilityVersions > GetVersionTable()
Definition: Serializer.cpp:1972
armnnSerializer::SerializerStrategy::GetInputIds
std::vector< int > & GetInputIds()
Definition: Serializer.hpp:39
armnnSerializer::SerializerStrategy::GetOutputIds
std::vector< int > & GetOutputIds()
Definition: Serializer.hpp:44
armnnSerializer::SerializerStrategy::GetSerializedLayers
std::vector< flatbuffers::Offset< armnnSerializer::AnyLayer > > & GetSerializedLayers()
Definition: Serializer.hpp:49