• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_DELEGATES_FLEX_UTIL_H_
16 #define TENSORFLOW_LITE_DELEGATES_FLEX_UTIL_H_
17 
18 #include "tensorflow/c/c_api_internal.h"
19 #include "tensorflow/lite/c/c_api_internal.h"
20 #include "tensorflow/core/framework/tensor.h"
21 #include "tensorflow/core/lib/core/status.h"
22 
23 namespace tflite {
24 namespace flex {
25 
26 // Converts a tensorflow:Status into a TfLiteStatus. If the original status
27 // represented an error, reports it using the given 'context'.
28 TfLiteStatus ConvertStatus(TfLiteContext* context,
29                            const tensorflow::Status& status);
30 
31 // Copies the given shape and type of the TensorFlow 'src' tensor into a TF Lite
32 // 'tensor'. Logs an error and returns kTfLiteError if the shape or type can't
33 // be converted.
34 TfLiteStatus CopyShapeAndType(TfLiteContext* context,
35                               const tensorflow::Tensor& src,
36                               TfLiteTensor* tensor);
37 
38 // Returns the TF C API Data type that corresponds to the given TfLiteType.
39 TF_DataType GetTensorFlowDataType(TfLiteType type);
40 
41 // Returns the TfLiteType that corresponds to the given TF C API Data type.
42 TfLiteType GetTensorFlowLiteType(TF_DataType);
43 
44 }  // namespace flex
45 }  // namespace tflite
46 
47 #endif  // TENSORFLOW_LITE_DELEGATES_FLEX_UTIL_H_
48