已合并
refactor: 隔离 ops-ras 重复头文件路径 #89
LiuZonggu创建于 8月29日
refactor: 隔离 ops-ras 重复头文件路径 #89
已合并
从已删除 :fix/remove-duplicate-headers合入到cann/ops-rasmaster
共 7 个文件变更+3-637
| @@ -48,7 +48,6 @@ ras@ops-ras: | |||
| 48 | - ops/ops-ras/tests/ | 48 | - ops/ops-ras/tests/ |
| 49 | - ops/ops-ras/build.sh | 49 | - ops/ops-ras/build.sh |
| 50 | - ops/ops-ras/CMakeLists.txt | 50 | - ops/ops-ras/CMakeLists.txt |
| 51 | - - ops/ops-ras/common/inc/op_api/level2_base.h | ||
| 52 | non_delivery: null | 51 | non_delivery: null |
| 53 | open_source: null | 52 | open_source: null |
| 54 | 53 | ||
| @@ -153,6 +153,9 @@ set(OPAPI_INCLUDE | |||
| 153 | ${JSON_INCLUDE} | 153 | ${JSON_INCLUDE} |
| 154 | ${OPS_RAS_DIR} | 154 | ${OPS_RAS_DIR} |
| 155 | ${AICPU_INC_DIRS} | 155 | ${AICPU_INC_DIRS} |
| 156 | + ${OPS_RAS_DIR}/common/include | ||
| 157 | + ${OPS_RAS_DIR}/common/include/external/ras | ||
| 158 | + ${OPS_RAS_DIR}/common/include/static/ras | ||
| 156 | ${OPS_RAS_DIR}/common/inc | 159 | ${OPS_RAS_DIR}/common/inc |
| 157 | ${OPS_RAS_DIR}/common/inc/op_api | 160 | ${OPS_RAS_DIR}/common/inc/op_api |
| 158 | ${TOP_DIR}/output/${PRODUCT}/aclnnop_resource | 161 | ${TOP_DIR}/output/${PRODUCT}/aclnnop_resource |
| @@ -1,86 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | -/*! | ||
| 12 | - * \file onnx_common.h | ||
| 13 | - * \brief | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | -#ifndef MATH_COMMON_ONNX_COMMON_H | ||
| 17 | -#define MATH_COMMON_ONNX_COMMON_H | ||
| 18 | - | ||
| 19 | -#include <string> | ||
| 20 | -#include <vector> | ||
| 21 | -#include <map> | ||
| 22 | - | ||
| 23 | -#include "stub_ops.h" | ||
| 24 | -#include "register/register.h" | ||
| 25 | -#include "graph/operator.h" | ||
| 26 | -#include "graph/graph.h" | ||
| 27 | -#include "base/err_msg.h" | ||
| 28 | -#include "log/log.h" | ||
| 29 | -#include "onnx/proto/ge_onnx.pb.h" | ||
| 30 | - | ||
| 31 | -namespace domi { | ||
| 32 | -template <typename T> | ||
| 33 | -inline std::string GetOpName(const T& op) | ||
| 34 | -{ | ||
| 35 | - ge::AscendString op_ascend_name; | ||
| 36 | - ge::graphStatus ret = op.GetName(op_ascend_name); | ||
| 37 | - if (ret != ge::GRAPH_SUCCESS) { | ||
| 38 | - std::string op_name = "None"; | ||
| 39 | - return op_name; | ||
| 40 | - } | ||
| 41 | - return op_ascend_name.GetString(); | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -template<typename T> | ||
| 45 | -inline ge::Tensor Vec2Tensor(vector<T>& vals, const vector<int64_t>& dims, ge::DataType dtype, ge::Format format = ge::FORMAT_ND) { | ||
| 46 | - ge::Shape shape(dims); | ||
| 47 | - ge::TensorDesc desc(shape, format, dtype); | ||
| 48 | - ge::Tensor tensor(desc, reinterpret_cast<uint8_t*>(vals.data()), vals.size() * sizeof(T)); | ||
| 49 | - return tensor; | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | -template<typename T> | ||
| 53 | -inline ge::Tensor CreateScalar(T val, ge::DataType dtype, ge::Format format = ge::FORMAT_ND) { | ||
| 54 | - vector<int64_t> dims_scalar = {}; | ||
| 55 | - ge::Shape shape(dims_scalar); | ||
| 56 | - ge::TensorDesc desc(shape, format, dtype); | ||
| 57 | - ge::Tensor tensor(desc, reinterpret_cast<uint8_t*>(&val), sizeof(T)); | ||
| 58 | - return tensor; | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -inline Status ChangeFormatFromOnnx(ge::Operator& op, const int idx, ge::Format format, bool is_input) { | ||
| 62 | - if (is_input) { | ||
| 63 | - ge::TensorDesc org_tensor = op.GetInputDesc(idx); | ||
| 64 | - org_tensor.SetOriginFormat(format); | ||
| 65 | - org_tensor.SetFormat(format); | ||
| 66 | - auto ret = op.UpdateInputDesc(idx, org_tensor); | ||
| 67 | - if (ret != ge::GRAPH_SUCCESS) { | ||
| 68 | - OP_LOGE(GetOpName(op).c_str(), "change input format failed."); | ||
| 69 | - return FAILED; | ||
| 70 | - } | ||
| 71 | - } else { | ||
| 72 | - ge::TensorDesc org_tensor_y = op.GetOutputDesc(idx); | ||
| 73 | - org_tensor_y.SetOriginFormat(format); | ||
| 74 | - org_tensor_y.SetFormat(format); | ||
| 75 | - auto ret_y = op.UpdateOutputDesc(idx, org_tensor_y); | ||
| 76 | - if (ret_y != ge::GRAPH_SUCCESS) { | ||
| 77 | - OP_LOGE(GetOpName(op).c_str(), "change output format failed."); | ||
| 78 | - return FAILED; | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - return SUCCESS; | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -} // namespace domi | ||
| 85 | - | ||
| 86 | -#endif // MATH_COMMON_ONNX_COMMON_H | ||
| @@ -1,525 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This program is free software, you can redistribute it and/or modify. | ||
| 3 | - * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | - * This file is a part of the CANN Open Software. | ||
| 5 | - * Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | - * 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. | ||
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | -#ifndef LEVEL2_BASE_H_ | ||
| 12 | -#define LEVEL2_BASE_H_ | ||
| 13 | - | ||
| 14 | -#include <algorithm> | ||
| 15 | -#include "op_api/op_api_def.h" | ||
| 16 | -#include "op_api/aclnn_util.h" | ||
| 17 | -#include "aclnn/aclnn_base.h" | ||
| 18 | -#include "opdev/platform.h" | ||
| 19 | -#include "opdev/common_types.h" | ||
| 20 | -#include "opdev/fast_vector.h" | ||
| 21 | - | ||
| 22 | -#ifdef __cplusplus | ||
| 23 | -extern "C" { | ||
| 24 | -#endif | ||
| 25 | - | ||
| 26 | -namespace op { | ||
| 27 | - | ||
| 28 | -// 根据API定义,需要列出所能支持的所有dtype | ||
| 29 | -static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LISTS = { | ||
| 30 | - op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_DOUBLE, op::DataType::DT_BF16}; | ||
| 31 | -static const int64_t UPSAMPLE_EXPECT_SIZE = 3; | ||
| 32 | -static const int64_t UPSAMPLE_DIM_LIMIT = 5; | ||
| 33 | -static constexpr size_t DIM_ZERO = 0; | ||
| 34 | -static constexpr size_t DIM_ONE = 1; | ||
| 35 | -static constexpr size_t DIM_TWO = 2; | ||
| 36 | -static constexpr size_t DIM_THREE = 3; | ||
| 37 | -static constexpr size_t DIM_FOUR = 4; | ||
| 38 | - | ||
| 39 | -// 检查1个输入和1个输出是否是空指针 | ||
| 40 | -inline static bool CheckNotNull2Tensor(const aclTensor* t0, const aclTensor* t1) | ||
| 41 | -{ | ||
| 42 | - OP_CHECK_NULL(t0, return false); | ||
| 43 | - OP_CHECK_NULL(t1, return false); | ||
| 44 | - | ||
| 45 | - return true; | ||
| 46 | -} | ||
| 47 | -inline static bool CheckNotNull3Tensor(const aclTensor* t0, const aclTensor* t1, const aclTensor* t2) | ||
| 48 | -{ | ||
| 49 | - // 检查输入是否是空指针 | ||
| 50 | - OP_CHECK_NULL(t0, return false); | ||
| 51 | - OP_CHECK_NULL(t1, return false); | ||
| 52 | - // 检查输入是否是空指针 | ||
| 53 | - OP_CHECK_NULL(t2, return false); | ||
| 54 | - | ||
| 55 | - return true; | ||
| 56 | -} | ||
| 57 | -// 检查3个输入和1个输出是否是空指针 | ||
| 58 | -inline static bool CheckNotNull4Tensor(const aclTensor* t0, const aclTensor* t1, const aclTensor* t2, const aclTensor* t3) | ||
| 59 | -{ | ||
| 60 | - // 检查输入是否是空指针 | ||
| 61 | - OP_CHECK_NULL(t0, return false); | ||
| 62 | - OP_CHECK_NULL(t1, return false); | ||
| 63 | - OP_CHECK_NULL(t2, return false); | ||
| 64 | - // 检查输入是否是空指针 | ||
| 65 | - OP_CHECK_NULL(t3, return false); | ||
| 66 | - | ||
| 67 | - return true; | ||
| 68 | -} | ||
| 69 | - | ||
| 70 | -inline static bool CheckNotNull2In1Out( | ||
| 71 | - const aclTensor* gradOutput, const aclTensor* input, const aclTensor* grid, const aclTensor* inputGrad, | ||
| 72 | - const aclTensor* gridGrad) | ||
| 73 | -{ | ||
| 74 | - OP_CHECK_NULL(gradOutput, return false); | ||
| 75 | - OP_CHECK_NULL(input, return false); | ||
| 76 | - OP_CHECK_NULL(grid, return false); | ||
| 77 | - OP_CHECK_NULL(inputGrad, return false); | ||
| 78 | - OP_CHECK_NULL(gridGrad, return false); | ||
| 79 | - return true; | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | -inline static bool CheckNotNull2In2Out( | ||
| 83 | - const aclTensor* gradOut, const aclIntArray* outputSize, const aclIntArray* inputSize, const aclTensor* gradInput) | ||
| 84 | -{ | ||
| 85 | - OP_CHECK_NULL(gradOut, return false); | ||
| 86 | - OP_CHECK_NULL(outputSize, return false); | ||
| 87 | - OP_CHECK_NULL(inputSize, return false); | ||
| 88 | - OP_CHECK_NULL(gradInput, return false); | ||
| 89 | - return true; | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -/** | ||
| 93 | - * 1. 1个输入1个输出 | ||
| 94 | - * 2. 输入输出的shape必须一致 | ||
| 95 | - * 3. 输入的维度必须小于等于8 | ||
| 96 | - */ | ||
| 97 | -inline static bool CheckSameShape1In1Out(const aclTensor* self, const aclTensor* out) | ||
| 98 | -{ | ||
| 99 | - // self和out的shape必须一致 | ||
| 100 | - OP_CHECK_SHAPE_NOT_EQUAL(self, out, return false); | ||
| @@ -1,25 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This program is free software, you can redistribute it and/or modify. | ||
| 3 | - * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | - * This file is a part of the CANN Open Software. | ||
| 5 | - * Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | - * 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. | ||
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | -#ifndef OP_API_DEF_H_ | ||
| 12 | -#define OP_API_DEF_H_ | ||
| 13 | - | ||
| 14 | -namespace op { | ||
| 15 | - constexpr size_t BN_MIN_SUPPORT_DIMS_NUMS = 2; | ||
| 16 | - constexpr size_t MAX_SUPPORT_DIMS_NUMS = 8; | ||
| 17 | - constexpr int8_t FP16FP32_KEEP_DTYPE = -1; | ||
| 18 | - constexpr int8_t KEEP_DTYPE = 0; | ||
| 19 | - constexpr int8_t ALLOW_FP32_DOWN_PRECISION = 1; | ||
| 20 | - constexpr int8_t USE_FP16 = 2; | ||
| 21 | - constexpr int8_t USE_HF32 = 3; | ||
| 22 | - constexpr int8_t USE_FP32_ADD = 4; | ||
| 23 | - constexpr size_t MAX_MASK_LEN64 = 64; | ||
| 24 | -} // namespace op | ||
| 25 | -#endif // OP_API_DEF_H_ | ||