# GstMLTensorMeta Source: [https://docs.qualcomm.com/doc/80-70014-50/topic/ml-api-gstmltensormeta.html](https://docs.qualcomm.com/doc/80-70014-50/topic/ml-api-gstmltensormeta.html) GstMLTensorMeta defines the metadata API for different tensor types. It is based on [GstMeta](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmeta.html?gi-language=c), which is a member of the [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) metadata structure. | Field | Description | | --- | --- | | meta ([GstMeta](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmeta.html?gi-language=c)) | Parent is GstMeta | | id (guint) | ID corresponding to the memory index inside [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) | | type (GstMLType) | Tensor type | | n\_dimensions (guint) | Number of tensor dimensions | | dimensions (guint) | Array of tensor dimensions | ## gst\_buffer\_add\_ml\_tensor\_meta Attaches GstMLTensorMeta metadata to buffer with the given parameters. **Prototype** GstMLTensorMeta * gst_buffer_add_ml_tensor_meta (GstBuffer * buffer, const GstMLType type, const guint n_dimensions, const guint dimensions[GST_ML_TENSOR_MAX_DIMS])Copy to clipboard **Parameters** | [in] | `buffer` | A [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) | | :--- | :--- | :--- | | [in] | `type` | The tensor type. | | [in] | `n_dimensions` | The number of tensor dimensions. | | [in] | `dimensions` | The array containing the tensor dimensions. | **Returns** The GstMLTensorMeta on buffer. Do not free after the code is run. ## gst\_buffer\_get\_ml\_tensor\_meta Gets the first GstMLTensorMeta on buffer **Prototype** GstMLTensorMeta * gst_buffer_get_ml_tensor_meta (GstBuffer * buffer)Copy to clipboard **Parameters** | [in] | `buffer` | A [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) | | :--- | :--- | :--- | **Returns** The GstMLTensorMeta on buffer. Do not free after the code is run. ## gst\_buffer\_get\_ml\_tensor\_meta\_id Finds the GstMLTensorMeta on buffer with the given ID. **Prototype** GstMLTensorMeta * gst_buffer_get_ml_tensor_meta_id (GstBuffer * buffer, guint id) Copy to clipboard **Parameters** | [in] | `buffer` | A [GstBuffer](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c) | | :--- | :--- | :--- | | [in] | `id` | A metadata ID | **Returns** The GstMLTensorMeta on buffer. Do not free after the code is run. ## gst\_ml\_meta\_tensor\_size Gets the total size of the tensor in bytes, which is calculated based on the dimensions and tensor type. **Prototype** gsize gst_ml_meta_tensor_size (const GstMLTensorMeta * meta)Copy to clipboard **Parameters** | [in] | `meta` | A GstMLTensorMeta | | :--- | :--- | :--- | **Returns** The size in bytes. **Parent Topic:** [Machine learning APIs](https://docs.qualcomm.com/doc/80-70014-50/topic/machine-learning-apis.html) Last Published: Oct 27, 2025 [Previous Topic GstMLInfo](https://docs.qualcomm.com/bundle/publicresource/80-70014-50/topics/ml-api-gstmlinfo.md) [Next Topic GstMLFrame](https://docs.qualcomm.com/bundle/publicresource/80-70014-50/topics/ml-api-gstmlframe.md)