* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef GE_GRAPH_MANAGER_UTIL_GRAPH_REBUILD_STATE_CTRL_H_
#define GE_GRAPH_MANAGER_UTIL_GRAPH_REBUILD_STATE_CTRL_H_
#include <map>
#include <set>
#include <string>
#include <mutex>
#include "graph/compute_graph.h"
#include "graph/gnode.h"
namespace ge {
class GraphRebuildStateCtrl {
public:
void AddGraph(uint32_t graph_id, const ComputeGraphPtr &compute_graph);
void RemoveGraph(uint32_t graph_id);
bool IsGraphNeedRebuild(uint32_t graph_id) const;
void SetGraphBuildEnd(uint32_t graph_id);
void SetStateChanged(const std::string &resource_name);
void AddResourceName(uint32_t graph_id, const std::string &resource_name);
bool IsVarPermitToChangeFormats(const std::string &var_name);
private:
std::set<uint32_t> graph_ids_need_rebuild_;
std::map<uint32_t, std::set<std::string>> graph_ids_to_resource_names_;
std::map<std::string, int32_t> resource_names_to_change_times_;
static const int32_t kMaxVarChangeTimes_ = 1;
mutable std::mutex mutex_;
};
}
#endif