• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 
16 #include "tensorflow/lite/delegates/gpu/common/precision.h"
17 
18 namespace tflite {
19 namespace gpu {
20 
ToString(CalculationsPrecision precision)21 std::string ToString(CalculationsPrecision precision) {
22   switch (precision) {
23     case CalculationsPrecision::F32_F16:
24       return "CalculationsPrecision::F32_F16";
25     case CalculationsPrecision::F32:
26       return "CalculationsPrecision::F32";
27     case CalculationsPrecision::F16:
28       return "CalculationsPrecision::F16";
29   }
30 }
31 
DeduceDataTypeFromPrecision(CalculationsPrecision precision)32 DataType DeduceDataTypeFromPrecision(CalculationsPrecision precision) {
33   if (precision == CalculationsPrecision::F32) {
34     return DataType::FLOAT32;
35   } else {
36     return DataType::FLOAT16;
37   }
38 }
39 
40 }  // namespace gpu
41 }  // namespace tflite
42