Caffe2 - C++ API
A deep learning, cross platform ML framework
net_async_polling.h
1 
17 #ifndef CAFFE2_CORE_NET_ASYNC_POLLING_H_
18 #define CAFFE2_CORE_NET_ASYNC_POLLING_H_
19 
20 #include "caffe2/core/net_async_base.h"
21 
22 namespace caffe2 {
23 
24 class AsyncPollingNet : public AsyncNetBase {
25  public:
26  AsyncPollingNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
27  ~AsyncPollingNet() override;
28 
29  protected:
30  bool DoRunAsync() override;
31 
32  bool pollAndSchedule();
33  void schedule(int task_id);
34 
35  // Synchronization
36  std::mutex running_mutex_;
37  std::condition_variable running_cv_;
38  std::atomic<bool> running_;
39 
40  // Stats
42  CAFFE_STAT_CTOR(AsyncPollingNetStats);
43  CAFFE_AVG_EXPORTED_STAT(poll_time_ms);
44  CAFFE_AVG_EXPORTED_STAT(task_pool_wait_time_us);
45  CAFFE_AVG_EXPORTED_STAT(task_run_time_us);
46  CAFFE_AVG_EXPORTED_STAT(poll_status_update_time_us);
47  CAFFE_AVG_EXPORTED_STAT(task_time_to_scheduled_us);
48  CAFFE_AVG_EXPORTED_STAT(task_time_to_succeeded_ms);
49  };
50  mutable std::vector<AsyncPollingNetStats> stats_;
51  std::vector<std::unique_ptr<Timer>> task_timers_;
52  void updateTaskStats(int task_id);
53 
54  // Polling
55  std::vector<EventStatus> status_;
56  void reset();
57  std::atomic<bool> has_chain_failed_;
58 
59  DISABLE_COPY_AND_ASSIGN(AsyncPollingNet);
60 };
61 
62 } // namespace caffe2
63 
64 #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:63
Copyright (c) 2016-present, Facebook, Inc.