File indexing completed on 2023-03-17 11:16:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef PHYSICSTOOLS_TENSORFLOW_NOTHREADPOOL_H
0011 #define PHYSICSTOOLS_TENSORFLOW_NOTHREADPOOL_H
0012
0013 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0014
0015 #include "tensorflow/core/lib/core/threadpool.h"
0016 #include "tensorflow/core/lib/core/threadpool_options.h"
0017
0018 namespace tensorflow {
0019
0020 class NoThreadPool : public tensorflow::thread::ThreadPoolInterface {
0021 public:
0022 static NoThreadPool& instance() {
0023 CMS_THREAD_SAFE static NoThreadPool pool;
0024 return pool;
0025 }
0026
0027 explicit NoThreadPool() : numScheduleCalled_(0) {}
0028
0029 void Schedule(std::function<void()> fn) override {
0030 numScheduleCalled_ += 1;
0031 fn();
0032 }
0033
0034 void ScheduleWithHint(std::function<void()> fn, int start, int end) override { Schedule(fn); }
0035
0036 void Cancel() override {}
0037
0038 int NumThreads() const override { return 1; }
0039
0040 int CurrentThreadId() const override { return -1; }
0041
0042 int GetNumScheduleCalled() { return numScheduleCalled_; }
0043
0044 private:
0045 std::atomic<int> numScheduleCalled_;
0046 };
0047
0048 }
0049
0050 #endif