@@ -42,6 +42,7 @@ limitations under the License.
42
42
#ifndef TENSORFLOW_LITE_CORE_C_COMMON_H_
43
43
#define TENSORFLOW_LITE_CORE_C_COMMON_H_
44
44
45
+ #include <stdarg.h>
45
46
#include <stdbool.h>
46
47
#include <stddef.h>
47
48
#include <stdint.h>
@@ -648,23 +649,26 @@ void TfLiteTensorReset(TfLiteType type, const char* name, TfLiteIntArray* dims,
648
649
TfLiteStatus TfLiteTensorCopy (const TfLiteTensor * src , TfLiteTensor * dst );
649
650
650
651
// Change the size of the memory block owned by `tensor` to `num_bytes`.
651
- // Tensors with allocation types other than kTfLiteDynamic will be ignored.
652
+ // Tensors with allocation types other than `kTfLiteDynamic` will be ignored and
653
+ // a kTfLiteOk will be returned.
652
654
// `tensor`'s internal data buffer will be assigned a pointer
653
655
// which can safely be passed to free or realloc if `num_bytes` is zero.
654
- // Behaviour is undefined if `tensor` is NULL.
655
656
// If `preserve_data` is true, tensor data will be unchanged in the range from
656
- // the start of the region up to the minimum of the old and new sizes.
657
- void TfLiteTensorResizeMaybeCopy (size_t num_bytes , TfLiteTensor * tensor ,
658
- bool preserve_data );
657
+ // the start of the region up to the minimum of the old and new sizes. In the
658
+ // case of NULL tensor, or an error allocating new memory, returns
659
+ // `kTfLiteError`.
660
+ TfLiteStatus TfLiteTensorResizeMaybeCopy (size_t num_bytes , TfLiteTensor * tensor ,
661
+ bool preserve_data );
659
662
660
663
// Change the size of the memory block owned by `tensor` to `num_bytes`.
661
- // Tensors with allocation types other than kTfLiteDynamic will be ignored.
664
+ // Tensors with allocation types other than kTfLiteDynamic will be ignored and
665
+ // a kTfLiteOk will be returned.
662
666
// `tensor`'s internal data buffer will be assigned a pointer
663
667
// which can safely be passed to free or realloc if `num_bytes` is zero.
664
- // Behaviour is undefined if `tensor` is NULL.
665
668
// Tensor data will be unchanged in the range from the start of the region up to
666
- // the minimum of the old and new sizes.
667
- void TfLiteTensorRealloc (size_t num_bytes , TfLiteTensor * tensor );
669
+ // the minimum of the old and new sizes. In the case
670
+ // of NULL tensor, or an error allocating new memory, returns `kTfLiteError`.
671
+ TfLiteStatus TfLiteTensorRealloc (size_t num_bytes , TfLiteTensor * tensor );
668
672
#endif // TF_LITE_STATIC_MEMORY
669
673
670
674
// WARNING: This is an experimental interface that is subject to change.
@@ -1135,6 +1139,20 @@ TfLiteOpaqueDelegate* TfLiteOpaqueDelegateCreate(
1135
1139
// 'delegate' is a null pointer.
1136
1140
void TfLiteOpaqueDelegateDelete (TfLiteOpaqueDelegate * delegate );
1137
1141
1142
+ // Returns a pointer to the data associated with the provided opaque 'delegate'.
1143
+ //
1144
+ // A null pointer will be returned when:
1145
+ // - The 'delegate' is null.
1146
+ // - The 'data' field of the 'TfLiteOpaqueDelegateBuilder' used to construct the
1147
+ // 'delegate' was null.
1148
+ // - Or in case of any other error.
1149
+ // - The 'delegate' has been constructed via a 'TfLiteOpaqueDelegateBuilder',
1150
+ // but the 'data' field of the 'TfLiteOpaqueDelegateBuilder' is null.
1151
+ //
1152
+ // The data_ field of 'delegate' will be returned if the
1153
+ // 'opaque_delegate_builder' field is null.
1154
+ void * TfLiteOpaqueDelegateGetData (const TfLiteOpaqueDelegate * delegate );
1155
+
1138
1156
#ifdef __cplusplus
1139
1157
} // extern "C"
1140
1158
#endif // __cplusplus
0 commit comments