aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/kernels/kernel_util.h
diff options
context:
space:
mode:
authorGravatar Nupur Garg <nupurgarg@google.com>2018-01-25 09:34:11 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-25 09:40:45 -0800
commit03bb1c4a6014fdf3f10f301f093ec02d84f717c7 (patch)
tree4b7427247587f0240cd76a322ff21e1ddaf75270 /tensorflow/contrib/lite/kernels/kernel_util.h
parentbab793233e42b7654771769d4d4a7974b432883c (diff)
Add functions to encapsulate the logic for checking and setting tensor type.
PiperOrigin-RevId: 183250334
Diffstat (limited to 'tensorflow/contrib/lite/kernels/kernel_util.h')
-rw-r--r--tensorflow/contrib/lite/kernels/kernel_util.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/kernels/kernel_util.h b/tensorflow/contrib/lite/kernels/kernel_util.h
index 1cf30ecff9..bfdfba00f5 100644
--- a/tensorflow/contrib/lite/kernels/kernel_util.h
+++ b/tensorflow/contrib/lite/kernels/kernel_util.h
@@ -44,6 +44,22 @@ inline TfLiteTensor* GetOptionalInputTensor(TfLiteContext* context,
return nullptr;
}
+// Determines whether tensor is constant.
+inline bool IsConstantTensor(TfLiteTensor* tensor) {
+ return tensor->allocation_type == kTfLiteMmapRo;
+}
+
+// Determines whether tensor is dynamic. Note that a tensor can be non-const and
+// not dynamic. This function specificially checks for a dynamic tensor.
+inline bool IsDynamicTensor(TfLiteTensor* tensor) {
+ return tensor->allocation_type == kTfLiteDynamic;
+}
+
+// Sets tensor to dynamic.
+inline void SetTensorToDynamic(TfLiteTensor* tensor) {
+ tensor->allocation_type = kTfLiteDynamic;
+}
+
// Calculates the multiplication factor for a quantized convolution (or
// quantized depthwise convolution) involving the given tensors. Returns an
// error if the scales of the tensors are not compatible.