17
#include "caffe2/core/flags.h"
18
#include "caffe2/core/init.h"
19
#include "caffe2/predictor/predictor.h"
20
#include "caffe2/utils/proto_utils.h"
22
C10_DEFINE_string(init_net, "", "The given path to the init protobuffer.");
26
"The given path to the predict protobuffer.");
31
if (FLAGS_init_net.empty()) {
32
LOG(FATAL) << "No init net specified. Use --init_net=/path/to/net.";
34
if (FLAGS_predict_net.empty()) {
35
LOG(FATAL) << "No predict net specified. Use --predict_net=/path/to/net.";
37
caffe2::NetDef init_net, predict_net;
38
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &init_net));
39
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predict_net));
41
VLOG(1) << "Init net: " << ProtoDebugString(init_net);
42
LOG(INFO) << "Predict net: " << ProtoDebugString(predict_net);
43
auto predictor = std::make_unique<Predictor>(init_net, predict_net);
44
LOG(INFO) << "Checking that a null forward-pass works";
45
Predictor::TensorList inputVec, outputVec;
46
(*predictor)(inputVec, &outputVec);
47
CAFFE_ENFORCE_GT(outputVec.size(), 0);
51
int main(int argc, char** argv) {
52
caffe2::GlobalInit(&argc, &argv);
55
caffe2::ShutdownProtobufLibrary();