Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
dai::NNData Class Reference

#include <NNData.hpp>

Inheritance diagram for dai::NNData:
Inheritance graph
[legend]

Public Member Functions

std::vector< std::string > getAllLayerNames () const
 
std::vector< TensorInfogetAllLayers () const
 
std::vector< float > getFirstLayerFp16 () const
 
std::vector< std::int32_t > getFirstLayerInt32 () const
 
std::vector< std::uint8_t > getFirstLayerUInt8 () const
 
bool getLayer (const std::string &name, TensorInfo &tensor) const
 
bool getLayerDatatype (const std::string &name, TensorInfo::DataType &datatype) const
 
std::vector< float > getLayerFp16 (const std::string &name) const
 
std::vector< std::int32_t > getLayerInt32 (const std::string &name) const
 
std::vector< std::uint8_t > getLayerUInt8 (const std::string &name) const
 
bool hasLayer (const std::string &name) const
 
 NNData ()
 
 NNData (std::shared_ptr< RawNNData > ptr)
 
NNDatasetLayer (const std::string &name, const std::vector< int > &data)
 
NNDatasetLayer (const std::string &name, std::vector< double > data)
 
NNDatasetLayer (const std::string &name, std::vector< float > data)
 
NNDatasetLayer (const std::string &name, std::vector< std::uint8_t > data)
 
NNDatasetSequenceNum (int64_t sequenceNum)
 
NNDatasetTimestamp (std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
 
NNDatasetTimestampDevice (std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
 
virtual ~NNData ()=default
 
- Public Member Functions inherited from dai::Buffer
 Buffer ()
 Creates Buffer message. More...
 
 Buffer (std::shared_ptr< dai::RawBuffer > ptr)
 
std::vector< std::uint8_t > & getData () const
 Get non-owning reference to internal buffer. More...
 
int64_t getSequenceNum () const
 
std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestamp () const
 
std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestampDevice () const
 
void setData (const std::vector< std::uint8_t > &data)
 
void setData (std::vector< std::uint8_t > &&data)
 
BuffersetSequenceNum (int64_t sequenceNum)
 
BuffersetTimestamp (std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
 
BuffersetTimestampDevice (std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
 
virtual ~Buffer ()=default
 
- Public Member Functions inherited from dai::ADatatype
 ADatatype (std::shared_ptr< RawBuffer > r)
 
std::shared_ptr< RawBuffergetRaw () const
 
virtual ~ADatatype ()=default
 

Private Member Functions

std::shared_ptr< RawBufferserialize () const override
 

Private Attributes

std::unordered_map< std::string, std::vector< std::uint16_t > > fp16Data
 
RawNNDatarawNn
 
std::unordered_map< std::string, std::vector< std::uint8_t > > u8Data
 

Static Private Attributes

static constexpr int DATA_ALIGNMENT = 64
 

Additional Inherited Members

- Protected Attributes inherited from dai::ADatatype
std::shared_ptr< RawBufferraw
 

Detailed Description

NNData message. Carries tensors and their metadata

Definition at line 16 of file NNData.hpp.

Constructor & Destructor Documentation

◆ NNData() [1/2]

dai::NNData::NNData ( )

Construct NNData message.

Definition at line 14 of file NNData.cpp.

◆ NNData() [2/2]

dai::NNData::NNData ( std::shared_ptr< RawNNData ptr)
explicit

Definition at line 15 of file NNData.cpp.

◆ ~NNData()

virtual dai::NNData::~NNData ( )
virtualdefault

Member Function Documentation

◆ getAllLayerNames()

std::vector< std::string > dai::NNData::getAllLayerNames ( ) const
Returns
Names of all layers added

Definition at line 139 of file NNData.cpp.

◆ getAllLayers()

std::vector< TensorInfo > dai::NNData::getAllLayers ( ) const
Returns
All layers and their information

Definition at line 147 of file NNData.cpp.

◆ getFirstLayerFp16()

std::vector< float > dai::NNData::getFirstLayerFp16 ( ) const

Convenience function to retrieve float values from first layers FP16 tensor

Returns
Float data

Definition at line 255 of file NNData.cpp.

◆ getFirstLayerInt32()

std::vector< std::int32_t > dai::NNData::getFirstLayerInt32 ( ) const

Convenience function to retrieve INT32 values from first layers tensor

Returns
INT32 data

Definition at line 264 of file NNData.cpp.

◆ getFirstLayerUInt8()

std::vector< std::uint8_t > dai::NNData::getFirstLayerUInt8 ( ) const

Convenience function to retrieve U8 data from first layer

Returns
U8 binary data

Definition at line 245 of file NNData.cpp.

◆ getLayer()

bool dai::NNData::getLayer ( const std::string &  name,
TensorInfo tensor 
) const

Retrieve layers tensor information

Parameters
nameName of the layer
[out]tensorOutputs tensor information of that layer
Returns
True if layer exists, false otherwise

Definition at line 151 of file NNData.cpp.

◆ getLayerDatatype()

bool dai::NNData::getLayerDatatype ( const std::string &  name,
TensorInfo::DataType datatype 
) const

Retrieve datatype of a layers tensor

Parameters
nameName of the layer
[out]datatypeDatatype of layers tensor
Returns
True if layer exists, false otherwise

Definition at line 168 of file NNData.cpp.

◆ getLayerFp16()

std::vector< float > dai::NNData::getLayerFp16 ( const std::string &  name) const

Convenience function to retrieve float values from layers FP16 tensor

Parameters
nameName of the layer
Returns
Float data

Definition at line 221 of file NNData.cpp.

◆ getLayerInt32()

std::vector< std::int32_t > dai::NNData::getLayerInt32 ( const std::string &  name) const

Convenience function to retrieve INT32 values from layers tensor

Parameters
nameName of the layer
Returns
INT32 data

Definition at line 197 of file NNData.cpp.

◆ getLayerUInt8()

std::vector< std::uint8_t > dai::NNData::getLayerUInt8 ( const std::string &  name) const

Convenience function to retrieve U8 data from layer

Parameters
nameName of the layer
Returns
U8 binary data

Definition at line 178 of file NNData.cpp.

◆ hasLayer()

bool dai::NNData::hasLayer ( const std::string &  name) const

Checks if given layer exists

Parameters
nameName of the layer
Returns
True if layer exists, false otherwise

Definition at line 161 of file NNData.cpp.

◆ serialize()

std::shared_ptr< RawBuffer > dai::NNData::serialize ( ) const
overrideprivatevirtual

Reimplemented from dai::Buffer.

Definition at line 40 of file NNData.cpp.

◆ setLayer() [1/4]

NNData & dai::NNData::setLayer ( const std::string &  name,
const std::vector< int > &  data 
)

Set a layer with datatype U8. Integers are cast to bytes.

Parameters
nameName of the layer
dataData to store

Definition at line 114 of file NNData.cpp.

◆ setLayer() [2/4]

NNData & dai::NNData::setLayer ( const std::string &  name,
std::vector< double >  data 
)

Set a layer with datatype FP16. Double values are converted to FP16.

Parameters
nameName of the layer
dataData to store

Definition at line 130 of file NNData.cpp.

◆ setLayer() [3/4]

NNData & dai::NNData::setLayer ( const std::string &  name,
std::vector< float >  data 
)

Set a layer with datatype FP16. Float values are converted to FP16.

Parameters
nameName of the layer
dataData to store

Definition at line 123 of file NNData.cpp.

◆ setLayer() [4/4]

NNData & dai::NNData::setLayer ( const std::string &  name,
std::vector< std::uint8_t >  data 
)

Set a layer with datatype U8.

Parameters
nameName of the layer
dataData to store

Definition at line 110 of file NNData.cpp.

◆ setSequenceNum()

NNData & dai::NNData::setSequenceNum ( int64_t  sequenceNum)

Retrieves image sequence number

Definition at line 281 of file NNData.cpp.

◆ setTimestamp()

NNData & dai::NNData::setTimestamp ( std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration >  timestamp)

Sets image timestamp related to dai::Clock::now()

Definition at line 273 of file NNData.cpp.

◆ setTimestampDevice()

NNData & dai::NNData::setTimestampDevice ( std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration >  timestamp)

Sets image timestamp related to dai::Clock::now()

Definition at line 277 of file NNData.cpp.

Member Data Documentation

◆ DATA_ALIGNMENT

constexpr int dai::NNData::DATA_ALIGNMENT = 64
staticconstexprprivate

Definition at line 17 of file NNData.hpp.

◆ fp16Data

std::unordered_map<std::string, std::vector<std::uint16_t> > dai::NNData::fp16Data
private

Definition at line 25 of file NNData.hpp.

◆ rawNn

RawNNData& dai::NNData::rawNn
private

Definition at line 19 of file NNData.hpp.

◆ u8Data

std::unordered_map<std::string, std::vector<std::uint8_t> > dai::NNData::u8Data
private

Definition at line 23 of file NNData.hpp.


The documentation for this class was generated from the following files:


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:20