aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/context.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-07-03 13:17:19 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-03 13:20:38 -0700
commit3340c2da43f8b2313692aaad1a94da6c4a4e4106 (patch)
tree24f1f45d83c771c2324dec4f98b022faaca29849 /tensorflow/contrib/lite/context.h
parent02ed358a986496e387d5f2e52865b10606e52c0a (diff)
Remove framework's dependency on eigen and gemmlowp.
PiperOrigin-RevId: 203172717
Diffstat (limited to 'tensorflow/contrib/lite/context.h')
-rw-r--r--tensorflow/contrib/lite/context.h33
1 files changed, 29 insertions, 4 deletions
diff --git a/tensorflow/contrib/lite/context.h b/tensorflow/contrib/lite/context.h
index 4f260ad40a..1ff8843fa7 100644
--- a/tensorflow/contrib/lite/context.h
+++ b/tensorflow/contrib/lite/context.h
@@ -39,6 +39,26 @@ extern "C" {
typedef enum { kTfLiteOk = 0, kTfLiteError = 1 } TfLiteStatus;
+// The list of external context types known to TF Lite. This list exists solely
+// to avoid conflicts and to ensure ops can share the external contexts they
+// need. Access to the external contexts is controled by one of the
+// corresponding support files.
+typedef enum {
+ kTfLiteEigenContext = 0, // include eigen_support.h to use.
+ kTfLiteGemmLowpContext = 1, // include gemm_support.h to use.
+ kTfLiteMaxExternalContexts = 2
+} TfLiteExternalContextType;
+
+// An external context is a collection of information unrelated to the TF Lite
+// framework, but useful to a subset of the ops. TF Lite knows very little
+// about about the actual contexts, but it keeps a list of them, and is able to
+// refresh them if configurations like the number of recommended threads
+// change.
+typedef struct {
+ TfLiteExternalContextType type;
+ TfLiteStatus (*Refresh)(struct TfLiteContext* context);
+} TfLiteExternalContext;
+
// Forward declare so GetNode can use this is in Context.
typedef struct _TfLiteRegistration TfLiteRegistration;
typedef struct _TfLiteDelegate TfLiteDelegate;
@@ -339,10 +359,15 @@ typedef struct TfLiteContext {
// eigen.
int recommended_num_threads;
- // TODO(ahentz): we should create a more general mechanism for this sort of
- // library-global objects.
- void* gemm_context;
- void* eigen_context;
+ // Access external contexts by type.
+ // WARNING: This is an experimental interface that is subject to change.
+ TfLiteExternalContext* (*GetExternalContext)(struct TfLiteContext*,
+ TfLiteExternalContextType);
+ // Set the value of a external context. Does not take ownership of the
+ // pointer.
+ // WARNING: This is an experimental interface that is subject to change.
+ void (*SetExternalContext)(struct TfLiteContext*, TfLiteExternalContextType,
+ TfLiteExternalContext*);
} TfLiteContext;
typedef struct _TfLiteRegistration {