* 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 INC_FRAMEWORK_COMMON_OP_GE_OP_UTILS_H_
#define INC_FRAMEWORK_COMMON_OP_GE_OP_UTILS_H_
#include <memory>
#include <vector>
#include "graph/debug/ge_attr_define.h"
#include "framework/common/util.h"
#include "graph/attr_value.h"
#include "graph/ge_tensor.h"
#include "graph/node.h"
#include "graph/op_desc.h"
#include "proto/insert_op.pb.h"
namespace ge {
extern GE_FUNC_VISIBILITY const uint32_t ADD_INPUT_NUM;
extern GE_FUNC_VISIBILITY const uint32_t MUL_INPUT_NUM;
extern GE_FUNC_VISIBILITY const int32_t PERMUTE_ORDER_NUM;
extern GE_FUNC_VISIBILITY const float64_t SSD_PRIORBOX_ASPECT_RATIO_VALUE;
extern GE_FUNC_VISIBILITY const uint32_t STRIDEDSLICE_INPUT_NUM;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_INPUT_NUM;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_OUTPUT_NUM;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_FALSE_OUTPUT;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_TRUE_OUTPUT;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_DATA_INPUT;
extern GE_FUNC_VISIBILITY const uint32_t SWITCH_PRED_INPUT;
extern GE_FUNC_VISIBILITY const int32_t MERGE_DATA_OUTPUT;
extern GE_FUNC_VISIBILITY const int32_t MERGE_INDEX_OUTPUT;
extern GE_FUNC_VISIBILITY const uint32_t IF_COND_INPUT;
extern GE_FUNC_VISIBILITY const uint32_t FOR_START_INPUT;
extern GE_FUNC_VISIBILITY const uint32_t FOR_LIMIT_INPUT;
extern GE_FUNC_VISIBILITY const uint32_t FOR_DELTA_INPUT;
extern GE_FUNC_VISIBILITY const uint32_t FOR_DATA_INPUT;
extern GE_FUNC_VISIBILITY const int32_t NORMAL_TENSOR_SIZE;
class GE_FUNC_VISIBILITY OpUtils {
public:
static Status ConvertAippParams(const GeAttrValue::NamedAttrs &aipp_attr,
domi::AippOpParams &aipp_params);
template <typename T>
static void SliceData(const std::vector<char_t *> &input, const int64_t chunk_size, std::vector<char_t *> &output,
const int64_t begin, const int64_t out_dim, const int64_t stride);
template <typename T>
static Status SetDataByDataType(const size_t out_size, const std::vector<char_t *> &chunk_input,
const std::vector<char_t *> &chunk_output, GeTensor *const output);
template <typename T>
static Status SetOutputSliceDataByDataType(void *const data, const int64_t data_size,
const std::vector<int64_t> &input_dims,
const std::vector<int64_t> &begin,
const std::vector<int64_t> &output_dims,
ge::GeTensor *const output, const std::vector<int64_t> &stride);
static Status SetOutputSliceData(void *const data, const int64_t data_size, const int32_t data_type,
const std::vector<int64_t> &input_dims, const std::vector<int64_t> &begin,
const std::vector<int64_t> &output_dims, GeTensor *const output,
const std::vector<int64_t> &stride);
static Status GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, const DataType type,
std::vector<int64_t> &dims);
static bool IsHcomNodeNotSupportAddrRefresh(const OpDescPtr &op_desc);
static Status GetConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size);
};
}
#endif