• 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 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_HINTS_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_HINTS_H_
18 
19 #include <cstdint>
20 
21 namespace tflite {
22 namespace gpu {
23 
24 struct ModelHints {
25   using ModelHint = uint64_t;
26 
27   // By default we want the fastest inference.
28   static constexpr ModelHint kFastestInference = 0x00000000;
29   // Can improve compilation time, but inference can be slower.
30   static constexpr ModelHint kReduceKernelsCount = 0x00000001;
31   // Can improve tuning time, but inference can be slower.
32   static constexpr ModelHint kFastTuning = 0x00000002;
33 
34   // Can improve performance and memory consumption, but slow down
35   // initialization and create more unique kernels.
36   static constexpr ModelHint kAllowSpecialKernels = 0x00000004;
37 
38   // By default we apply Winograd optimized kernels and it improves performance.
39   // But it also can increase memory usage and decrease precision.
40   // This hint can disable Winograd optimizations.
41   static constexpr ModelHint kNoWinogradOptimizations = 0x00000008;
42 
AddModelHints43   void Add(ModelHint hint) {
44     if (hint == kFastestInference) {
45       hints = kFastestInference;
46     } else {
47       hints |= hint;
48     }
49   }
50 
CheckModelHints51   bool Check(ModelHint hint) const { return hints & hint; }
52 
53   uint64_t hints = kFastestInference;
54 };
55 
56 }  // namespace gpu
57 }  // namespace tflite
58 
59 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_HINTS_H_
60