| @@ -23,6 +23,10 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| Status Model::Build(GraphCell graph, const std::shared_ptr<Context> &model_context) { | Status Model::Build(GraphCell graph, const std::shared_ptr<Context> &model_context) { | ||||
| if (impl_ != nullptr) { | |||||
| MS_LOG(DEBUG) << "Model has been already built."; | |||||
| return kSuccess; | |||||
| } | |||||
| impl_ = std::shared_ptr<ModelImpl>(new (std::nothrow) ModelImpl()); | impl_ = std::shared_ptr<ModelImpl>(new (std::nothrow) ModelImpl()); | ||||
| if (impl_ == nullptr) { | if (impl_ == nullptr) { | ||||
| MS_LOG(ERROR) << "Model implement is null."; | MS_LOG(ERROR) << "Model implement is null."; | ||||
| @@ -37,10 +37,6 @@ using mindspore::lite::RET_OK; | |||||
| Status ModelImpl::Build() { | Status ModelImpl::Build() { | ||||
| MS_LOG(DEBUG) << "Start build model."; | MS_LOG(DEBUG) << "Start build model."; | ||||
| if (session_ != nullptr) { | |||||
| MS_LOG(DEBUG) << "Model has been already built."; | |||||
| return kSuccess; | |||||
| } | |||||
| auto model = graph_->graph_data_->lite_model(); | auto model = graph_->graph_data_->lite_model(); | ||||
| if (graph_ == nullptr || graph_->graph_data_ == nullptr || model == nullptr) { | if (graph_ == nullptr || graph_->graph_data_ == nullptr || model == nullptr) { | ||||
| MS_LOG(ERROR) << "Invalid graph."; | MS_LOG(ERROR) << "Invalid graph."; | ||||
| @@ -67,14 +67,14 @@ MSTensor::Impl *MSTensor::Impl::StringsToTensorImpl(const std::string &name, con | |||||
| delete lite_tensor; | delete lite_tensor; | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| auto impl = new (std::nothrow) Impl(); | |||||
| auto impl = new (std::nothrow) Impl(lite_tensor); | |||||
| if (impl == nullptr) { | if (impl == nullptr) { | ||||
| delete lite_tensor; | delete lite_tensor; | ||||
| MS_LOG(ERROR) << "Failed to allocate tensor impl."; | MS_LOG(ERROR) << "Failed to allocate tensor impl."; | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| impl->set_lite_tensor(lite_tensor); | |||||
| impl->set_own_data(true); | impl->set_own_data(true); | ||||
| impl->set_from_session(false); | |||||
| return impl; | return impl; | ||||
| } | } | ||||