Caffe2 - C++ API
A deep learning, cross platform ML framework
net_simple.h
1 #ifndef CAFFE2_CORE_NET_SIMPLE_H_
2 #define CAFFE2_CORE_NET_SIMPLE_H_
3 
4 #include <vector>
5 
6 #include "c10/util/Registry.h"
7 #include "caffe2/core/common.h"
8 #include "caffe2/core/logging.h"
9 #include "caffe2/core/net.h"
10 #include "caffe2/core/tensor.h"
11 #include "caffe2/core/workspace.h"
12 #include "caffe2/proto/caffe2_pb.h"
13 
14 namespace caffe2 {
15 
16 // This is the very basic structure you need to run a network - all it
17 // does is simply to run everything in sequence. If you want more fancy control
18 // such as a DAG-like execution, check out other better net implementations.
19 class CAFFE2_API SimpleNet : public NetBase {
20  public:
21  SimpleNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
22  bool SupportsAsync() override {
23  return false;
24  }
25 
26  vector<float> TEST_Benchmark(
27  const int warmup_runs,
28  const int main_runs,
29  const bool run_individual) override;
30 
31  /*
32  * This returns a list of pointers to objects stored in unique_ptrs.
33  * Used by Observers.
34  *
35  * Think carefully before using.
36  */
37  vector<OperatorBase*> GetOperators() const override {
38  vector<OperatorBase*> op_list;
39  for (auto& op : operators_) {
40  op_list.push_back(op.get());
41  }
42  return op_list;
43  }
44 
45  protected:
46  bool Run() override;
47  bool RunAsync() override;
48 
49  vector<unique_ptr<OperatorBase>> operators_;
50 
51  C10_DISABLE_COPY_AND_ASSIGN(SimpleNet);
52 };
53 
54 } // namespace caffe2
55 
56 #endif // CAFFE2_CORE_NET_SIMPLE_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 ...
Definition: blob.h:13