Class NNData

Inheritance Relationships

Base Type

Class Documentation

class NNData : public dai::Buffer

NNData message. Carries tensors and their metadata

Public Functions

NNData()

Construct NNData message.

explicit NNData(std::shared_ptr<RawNNData> ptr)
virtual ~NNData() = default
NNData &setLayer(const std::string &name, std::vector<std::uint8_t> data)

Set a layer with datatype U8.

Parameters:
  • name – Name of the layer

  • data – Data to store

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

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

Parameters:
  • name – Name of the layer

  • data – Data to store

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

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

Parameters:
  • name – Name of the layer

  • data – Data to store

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

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

Parameters:
  • name – Name of the layer

  • data – Data to store

std::vector<std::string> getAllLayerNames() const
Returns:

Names of all layers added

std::vector<TensorInfo> getAllLayers() const
Returns:

All layers and their information

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

Retrieve layers tensor information

Parameters:
  • name – Name of the layer

  • tensor[out] Outputs tensor information of that layer

Returns:

True if layer exists, false otherwise

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

Checks if given layer exists

Parameters:

name – Name of the layer

Returns:

True if layer exists, false otherwise

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

Retrieve datatype of a layers tensor

Parameters:
  • name – Name of the layer

  • datatype[out] Datatype of layers tensor

Returns:

True if layer exists, false otherwise

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

Convenience function to retrieve U8 data from layer

Parameters:

name – Name of the layer

Returns:

U8 binary data

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

Convenience function to retrieve float values from layers FP16 tensor

Parameters:

name – Name of the layer

Returns:

Float data

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

Convenience function to retrieve INT32 values from layers tensor

Parameters:

name – Name of the layer

Returns:

INT32 data

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

Convenience function to retrieve U8 data from first layer

Returns:

U8 binary data

std::vector<float> getFirstLayerFp16() const

Convenience function to retrieve float values from first layers FP16 tensor

Returns:

Float data

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

Convenience function to retrieve INT32 values from first layers tensor

Returns:

INT32 data

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

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

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

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

NNData &setSequenceNum(int64_t sequenceNum)

Retrieves image sequence number