Caffe2 - C++ API
A deep learning, cross platform ML framework
predictor.h
1 #pragma once
2 
3 #include "caffe2/core/net.h"
4 #include "caffe2/core/tensor.h"
5 
6 namespace caffe2 {
7 
8 class Predictor {
9  public:
10  using TensorVector = std::vector<TensorCPU*>;
11  // Runs the `init_net` once, then saves the `run_net` to be executed
12  // in `::run`
13  Predictor(
14  const NetDef& init_net,
15  const NetDef& run_net,
16  Workspace* parent = nullptr);
17 
18  // Executes `run_net` on the inputs.
19  // The first `inputs.size()` inputs from run_net::external_inputs
20  // are shared with the data in `inputs`.
21 
22  // Precondition:
23  // inputs.size() <= run_net_.external_inputs.size()
24 
25  // Postcondition:
26  // outputs->size() == run_net.external_inputs.size()
27  void run(const TensorVector& inputs, TensorVector* outputs);
28 
29  const NetDef& def() const {
30  return run_net_;
31  };
32 
33  Workspace* ws() {
34  return &ws_;
35  };
36 
37  private:
38  NetDef run_net_;
39  Workspace ws_;
40 };
41 }
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:53
Simple registry implementation in Caffe2 that uses static variables to register object creators durin...