• 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_KERNELS_EIGEN_SUPPORT_H_
16 #define TENSORFLOW_LITE_KERNELS_EIGEN_SUPPORT_H_
17 
18 #include "tensorflow/lite/c/common.h"
19 
20 namespace EigenForTFLite {
21 struct ThreadPoolDevice;
22 }
23 
24 namespace tflite {
25 namespace eigen_support {
26 
27 // Let the framework know that the op will be using Eigen. If necessary a set of
28 // temporary Eigen objects might be created and placed in 'context'.
29 void IncrementUsageCounter(TfLiteContext* context);
30 
31 // Let the framework know that the op stopped using Eigen. If there are no more
32 // usages all temporary Eigen objects will be deleted.
33 void DecrementUsageCounter(TfLiteContext* context);
34 
35 // Fetch the ThreadPoolDevice associated with the provided context.
36 //
37 // Note: The caller must ensure that |IncrementUsageCounter()| has already been
38 // called. Moreover, it is *not* safe to cache the returned device; it may be
39 // invalidated if the context thread count changes.
40 const EigenForTFLite::ThreadPoolDevice* GetThreadPoolDevice(
41     TfLiteContext* context);
42 
43 }  // namespace eigen_support
44 }  // namespace tflite
45 
46 #endif  // TENSORFLOW_LITE_KERNELS_EIGEN_SUPPORT_H_
47