19
#include "c10/util/Flags.h"
20
#include "caffe2/core/init.h"
21
#include "caffe2/core/logging.h"
22
#include "caffe2/core/operator.h"
23
#include "caffe2/proto/caffe2_pb.h"
24
#include "caffe2/utils/proto_utils.h"
26
C10_DEFINE_string(plan, "", "The given path to the plan protobuffer.");
28
int main(int argc, char** argv) {
29
c10::SetUsageMessage("Runs a caffe2 plan that has MPI operators in it.");
31
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &mpi_ret);
32
if (mpi_ret != MPI_THREAD_MULTIPLE &&
33
mpi_ret != MPI_THREAD_SERIALIZED) {
34
std::cerr << "Caffe2 MPI requires the underlying MPI to support the "
35
"MPI_THREAD_SERIALIZED or MPI_THREAD_MULTIPLE mode.\n";
38
caffe2::GlobalInit(&argc, &argv);
39
LOG(INFO) << "Loading plan: " << FLAGS_plan;
40
caffe2::PlanDef plan_def;
41
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_plan, &plan_def));
42
std::unique_ptr<caffe2::Workspace> workspace(new caffe2::Workspace());
43
workspace->RunPlan(plan_def);
46
caffe2::ShutdownProtobufLibrary();