Caffe2 - C++ API
A deep learning, cross platform ML framework
net_gl.h
1 #ifndef CAFFE2_CORE_NET_GL_H_
2 #define CAFFE2_CORE_NET_GL_H_
3 
4 #include <vector>
5 
6 #include "caffe2/core/common.h"
7 #include "caffe2/core/logging.h"
8 #include "caffe2/core/net.h"
9 #include "caffe2/core/registry.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 with
17 // ARM's compute library
18 class GLNet : public NetBase {
19  private:
20  bool first_run_ = true;
21  Workspace* ws_;
22  // record output blob for sync step in operator level benchmarking
23  std::vector<string> output_blobs_;
24  // record operator type and only sync after gpu op
25  std::vector<bool> opengl_device_;
26  public:
27  GLNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
28  bool SupportsAsync() override {
29  return false;
30  }
31 
32  vector<float> TEST_Benchmark(
33  const int warmup_runs,
34  const int main_runs,
35  const bool run_individual) override;
36 
37  /*
38  * This returns a list of pointers to objects stored in unique_ptrs.
39  * Used by Observers.
40  *
41  * Think carefully before using.
42  */
43  vector<OperatorBase*> GetOperators() const override {
44  vector<OperatorBase*> op_list;
45  for (auto& op : operators_) {
46  op_list.push_back(op.get());
47  }
48  return op_list;
49  }
50 
51  protected:
52  bool Run();
53  bool RunAsync();
54  bool DoRunAsync() override {
55  return Run();
56  }
57 
58  vector<unique_ptr<OperatorBase>> operators_;
59 
60  DISABLE_COPY_AND_ASSIGN(GLNet);
61 };
62 
63 } // namespace caffe2
64 
65 #endif // CAFFE2_CORE_NET_SIMPLE_H_
vector< float > TEST_Benchmark(const int warmup_runs, const int main_runs, const bool run_individual) override
Benchmarks a network.
Definition: net_gl.cc:87
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 ...