aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/c
diff options
context:
space:
mode:
authorGravatar Pete Warden <petewarden@google.com>2018-09-24 15:54:32 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-24 16:02:13 -0700
commit1ff157d82dac29f5a3a3197b2664208f6ed6ba06 (patch)
treec751f5a665a27c660809c4884eb07f69b4983244 /tensorflow/contrib/lite/c
parent9c58005ec86297a1d0a17dc4f7ad7cbae9c47e4b (diff)
Portability preparation for more cross-platform prototyping.
PiperOrigin-RevId: 214346240
Diffstat (limited to 'tensorflow/contrib/lite/c')
-rw-r--r--tensorflow/contrib/lite/c/c_api_internal.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/tensorflow/contrib/lite/c/c_api_internal.c b/tensorflow/contrib/lite/c/c_api_internal.c
index 1846bad4b7..8a0c177b19 100644
--- a/tensorflow/contrib/lite/c/c_api_internal.c
+++ b/tensorflow/contrib/lite/c/c_api_internal.c
@@ -14,15 +14,29 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/contrib/lite/c/c_api_internal.h"
+#ifndef TF_LITE_STATIC_MEMORY
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#endif // TF_LITE_STATIC_MEMORY
int TfLiteIntArrayGetSizeInBytes(int size) {
static TfLiteIntArray dummy;
return sizeof(dummy) + sizeof(dummy.data[0]) * size;
}
+int TfLiteIntArrayEqual(TfLiteIntArray* a, TfLiteIntArray* b) {
+ if (a == b) return 1;
+ if (a == NULL || b == NULL) return 0;
+ if (a->size != b->size) return 0;
+ int i = 0;
+ for (; i < a->size; i++)
+ if (a->data[i] != b->data[i]) return 0;
+ return 1;
+}
+
+#ifndef TF_LITE_STATIC_MEMORY
+
TfLiteIntArray* TfLiteIntArrayCreate(int size) {
TfLiteIntArray* ret =
(TfLiteIntArray*)malloc(TfLiteIntArrayGetSizeInBytes(size));
@@ -40,16 +54,6 @@ void TfLiteIntArrayPrint(const char* s, TfLiteIntArray* a) {
printf("]\n");
}
-int TfLiteIntArrayEqual(TfLiteIntArray* a, TfLiteIntArray* b) {
- if (a == b) return 1;
- if (a == NULL || b == NULL) return 0;
- if (a->size != b->size) return 0;
- int i = 0;
- for (; i < a->size; i++)
- if (a->data[i] != b->data[i]) return 0;
- return 1;
-}
-
TfLiteIntArray* TfLiteIntArrayCopy(TfLiteIntArray* src) {
if (!src) return NULL;
TfLiteIntArray* ret = TfLiteIntArrayCreate(src->size);
@@ -102,3 +106,4 @@ void TfLiteTensorRealloc(size_t num_bytes, TfLiteTensor* tensor) {
}
tensor->bytes = num_bytes;
}
+#endif // TF_LITE_STATIC_MEMORY