mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
This reverts commit 716b3b893d.
Reverted https://github.com/pytorch/pytorch/pull/103725 on behalf of https://github.com/osalpekar due to Broke caffe2 builds due. More info at [D46920675](https://www.internalfb.com/diff/D46920675) ([comment](https://github.com/pytorch/pytorch/pull/103725#issuecomment-1603129273))
47 lines
990 B
C++
47 lines
990 B
C++
#include "caffe2/opt/optimizer.h"
|
|
|
|
#include "caffe2/opt/converter.h"
|
|
#include "caffe2/opt/mobile.h"
|
|
#include "caffe2/opt/fusion.h"
|
|
|
|
namespace caffe2 {
|
|
namespace opt {
|
|
|
|
void workspaceOptimizations(nom::repr::NNModule* nn, Workspace* ws, int level) {
|
|
switch (level) {
|
|
case 1:
|
|
opt::fuseConvBN(nn, ws);
|
|
case 0:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void graphOptimzations(nom::repr::NNModule* nn, int level) {
|
|
switch (level) {
|
|
case 1:
|
|
#ifdef USE_NNPACK
|
|
opt::addNNPACK(nn, false);
|
|
opt::fuseNNPACKConvRelu(nn);
|
|
#endif
|
|
case 0:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
NetDef optimize(NetDef net, Workspace* ws, int level) {
|
|
auto nn = convertToNNModule(net);
|
|
graphOptimzations(&nn, level);
|
|
workspaceOptimizations(&nn, ws, level);
|
|
return convertToCaffe2Proto(nn, net);
|
|
}
|
|
|
|
NetDef optimize(NetDef net, int level) {
|
|
auto nn = convertToNNModule(net);
|
|
graphOptimzations(&nn, level);
|
|
return convertToCaffe2Proto(nn, net);
|
|
}
|
|
|
|
} // namespace opt
|
|
} // namespace caffe2
|