Caffe2 - C++ API
A deep learning, cross platform ML framework
optimizer.cc
1 #include "caffe2/opt/optimizer.h"
2 
3 #include "caffe2/opt/converter.h"
4 #include "caffe2/opt/mobile.h"
5 #include "caffe2/opt/fusion.h"
6 
7 namespace caffe2 {
8 namespace opt {
9 
10 void workspaceOptimizations(nom::repr::NNModule* nn, Workspace* ws, int level) {
11  switch (level) {
12  case 1:
13  opt::fuseConvBN(nn, ws);
14  case 0:
15  default:
16  break;
17  }
18 }
19 
20 void graphOptimzations(nom::repr::NNModule* nn, int level) {
21  switch (level) {
22  case 1:
23 #ifdef USE_NNPACK
24  opt::addNNPACK(nn, false);
25  opt::fuseNNPACKConvRelu(nn);
26 #endif
27  case 0:
28  default:
29  break;
30  }
31 }
32 
33 NetDef optimize(NetDef net, Workspace* ws, int level) {
34  auto nn = convertToNNModule(net);
35  graphOptimzations(&nn, level);
36  workspaceOptimizations(&nn, ws, level);
37  return convertToCaffe2Proto(nn, net);
38 }
39 
40 NetDef optimize(NetDef net, int level) {
41  auto nn = convertToNNModule(net);
42  graphOptimzations(&nn, level);
43  return convertToCaffe2Proto(nn, net);
44 }
45 
46 } // namespace opt
47 } // namespace caffe2
48 
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
repr::NNModule convertToNNModule(const caffe2::NetDef &net, bool strict, std::vector< repr::NNGraph::NodeRef > *opNodeVec)
Ingest a caffe2 protobuf model and output an NNModule.
Definition: converter.cc:301