1/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations 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
20namespace EigenForTFLite {
21struct ThreadPoolDevice;
22}
23
24namespace tflite {
25namespace 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'.
29void 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.
33void 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.
40const EigenForTFLite::ThreadPoolDevice* GetThreadPoolDevice(
41 TfLiteContext* context);
42
43} // namespace eigen_support
44} // namespace tflite
45
46#endif // TENSORFLOW_LITE_KERNELS_EIGEN_SUPPORT_H_
47