Caffe2 - C++ API
A deep learning, cross platform ML framework
net_async_dag_gpu.h
1 #ifndef CAFFE2_CORE_NET_ASYNC_DAG_GPU_H_
2 #define CAFFE2_CORE_NET_ASYNC_DAG_GPU_H_
3 
4 #include "caffe2/core/common.h"
5 #include "caffe2/core/net_dag.h"
6 #include "caffe2/core/workspace.h"
7 #include "caffe2/proto/caffe2.pb.h"
8 
9 namespace caffe2 {
10 
11 // Run an event-driven graph - before each operator chain, wait on each parent
12 // operator for the chain source, then execute each operator. Due to the chain
13 // construction mechanism, operators in the same chain implicitly runs on the
14 // same stream.
15 // AsyncDAGNet is only registered in gpu mode, because CPU code is always sync
16 // and a CPU only AsyncDAG net is essentially a DAG net.
17 class AsyncDAGNet : public DAGNetBase {
18  public:
19  AsyncDAGNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
20  bool SupportsAsync() override {
21  return true;
22  }
23  bool RunAt(int chain_id, const std::vector<int>& chain) override;
24 
25  protected:
26  bool DoRunAsync() override;
27 
28  // Tracks whether a given op has had an event recorded in each
29  // RunAt() iteration.
30  std::vector<int32_t> eventRecorded_;
31 
32  int stream(const DeviceOption& device_option);
33  static thread_local std::vector<int> stream_counters_;
34 
35  DISABLE_COPY_AND_ASSIGN(AsyncDAGNet);
36 };
37 
38 } // namespace caffe2
39 
40 #endif // CAFFE2_CORE_NET_ASYNC_DAG_GPU_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 ...