Caffe2 - C++ API
A deep learning, cross platform ML framework
net_async_polling.h
1 #ifndef CAFFE2_CORE_NET_ASYNC_POLLING_H_
2 #define CAFFE2_CORE_NET_ASYNC_POLLING_H_
3 
4 #include "caffe2/core/net_async_base.h"
5 
6 namespace caffe2 {
7 
8 class AsyncPollingNet : public AsyncNetBase {
9  public:
10  AsyncPollingNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
11  ~AsyncPollingNet() override;
12 
13  protected:
14  bool DoRunAsync() override;
15 
16  bool pollAndSchedule();
17  void schedule(int task_id);
18 
19  // Synchronization
20  std::mutex running_mutex_;
21  std::condition_variable running_cv_;
22  std::atomic<bool> running_;
23 
24  // Stats
26  CAFFE_STAT_CTOR(AsyncPollingNetStats);
27  CAFFE_AVG_EXPORTED_STAT(poll_time_ms);
28  CAFFE_AVG_EXPORTED_STAT(task_pool_wait_time_us);
29  CAFFE_AVG_EXPORTED_STAT(task_run_time_us);
30  CAFFE_AVG_EXPORTED_STAT(poll_status_update_time_us);
31  CAFFE_AVG_EXPORTED_STAT(task_time_to_scheduled_us);
32  CAFFE_AVG_EXPORTED_STAT(task_time_to_succeeded_ms);
33  };
34  mutable std::vector<AsyncPollingNetStats> stats_;
35  std::vector<std::unique_ptr<Timer>> task_timers_;
36  void updateTaskStats(int task_id);
37 
38  // Polling
39  std::vector<EventStatus> status_;
40  void reset();
41  std::atomic<bool> has_chain_failed_;
42 
43  DISABLE_COPY_AND_ASSIGN(AsyncPollingNet);
44 };
45 
46 } // namespace caffe2
47 
48 #endif // CAFFE2_CORE_NET_ASYNC_POLLING_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...