* 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.
*/
* \file reschedule_utils.h
* \brief
*/
#ifndef RESCHEDULE_UTILS_H_
#define RESCHEDULE_UTILS_H_
#include "interface/function/function.h"
#include "interface/tensor/logical_tensor.h"
namespace npu::tile_fwk {
class RescheduleUtils {
public:
static bool isAllocOp(Operation* op);
static std::vector<std::vector<std::vector<int>>> GetInOutGraphs(
const std::vector<Operation*>& opList, int functionmagic = -1);
static void GetInOutGraphs(
const std::vector<Operation*>& opList, std::vector<std::vector<int>>& inGraph,
std::vector<std::vector<int>>& outGraph, bool hasCtrlEdge = true);
static void GetInOutGraphs(
const std::vector<Operation*>& opList, std::unordered_map<Operation*, std::vector<Operation*>>& inGraph,
std::unordered_map<Operation*, std::vector<Operation*>>& outGraph, bool hasCtrlEdge = true);
static void GetInOutGraphs(
const std::vector<Operation*>& opList, std::vector<std::vector<int>>& inGraph,
std::vector<std::vector<int>>& outGraph, int subGraphId, bool hasCtrlEdge = true);
static void GetInOutGraphs(
const std::vector<Operation*>& opList, std::unordered_map<Operation*, std::vector<Operation*>>& inGraph,
std::unordered_map<Operation*, std::vector<Operation*>>& outGraph, int subGraphId, bool hasCtrlEdge = true);
static PipeType GetOpPipeType(const Operation* op);
static unsigned long ComputeOperationHash(const Operation* op);
static void UpdateTensorConsProd(Function* funcPtr);
static void ClearInputConsProd(
Operation& op, Function* funcPtr, const std::unordered_set<LogicalTensorPtr>& incastSet);
static void ClearOutputConsProd(
Operation& op, Function* funcPtr, const std::unordered_set<LogicalTensorPtr>& outcastSet);
static void EraseOpsBelongToFunc(std::set<Operation*, LogicalTensor::CompareOp>& ops, Function* funcPtr);
static void PrintColorNode(Function& func);
};
}
#endif