/** * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AIR_CXX_INC_FRAMEWORK_RUNTIME_EXE_GRAPH_RESOURCE_GUARD_H_ #define AIR_CXX_INC_FRAMEWORK_RUNTIME_EXE_GRAPH_RESOURCE_GUARD_H_ #include #include #include #include #include "common/ge_visibility.h" namespace gert { class VISIBILITY_EXPORT ResourceGuard { public: void *ResetExecutionData(std::unique_ptr execution_data); void ResetAnyValue(std::unique_ptr any_values, size_t count); void PushNode(void *node); void PushWatcher(void *watcher); void *ResetNodesArray(std::unique_ptr nodes_array); void *ResetStartNodesArray(std::unique_ptr start_nodes_array); void *ResetNodesIndgreeArray(std::unique_ptr nodes_indgree_array); void *ResetNodesWaitIndgreeArray(std::unique_ptr nodes_indgree_array); void *ResetInputsArray(std::unique_ptr inputs_array); void *ResetOutputsArray(std::unique_ptr outputs_array); void *ResetWatchersArray(std::unique_ptr watchers_array); void *ResetReadyQueue(void *ready_queue); void *ResetBuffer(std::unique_ptr buffer); void *ResetComputeNodeInfo(std::unique_ptr compute_node_info); void *ResetKernelExtendInfo(std::unique_ptr kernel_extend_info); void *ResetModelDesc(std::unique_ptr model_desc); ~ResourceGuard(); private: std::unique_ptr execution_data_holder_; size_t any_values_num_; std::unique_ptr any_values_guard_; std::vector> nodes_guarder_; std::vector> watchers_guarder_; std::unique_ptr continuous_buffer_guarder_; std::unique_ptr buffer_guarder_; std::unique_ptr compute_node_info_guarder_; std::unique_ptr kernel_extend_info_guarder_; std::unique_ptr model_desc_guarder_; std::unique_ptr nodes_array_guarder_; std::unique_ptr start_nodes_array_guarder_; std::unique_ptr nodes_indgree_array_guarder_; std::unique_ptr nodes_wait_indgree_array_guarder_; std::unique_ptr inputs_array_guarder_; std::unique_ptr outputs_array_guarder_; std::unique_ptr watchers_array_guarder_; std::unique_ptr ready_queue_guarder_{nullptr, nullptr}; }; } // namespace gert #endif // AIR_CXX_INC_FRAMEWORK_RUNTIME_EXE_GRAPH_RESOURCE_GUARD_H_