# NNData

This message carries tensors and its data.
[NeuralNetwork](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/neural_network.md) node outputs NNData.

## Creating NNData

You can also create this message on the host ([example
here](https://github.com/luxonis/oak-examples/blob/cd4a1e2be64a7c0319870cf80b4be3bd0561e9a0/gen2-efficientnet-classification/main.py#L125-L127))
or [Script](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/script.md) node ([Script NNData
example](https://docs.luxonis.com/software-v3/depthai/examples/script_nndata_example.md)), populate the tensor with the data, and
send the message to the input of the
[NeuralNetwork](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/neural_network.md) node.

## Reference

### dai::NNData

Kind: class

NNData message. Carries tensors and their metadata

#### std::vector< TensorInfo > tensors

Kind: variable

#### unsigned int batchSize

Kind: variable

#### std::optional< ImgTransformation > transformation

Kind: variable

#### NNData()

Kind: function

Construct NNData message.

#### NNData(size_t size)

Kind: function

#### ~NNData()

Kind: function

#### std::vector< std::string > getAllLayerNames()

Kind: function

return: Names of all layers added

#### std::vector< TensorInfo > getAllLayers()

Kind: function

return: All layers and their information

#### std::optional< TensorInfo > getTensorInfo(const std::string & name)

Kind: function

Retrieve tensor information parameters: name: Name of the tensor return: Tensor information

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

Kind: function

Retrieve layers tensor information parameters: name: Name of the layer; tensor: Outputs tensor information of that layer return:
True if layer exists, false otherwise

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

Kind: function

Checks if given layer exists parameters: name: Name of the layer return: True if layer exists, false otherwise

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

Kind: function

Retrieve datatype of a layers tensor parameters: name: Name of the layer; datatype: Datatype of layers tensor return: True if
layer exists, false otherwise

#### TensorInfo::DataType getTensorDatatype(const std::string & name)

Kind: function

Get the datatype of a given tensor return: TensorInfo::DataType tensor datatype

#### TensorInfo::DataType getFirstTensorDatatype()

Kind: function

Get the datatype of the first tensor return: TensorInfo::DataType tensor datatype

#### span< std::uint8_t > emplaceTensor(TensorInfo & tensor)

Kind: function

Emplace a tensor This function allocates memory for the tensor and return over the said memory. It is up to the caller to fill the
memory out with meaningful data. return: Span over the allocated memory

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### DEPTHAI_SERIALIZE(NNData, Buffer::sequenceNum, Buffer::ts, Buffer::tsDevice, tensors, batchSize, transformation)

Kind: function

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
