Caffe2 - C++ API
A deep learning, cross platform ML framework
predictor_config.h
1 #pragma once
2 #include <memory>
3 #include "caffe2/core/net.h"
4 #include "caffe2/core/tensor.h"
5 #include "caffe2/proto/metanet.pb.h"
6 #include "caffe2/proto/predictor_consts.pb.h"
7 
8 namespace caffe2 {
9 
10 /*
11  * Parameters for a Predictor provided by name.
12  * They are stored as shared_ptr to accommodate parameter sharing
13  */
14 using PredictorParameters = std::map<std::string, std::shared_ptr<Blob>>;
15 
19 struct CAFFE2_API PredictorConfig {
20  // A map of parameter name to Tensor object. Predictor is supposed to
21  // guarantee constness of all these Tensor objects.
22  std::shared_ptr<PredictorParameters> parameters;
23 
24  std::shared_ptr<NetDef> predict_net;
25 
26  // Input names of a model. User will have to provide all of the inputs
27  // for inference
28  std::vector<std::string> input_names;
29  // Output names of a model. All outputs will be returned as results of
30  // inference
31  std::vector<std::string> output_names;
32  // Parameter names of a model. Should be a subset of parameters map passed in.
33  // We provide a separate set of parameter names here as whole parameter set
34  // passed in by a user might contain extra tensors used by other models
35  std::vector<std::string> parameter_names;
36 
37  // TODO We still save ws is because of the current design of workspace and
38  // tensor. Once tensor support intrusive_ptr, we'll get rid of this and use
39  // parameters to construct Workspace
40  std::shared_ptr<Workspace> ws;
41 };
42 
43 CAFFE2_API Workspace makeWorkspace(std::shared_ptr<PredictorParameters> parameters);
44 
45 CAFFE2_API PredictorConfig makePredictorConfig(
46  const MetaNetDef& net,
47  Workspace* parent = nullptr,
48  bool run_init = true);
49 
50 CAFFE2_API PredictorConfig makePredictorConfig(
51  const NetDef& init_net,
52  const NetDef& run_net,
53  Workspace* parent = nullptr,
54  bool run_init = true,
55  int optimization = 1);
56 
57 } // namespace caffe2
Stores parameters nessasary for creating a PredictorInterface object.
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