Caffe2 - C++ API
A deep learning, cross platform ML framework
net_simple.h
1 
17 #ifndef CAFFE2_CORE_NET_SIMPLE_H_
18 #define CAFFE2_CORE_NET_SIMPLE_H_
19 
20 #include <vector>
21 
22 #include "caffe2/core/common.h"
23 #include "caffe2/core/logging.h"
24 #include "caffe2/core/net.h"
25 #include "caffe2/core/registry.h"
26 #include "caffe2/core/tensor.h"
27 #include "caffe2/core/workspace.h"
28 #include "caffe2/proto/caffe2.pb.h"
29 
30 namespace caffe2 {
31 
32 // This is the very basic structure you need to run a network - all it
33 // does is simply to run everything in sequence. If you want more fancy control
34 // such as a DAG-like execution, check out other better net implementations.
35 class SimpleNet : public NetBase {
36  public:
37  SimpleNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
38  bool SupportsAsync() override {
39  return false;
40  }
41 
42  vector<float> TEST_Benchmark(
43  const int warmup_runs,
44  const int main_runs,
45  const bool run_individual) override;
46 
47  /*
48  * This returns a list of pointers to objects stored in unique_ptrs.
49  * Used by Observers.
50  *
51  * Think carefully before using.
52  */
53  vector<OperatorBase*> GetOperators() const override {
54  vector<OperatorBase*> op_list;
55  for (auto& op : operators_) {
56  op_list.push_back(op.get());
57  }
58  return op_list;
59  }
60 
61  protected:
62  bool Run() override;
63  bool RunAsync() override;
64 
65  vector<unique_ptr<OperatorBase>> operators_;
66 
67  DISABLE_COPY_AND_ASSIGN(SimpleNet);
68 };
69 
70 } // namespace caffe2
71 
72 #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:63
Copyright (c) 2016-present, Facebook, Inc.
vector< float > TEST_Benchmark(const int warmup_runs, const int main_runs, const bool run_individual) override
Benchmarks a network.
Definition: net_simple.cc:97