From 7fd5508f595cd0d6bbc7d240de618fb2f8d83fd3 Mon Sep 17 00:00:00 2001 From: jiangzhenguang Date: Fri, 26 Mar 2021 16:21:25 +0800 Subject: [PATCH] fix res18 310 infer --- .../cv/resnet/ascend310_infer/src/main.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/model_zoo/official/cv/resnet/ascend310_infer/src/main.cc b/model_zoo/official/cv/resnet/ascend310_infer/src/main.cc index 9f3f52356b..7371d46abf 100644 --- a/model_zoo/official/cv/resnet/ascend310_infer/src/main.cc +++ b/model_zoo/official/cv/resnet/ascend310_infer/src/main.cc @@ -39,10 +39,9 @@ using mindspore::dataset::vision::CenterCrop; using mindspore::dataset::vision::Normalize; using mindspore::dataset::vision::HWC2CHW; using mindspore::dataset::TensorTransform; -using mindspore::GlobalContext; using mindspore::Serialization; using mindspore::Model; -using mindspore::ModelContext; +using mindspore::Context; using mindspore::Status; using mindspore::ModelType; using mindspore::GraphCell; @@ -62,14 +61,14 @@ int main(int argc, char **argv) { return 1; } - - GlobalContext::SetGlobalDeviceTarget(mindspore::kDeviceTypeAscend310); - GlobalContext::SetGlobalDeviceID(FLAGS_device_id); - auto graph = Serialization::LoadModel(FLAGS_mindir_path, ModelType::kMindIR); - auto model_context = std::make_shared(); - - Model model(GraphCell(graph), model_context); - Status ret = model.Build(); + auto context = std::make_shared(); + auto ascend310 = std::make_shared(); + ascend310->SetDeviceID(FLAGS_device_id); + context->MutableDeviceInfo().push_back(ascend310); + mindspore::Graph graph; + Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph); + Model model; + Status ret = model.Build(GraphCell(graph), context); if (ret != kSuccess) { std::cout << "ERROR: Build failed." << std::endl; return 1;