* 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_PASSES_COND_REMOVE_PASS_H
#define GE_GRAPH_PASSES_COND_REMOVE_PASS_H
#include "graph/passes/base_pass.h"
namespace ge {
class CondRemovePass : public BaseNodePass {
public:
Status Run(NodePtr &node) override;
static Status GetIfChosenBranch(const NodePtr &node, const uint32_t cond, ComputeGraphPtr &compute_graph);
static Status GetCaseChosenBranch(const NodePtr &node, const uint32_t cond_index, ComputeGraphPtr &compute_graph);
static int32_t GetCondIndex(const GeTensor *tensor);
static Status RemoveDeadCondLink(const int32_t index, const NodePtr &node);
static Status ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, const ComputeGraphPtr &save_branch);
private:
Status GetCondInfoForIfCase(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor,
InDataAnchorPtr &cond_in_anchor) const;
Status GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor,
InDataAnchorPtr &cond_in_anchor);
bool CheckIfCondConstInput(const OutDataAnchorPtr &cond_out_anchor, const InDataAnchorPtr &cond_in_anchor,
int32_t &cond_index) const;
static OpDescPtr CreateSubgraphOpDesc(const NodePtr &node, const std::string &name, size_t input_num,
size_t output_num);
};
}
#endif