• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 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_COMMON_RUNTIME_EIGEN_THREAD_POOL_H_
17 #define TENSORFLOW_COMMON_RUNTIME_EIGEN_THREAD_POOL_H_
18 
19 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
20 #include "tensorflow/core/lib/core/threadpool.h"
21 
22 namespace tensorflow {
23 
24 class EigenThreadPoolWrapper : public Eigen::ThreadPoolInterface {
25  public:
EigenThreadPoolWrapper(thread::ThreadPool * pool)26   explicit EigenThreadPoolWrapper(thread::ThreadPool* pool) : pool_(pool) {}
~EigenThreadPoolWrapper()27   ~EigenThreadPoolWrapper() override {}
28 
Schedule(std::function<void ()> fn)29   void Schedule(std::function<void()> fn) override {
30     pool_->Schedule(std::move(fn));
31   }
NumThreads()32   int NumThreads() const override { return pool_->NumThreads(); }
CurrentThreadId()33   int CurrentThreadId() const override { return pool_->CurrentThreadId(); }
34 
35  private:
36   thread::ThreadPool* pool_ = nullptr;
37 };
38 
39 }  // namespace tensorflow
40 
41 #endif  // TENSORFLOW_COMMON_RUNTIME_EIGEN_THREAD_POOL_H_
42