An integer buffer handle that can be handled by delegate.
The value is valid only when delegate is not null.
WARNING: This is an experimental interface that is subject to change.
bytes
size_t TfLiteTensor::bytes
The number of bytes required to store the data of this Tensor.
I.e. (bytes of each element) * dims[0] * ... * dims[n-1]. For example, if type is kTfLiteFloat32 and dims = {3, 2} then bytes = sizeof(float) * 3 * 2 = 4 * 3 * 2 = 24.
The appropriate type should be used for a typed tensor based on type.
data_is_stale
bool TfLiteTensor::data_is_stale
If the delegate uses its own buffer (e.g.
GPU memory), the delegate is responsible to set data_is_stale to true. delegate->CopyFromBufferHandle can be called to copy the data from delegate buffer.
WARNING: This is an experimental interface that is subject to change.
Encodes shapes with unknown dimensions with -1. This field is only populated when unknown dimensions exist in a read-write tensor (i.e. an input or output tensor). (e.g. dims contains [1, 1, 1, 3] and dims_signature contains [1, -1, -1, 3]). If no unknown dimensions exist then dims_signature is either null, or set to an empty array. Note that this field only exists when TF_LITE_STATIC_MEMORY is not defined.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-10 UTC."],[],[],null,["# TfLiteTensor Struct Reference\n\nTfLiteTensor\n============\n\n\n`#include \u003ccommon.h\u003e`\n\nA tensor in the interpreter system which is a wrapper around a buffer of data including a dimensionality (or NULL if not currently defined).\n\nSummary\n-------\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [allocation](#struct_tf_lite_tensor_1ab5dcd15fd342f9365a599b37e7e5ee18) | `const void *` An opaque pointer to a tflite::MMapAllocation. |\n| [allocation_type](#struct_tf_lite_tensor_1a4b21e89c9d432fcde19e5cecdcd18acf) | `TfLiteAllocationType` How memory is mapped kTfLiteMmapRo: Memory mapped read only. |\n| [buffer_handle](#struct_tf_lite_tensor_1a784b0cd1be5d43ea2292e75f6a15c11b) | `TfLiteBufferHandle` An integer buffer handle that can be handled by `delegate`. |\n| [bytes](#struct_tf_lite_tensor_1a65082739eecbd6d52d7d339d43b87606) | `size_t` The number of bytes required to store the data of this Tensor. |\n| [data](#struct_tf_lite_tensor_1a31678fd0752ef9e3b3debb11e7956fb0) | [TfLitePtrUnion](/edge/api/tflite/c/union/tf-lite-ptr-union#union_tf_lite_ptr_union) A union of data pointers. |\n| [data_is_stale](#struct_tf_lite_tensor_1abbb1c8fb4b382e3ffa1aec69f9a04619) | `bool` If the delegate uses its own buffer (e.g. |\n| [delegate](#struct_tf_lite_tensor_1a9491f4d29e4e8423cdc1861ac2a4eb74) | `struct `[TfLiteDelegate](/edge/api/tflite/c/struct/tf-lite-delegate#struct_tf_lite_delegate)` *` The delegate which knows how to handle `buffer_handle`. |\n| [dims](#struct_tf_lite_tensor_1a9826437410d81b21035c89847d526c81) | [TfLiteIntArray](/edge/api/tflite/c/struct/tf-lite-int-array#struct_tf_lite_int_array)` *` A pointer to a structure representing the dimensionality interpretation that the buffer should have. |\n| [dims_signature](#struct_tf_lite_tensor_1ace0611c9e0f0683e5075e4b2768d96b8) | `const `[TfLiteIntArray](/edge/api/tflite/c/struct/tf-lite-int-array#struct_tf_lite_int_array)` *` Optional. |\n| [is_variable](#struct_tf_lite_tensor_1a39290cf2770c0eebc8bd63faf12dac2f) | `bool` True if the tensor is a variable. |\n| [name](#struct_tf_lite_tensor_1adb13df6dd8e7223f9b3abf318a034209) | `const char *` Null-terminated name of this tensor. |\n| [params](#struct_tf_lite_tensor_1ad0fbad4e97f0be0a6e4bfa1b2be0e3fe) | [TfLiteQuantizationParams](/edge/api/tflite/c/struct/tf-lite-quantization-params#struct_tf_lite_quantization_params) Quantization information. |\n| [quantization](#struct_tf_lite_tensor_1aa4efa609d9ad9c78c5f53a592020de9e) | [TfLiteQuantization](/edge/api/tflite/c/struct/tf-lite-quantization#struct_tf_lite_quantization) Quantization information. Replaces params field above. |\n| [sparsity](#struct_tf_lite_tensor_1a40010fa2bfbebd59bf060459d95b65c6) | [TfLiteSparsity](/edge/api/tflite/c/struct/tf-lite-sparsity#struct_tf_lite_sparsity)` *` Parameters used to encode a sparse tensor. |\n| [type](#struct_tf_lite_tensor_1a24d579d439274a598ce79f0ec6bf6f50) | `TfLiteType` The data type specification for data stored in `data`. |\n\nPublic attributes\n-----------------\n\n### allocation\n\n```gdscript\nconst void * TfLiteTensor::allocation\n``` \nAn opaque pointer to a tflite::MMapAllocation. \n\n### allocation_type\n\n```carbon\nTfLiteAllocationType TfLiteTensor::allocation_type\n``` \nHow memory is mapped kTfLiteMmapRo: Memory mapped read only.\n\ni.e. weights kTfLiteArenaRw: Arena allocated read write memory (i.e. temporaries, outputs). \n\n### buffer_handle\n\n```scdoc\nTfLiteBufferHandle TfLiteTensor::buffer_handle\n``` \nAn integer buffer handle that can be handled by `delegate`.\n\nThe value is valid only when delegate is not null.\n\nWARNING: This is an experimental interface that is subject to change. \n\n### bytes\n\n```scdoc\nsize_t TfLiteTensor::bytes\n``` \nThe number of bytes required to store the data of this Tensor.\n\nI.e. (bytes of each element) \\* dims\\[0\\] \\* ... \\* dims\\[n-1\\]. For example, if type is kTfLiteFloat32 and dims = {3, 2} then bytes = sizeof(float) \\* 3 \\* 2 = 4 \\* 3 \\* 2 = 24. \n\n### data\n\n```text\nTfLitePtrUnion TfLiteTensor::data\n``` \nA union of data pointers.\n\nThe appropriate type should be used for a typed tensor based on `type`. \n\n### data_is_stale\n\n```scdoc\nbool TfLiteTensor::data_is_stale\n``` \nIf the delegate uses its own buffer (e.g.\n\nGPU memory), the delegate is responsible to set data_is_stale to true. `delegate-\u003eCopyFromBufferHandle` can be called to copy the data from delegate buffer.\n\nWARNING: This is an experimental interface that is subject to change. \n\n### delegate\n\n```scdoc\nstruct TfLiteDelegate * TfLiteTensor::delegate\n``` \nThe delegate which knows how to handle `buffer_handle`.\n\nWARNING: This is an experimental interface that is subject to change. \n\n### dims\n\n```scdoc\nTfLiteIntArray * TfLiteTensor::dims\n``` \nA pointer to a structure representing the dimensionality interpretation that the buffer should have.\n\nNOTE: the product of elements of `dims` and the element datatype size should be equal to `bytes` below. \n\n### dims_signature\n\n```gdscript\nconst TfLiteIntArray * TfLiteTensor::dims_signature\n``` \nOptional.\n\nEncodes shapes with unknown dimensions with -1. This field is only populated when unknown dimensions exist in a read-write tensor (i.e. an input or output tensor). (e.g. `dims` contains \\[1, 1, 1, 3\\] and `dims_signature` contains \\[1, -1, -1, 3\\]). If no unknown dimensions exist then `dims_signature` is either null, or set to an empty array. Note that this field only exists when TF_LITE_STATIC_MEMORY is not defined. \n\n### is_variable\n\n```gdscript\nbool TfLiteTensor::is_variable\n``` \nTrue if the tensor is a variable. \n\n### name\n\n```gdscript\nconst char * TfLiteTensor::name\n``` \nNull-terminated name of this tensor. \n\n### params\n\n```text\nTfLiteQuantizationParams TfLiteTensor::params\n``` \nQuantization information. \n\n### quantization\n\n```text\nTfLiteQuantization TfLiteTensor::quantization\n``` \nQuantization information. Replaces params field above. \n\n### sparsity\n\n```scdoc\nTfLiteSparsity * TfLiteTensor::sparsity\n``` \nParameters used to encode a sparse tensor.\n\nThis is optional. The field is NULL if a tensor is dense.\n\nWARNING: This is an experimental interface that is subject to change. \n\n### type\n\n```carbon\nTfLiteType TfLiteTensor::type\n``` \nThe data type specification for data stored in `data`.\n\nThis affects what member of `data` union should be used."]]