Caffe2 - C++ API
A deep learning, cross platform ML framework
net_simple_async.h
1 
17 #ifndef CAFFE2_CORE_NET_SIMPLE_ASYNC_H_
18 #define CAFFE2_CORE_NET_SIMPLE_ASYNC_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 AsyncSimpleNet : public NetBase {
36  public:
37  AsyncSimpleNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
38 
39  bool SupportsAsync() override {
40  return true;
41  }
42 
43  vector<float> TEST_Benchmark(
44  const int warmup_runs,
45  const int main_runs,
46  const bool run_individual) override;
47 
48  /*
49  * This returns a list of pointers to objects stored in unique_ptrs.
50  * Used by Observers.
51  *
52  * Think carefully before using.
53  */
54  vector<OperatorBase*> GetOperators() const override {
55  vector<OperatorBase*> op_list;
56  for (auto& op : operators_) {
57  op_list.push_back(op.get());
58  }
59  return op_list;
60  }
61 
62  protected:
63  bool DoRunAsync() override;
64 
65  vector<unique_ptr<OperatorBase>> operators_;
66 
67  DISABLE_COPY_AND_ASSIGN(AsyncSimpleNet);
68 };
69 
70 } // namespace caffe2
71 
72 #endif // CAFFE2_CORE_NET_SIMPLE_ASYNC_H_
vector< float > TEST_Benchmark(const int warmup_runs, const int main_runs, const bool run_individual) override
Benchmarks a network.
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.