1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "minddata/dataset/engine/runtime_context.h" 18 namespace mindspore::dataset { AssignConsumer(std::shared_ptr<TreeConsumer> tree_consumer)19void RuntimeContext::AssignConsumer(std::shared_ptr<TreeConsumer> tree_consumer) { 20 tree_consumer_ = std::move(tree_consumer); 21 } Terminate()22Status NativeRuntimeContext::Terminate() { 23 MS_LOG(INFO) << "Terminating a Dataset NativeRuntime."; 24 if (tree_consumer_ != nullptr) { 25 return TerminateImpl(); 26 } 27 MS_LOG(WARNING) << "Dataset TreeConsumer was not initialized."; 28 return Status::OK(); 29 } 30 TerminateImpl()31Status NativeRuntimeContext::TerminateImpl() { 32 CHECK_FAIL_RETURN_UNEXPECTED(tree_consumer_ != nullptr, "Dataset TreeConsumer is not initialized."); 33 return tree_consumer_->Terminate(); 34 } 35 ~NativeRuntimeContext()36NativeRuntimeContext::~NativeRuntimeContext() { 37 Status rc = NativeRuntimeContext::Terminate(); 38 if (rc.IsError()) MS_LOG(ERROR) << "Error while terminating the consumer. Message:" << rc; 39 } 40 GetConsumer()41TreeConsumer *RuntimeContext::GetConsumer() { return tree_consumer_.get(); } 42 Init() const43Status RuntimeContext::Init() const { return GlobalInit(); } 44 } // namespace mindspore::dataset 45