ArmNN
 24.08
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 365 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 2562 of file Serializer.cpp.

2563 {
2564  flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2565 
2566  auto bytesToWrite = armnn::numeric_cast<std::streamsize>(fbBuilder.GetSize());
2567  stream.write(reinterpret_cast<const char*>(fbBuilder.GetBufferPointer()), bytesToWrite);
2568  return !stream.bad();
2569 }

◆ Serialize()

void Serialize ( const armnn::INetwork inNetwork)

Serializes the network to ArmNN SerializedGraph.

Parameters
[in]inNetworkThe network to be serialized.

Definition at line 2543 of file Serializer.cpp.

2544 {
2545  // Iterate through to network
2546  inNetwork.ExecuteStrategy(m_SerializerStrategy);
2547  flatbuffers::FlatBufferBuilder& fbBuilder = m_SerializerStrategy.GetFlatBufferBuilder();
2548 
2549  // Create FlatBuffer SerializedGraph
2550  auto serializedGraph = serializer::CreateSerializedGraph(
2551  fbBuilder,
2552  fbBuilder.CreateVector(m_SerializerStrategy.GetSerializedLayers()),
2553  fbBuilder.CreateVector(m_SerializerStrategy.GetInputIds()),
2554  fbBuilder.CreateVector(m_SerializerStrategy.GetOutputIds()),
2555  m_SerializerStrategy.GetVersionTable());
2556 
2557  // Serialize the graph
2558  fbBuilder.Finish(serializedGraph);
2559 }

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:672
armnnSerializer::SerializerStrategy::GetFlatBufferBuilder
flatbuffers::FlatBufferBuilder & GetFlatBufferBuilder()
Definition: Serializer.hpp:34
armnnSerializer::SerializerStrategy::GetVersionTable
flatbuffers::Offset< armnnSerializer::FeatureCompatibilityVersions > GetVersionTable()
Definition: Serializer.cpp:2017
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