已合并
fix clean code #1871
wy519创建于 3月25日
fix clean code #1871
已合并
共 11 个文件变更+20-70
| @@ -477,6 +477,7 @@ conversion@ops-math: | |||
| 477 | src: | 477 | src: |
| 478 | release: | 478 | release: |
| 479 | style: | 479 | style: |
| 480 | + - ops/ops-math/conversion/chunk_cat/ | ||
| 480 | - ops/ops-math/conversion/stack_ball_query/README.md | 481 | - ops/ops-math/conversion/stack_ball_query/README.md |
| 481 | - ops/ops-math/conversion/stack_ball_query/op_kernel/ | 482 | - ops/ops-math/conversion/stack_ball_query/op_kernel/ |
| 482 | - ops/ops-math/conversion/stack_ball_query/op_host/ | 483 | - ops/ops-math/conversion/stack_ball_query/op_host/ |
| @@ -721,6 +722,8 @@ conversion@ops-math: | |||
| 721 | kernel_style: null | 722 | kernel_style: null |
| 722 | unrelease: | 723 | unrelease: |
| 723 | test_code: | 724 | test_code: |
| 725 | + - ops/ops-math/conversion/chunk_cat/examples/ | ||
| 726 | + - ops/ops-math/conversion/chunk_cat/tests/ | ||
| 724 | - ops/ops-math/conversion/stack_ball_query/examples/ | 727 | - ops/ops-math/conversion/stack_ball_query/examples/ |
| 725 | - ops/ops-math/conversion/stack_ball_query/tests/ | 728 | - ops/ops-math/conversion/stack_ball_query/tests/ |
| 726 | - ops/ops-math/conversion/assign/examples/ | 729 | - ops/ops-math/conversion/assign/examples/ |
| @@ -1,6 +1,6 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | # This program is free software, you can redistribute it and/or modify it. | 2 | # This program is free software, you can redistribute it and/or modify it. |
| 3 | -# Copyright (c) 2025 Huawei Technologies Co., Ltd. | 3 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | # This file is a part of the CANN Open Software. | 4 | # This file is a part of the CANN Open Software. |
| 5 | # Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 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. | 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| @@ -1,5 +1,5 @@ | |||
| 1 | /** | 1 | /** |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 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 | 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"). | 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. | 5 | * Please refer to the License for details. You may not use this file except in compliance with the License. |
| @@ -138,15 +138,14 @@ const aclTensor* MergeLastDims(const aclTensor* tensor, int64_t dim, aclOpExecut | |||
| 138 | 138 | ||
| 139 | op::Shape newShape; | 139 | op::Shape newShape; |
| 140 | for (int64_t i = 0; i <= dim; i++) { | 140 | for (int64_t i = 0; i <= dim; i++) { |
| 141 | - newShape.AppendDim((int64_t)shapeTensor.GetDim(i)); | 141 | + newShape.AppendDim(static_cast<int64_t>(shapeTensor.GetDim(i))); |
| 142 | } | 142 | } |
| 143 | int64_t catdimSize = 1; | 143 | int64_t catdimSize = 1; |
| 144 | for (int64_t i = dim + 1; i < dimNum; i++) { | 144 | for (int64_t i = dim + 1; i < dimNum; i++) { |
| 145 | catdimSize *= shapeTensor.GetDim(i); | 145 | catdimSize *= shapeTensor.GetDim(i); |
| 146 | } | 146 | } |
| 147 | newShape.AppendDim(catdimSize); | 147 | newShape.AppendDim(catdimSize); |
| 148 | - auto reshapeTensor = executor == nullptr ? const_cast<aclTensor *>(tensor) | 148 | + auto reshapeTensor = executor->CreateView(tensor, tensor->GetViewShape(), tensor->GetViewOffset()); |
| 149 | - : executor->CreateView(tensor, tensor->GetViewShape(), tensor->GetViewOffset()); | ||
| 150 | reshapeTensor->SetViewShape(newShape); | 149 | reshapeTensor->SetViewShape(newShape); |
| 151 | reshapeTensor->SetOriginalShape(newShape); | 150 | reshapeTensor->SetOriginalShape(newShape); |
| 152 | reshapeTensor->SetStorageShape(newShape); | 151 | reshapeTensor->SetStorageShape(newShape); |
| @@ -234,7 +233,7 @@ aclnnStatus aclnnChunkCatGetWorkspaceSize( | |||
| 234 | return ACLNN_SUCCESS; | 233 | return ACLNN_SUCCESS; |
| 235 | } | 234 | } |
| 236 | 235 | ||
| 237 | -aclnnStatus aclnnChunkCat(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream) | 236 | +aclnnStatus aclnnChunkCat(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream) |
| 238 | { | 237 | { |
| 239 | L2_DFX_PHASE_2(aclnnChunkCat); | 238 | L2_DFX_PHASE_2(aclnnChunkCat); |
| 240 | return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | 239 | return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); |
| @@ -22,7 +22,7 @@ extern "C" { | |||
| 22 | * @domain aclnn_ops_infer | 22 | * @domain aclnn_ops_infer |
| 23 | */ | 23 | */ |
| 24 | ACLNN_API aclnnStatus aclnnChunkCatGetWorkspaceSize( | 24 | ACLNN_API aclnnStatus aclnnChunkCatGetWorkspaceSize( |
| 25 | - const aclTensorList* tensors, int64_t dim, int64_t num_chunks, aclTensor* out, | 25 | + const aclTensorList* tensors, int64_t dim, int64_t numChunks, aclTensor* out, |
| 26 | uint64_t* workspaceSize, aclOpExecutor** executor); | 26 | uint64_t* workspaceSize, aclOpExecutor** executor); |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| @@ -1,5 +1,5 @@ | |||
| 1 | /** | 1 | /** |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 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 | 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"). | 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. | 5 | * Please refer to the License for details. You may not use this file except in compliance with the License. |
| @@ -32,11 +32,14 @@ static ge::graphStatus InferShape4ChunkCat(gert::InferShapeContext* context) | |||
| 32 | OP_CHECK_NULL_WITH_CONTEXT(context, attrs); | 32 | OP_CHECK_NULL_WITH_CONTEXT(context, attrs); |
| 33 | const int64_t dim = *attrs->GetAttrPointer<int64_t>(0); | 33 | const int64_t dim = *attrs->GetAttrPointer<int64_t>(0); |
| 34 | const int64_t numChunks = *attrs->GetAttrPointer<int64_t>(1); | 34 | const int64_t numChunks = *attrs->GetAttrPointer<int64_t>(1); |
| 35 | + OP_CHECK_IF(dim != 0, | ||
| 36 | + OP_LOGE(context->GetNodeName(), "dim only support 0 now"), | ||
| 37 | + return ge::GRAPH_FAILED); | ||
| 35 | 38 | ||
| 36 | - auto out_shape = context->GetOutputShape(0); | 39 | + auto outShape = context->GetOutputShape(0); |
| 37 | - OP_CHECK_NULL_WITH_CONTEXT(context, out_shape); | 40 | + OP_CHECK_NULL_WITH_CONTEXT(context, outShape); |
| 38 | - out_shape->SetDimNum(dim + 2); // 2是由于输出的维度在dim维后所有维度合维 | 41 | + outShape->SetDimNum(dim + 2); // 2是由于输出的维度在dim维后所有维度合维 |
| 39 | - out_shape->SetDim(dim, numChunks); | 42 | + outShape->SetDim(dim, numChunks); |
| 40 | 43 | ||
| 41 | int64_t outputCol = 0; | 44 | int64_t outputCol = 0; |
| 42 | for (uint32_t i = 0; i < inputNum; i++) { | 45 | for (uint32_t i = 0; i < inputNum; i++) { |
| @@ -48,14 +51,14 @@ static ge::graphStatus InferShape4ChunkCat(gert::InferShapeContext* context) | |||
| 48 | int64_t dim1Size = chunkCol; | 51 | int64_t dim1Size = chunkCol; |
| 49 | int64_t inputTensorDimNum = inputTensorShape->GetDimNum(); | 52 | int64_t inputTensorDimNum = inputTensorShape->GetDimNum(); |
| 50 | for (int64_t j = 0; j < dim; j++) { | 53 | for (int64_t j = 0; j < dim; j++) { |
| 51 | - out_shape->SetDim(j, inputTensorShape->GetDim(j)); | 54 | + outShape->SetDim(j, inputTensorShape->GetDim(j)); |
| 52 | } | 55 | } |
| 53 | for (int64_t j = dim + 1; j < inputTensorDimNum; j++) { | 56 | for (int64_t j = dim + 1; j < inputTensorDimNum; j++) { |
| 54 | dim1Size *= inputTensorShape->GetDim(j); | 57 | dim1Size *= inputTensorShape->GetDim(j); |
| 55 | } | 58 | } |
| 56 | outputCol += dim1Size; | 59 | outputCol += dim1Size; |
| 57 | } | 60 | } |
| 58 | - out_shape->SetDim(dim + 1, outputCol); | 61 | + outShape->SetDim(dim + 1, outputCol); |
| 59 | 62 | ||
| 60 | return ge::GRAPH_SUCCESS; | 63 | return ge::GRAPH_SUCCESS; |
| 61 | } | 64 | } |
Dconversion/chunk_cat/tests/CMakeLists.txt+0-17
| @@ -1,17 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify it. | ||
| 3 | -# Copyright (c) 2025 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 | ||
| 8 | -# BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | -# ---------------------------------------------------------------------------- | ||
| 11 | - | ||
| 12 | -file(GLOB CURRENT_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 13 | -foreach(SUB_DIR ${CURRENT_DIRS}) | ||
| 14 | - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/CMakeLists.txt") | ||
| 15 | - add_subdirectory(${SUB_DIR}) | ||
| 16 | - endif() | ||
| 17 | -endforeach() | ||
Dconversion/chunk_cat/tests/ut/CMakeLists.txt+0-17
| @@ -1,17 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify it. | ||
| 3 | -# Copyright (c) 2025 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 | ||
| 8 | -# BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | -# ---------------------------------------------------------------------------- | ||
| 11 | - | ||
| 12 | -file(GLOB CURRENT_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 13 | -foreach(SUB_DIR ${CURRENT_DIRS}) | ||
| 14 | - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/CMakeLists.txt") | ||
| 15 | - add_subdirectory(${SUB_DIR}) | ||
| 16 | - endif() | ||
| 17 | -endforeach() | ||
Dconversion/chunk_cat/tests/ut/op_host/CMakeLists.txt+0-21
| @@ -1,21 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify it. | ||
| 3 | -# Copyright (c) 2025 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 | ||
| 8 | -# BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | -# ---------------------------------------------------------------------------- | ||
| 11 | - | ||
| 12 | -if(UT_TEST_ALL OR OP_HOST_UT) | ||
| 13 | - add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 14 | -endif() | ||
| 15 | - | ||
| 16 | -file(GLOB CURRENT_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 17 | -foreach(SUB_DIR ${CURRENT_DIRS}) | ||
| 18 | - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/CMakeLists.txt") | ||
| 19 | - add_subdirectory(${SUB_DIR}) | ||
| 20 | - endif() | ||
| 21 | -endforeach() | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | # This program is free software, you can redistribute it and/or modify it. | 2 | # This program is free software, you can redistribute it and/or modify it. |
| 3 | -# Copyright (c) 2025 Huawei Technologies Co., Ltd. | 3 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | # This file is a part of the CANN Open Software. | 4 | # This file is a part of the CANN Open Software. |
| 5 | # Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 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. | 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. |