diff --git a/.clang-format b/.clang-format index 27412d05cc8cfa828fc413b6c9aed5433f821007..f32f4f013bb6c3394fb6eae1e6b53d020f2d1963 100644 --- a/.clang-format +++ b/.clang-format @@ -69,12 +69,12 @@ IndentCaseBlocks: false IndentCaseLabels: true IndentExternBlock: AfterExternBlock IndentGotoLabels: false -IndentPPDirectives: BeforeHash +IndentPPDirectives: None IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 2 -NamespaceIndentation: Inner +NamespaceIndentation: None PointerAlignment: Left ReflowComments: false SortIncludes: CaseSensitive @@ -97,4 +97,4 @@ SpacesInConditionalStatement: false SpacesInParentheses: false SpacesInSquareBrackets: false TabWidth: 4 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/cmake/intf.cmake b/cmake/intf.cmake index d24ce1444279053ff691e5fe4d792a3f5382dc49..eaabdcd5550f0d441600fa92d60c5760636a9698 100644 --- a/cmake/intf.cmake +++ b/cmake/intf.cmake @@ -22,18 +22,22 @@ target_compile_options( target_compile_definitions( intf_pub INTERFACE _GLIBCXX_USE_CXX11_ABI=0 $<$:_FORTIFY_SOURCE=2>) -target_include_directories(intf_pub - INTERFACE ${ASCEND_CANN_PACKAGE_PATH}/include) -## if the CANN_PATHS not empty +target_include_directories( + intf_pub INTERFACE ${ASCEND_CANN_PACKAGE_PATH}/include + ${PROJECT_SOURCE_DIR}/include) +# if the CANN_PATHS not empty if(CANN_PATHS) - ## if the arch is aarch64, add the include path - if(${ARCH} STREQUAL "aarch64") - target_include_directories(intf_pub INTERFACE ${CANN_PATHS}/aarch64-linux/include) - target_link_directories(intf_pub INTERFACE ${CANN_PATHS}/aarch64-linux/lib64) - else () - target_include_directories(intf_pub INTERFACE ${CANN_PATHS}/x86_64-linux/include) - target_link_directories(intf_pub INTERFACE ${CANN_PATHS}/x86_64-linux/lib64) - endif() + # if the arch is aarch64, add the include path + if(${ARCH} STREQUAL "aarch64") + target_include_directories(intf_pub + INTERFACE ${CANN_PATHS}/aarch64-linux/include) + target_link_directories(intf_pub INTERFACE + ${CANN_PATHS}/aarch64-linux/lib64) + else() + target_include_directories(intf_pub + INTERFACE ${CANN_PATHS}/x86_64-linux/include) + target_link_directories(intf_pub INTERFACE ${CANN_PATHS}/x86_64-linux/lib64) + endif() endif() target_link_options( diff --git a/cmake/stage_0.cmake b/cmake/stage_0.cmake index 426e801535c1519ca1619ebb0e33eddaa5ea3c74..edac7db17d85196fef6851eca2e120e161e8b0eb 100644 --- a/cmake/stage_0.cmake +++ b/cmake/stage_0.cmake @@ -3,7 +3,7 @@ target_compile_options(ascend_all_ops PRIVATE -g -fPIC -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0) target_include_directories(ascend_all_ops PRIVATE ${CANN_INCLUDE_PATH}) target_link_libraries(ascend_all_ops PRIVATE intf_pub exe_graph register - tiling_api) + tiling_api ascendcl) add_custom_command( TARGET ascend_all_ops POST_BUILD diff --git a/cmake/stage_1.cmake b/cmake/stage_1.cmake index 9a176248ee4a05dd1f751c60e4413ed43188ab18..502263afe6c29b90cde3bc42c2a988bdc6a866d8 100644 --- a/cmake/stage_1.cmake +++ b/cmake/stage_1.cmake @@ -8,6 +8,7 @@ target_link_libraries( exe_graph register tiling_api + ascendcl -Wl,--whole-archive rt2_registry -Wl,--no-whole-archive) @@ -27,6 +28,7 @@ target_link_libraries( exe_graph register tiling_api + ascendcl -Wl,--whole-archive rt2_registry -Wl,--no-whole-archive) diff --git a/include/log/log.h b/include/log/log.h new file mode 100644 index 0000000000000000000000000000000000000000..28ea5675270c4b6d873abd942c59bc662cd78ab2 --- /dev/null +++ b/include/log/log.h @@ -0,0 +1,62 @@ +// Copyright (c) 2024 Huawei Technologies Co., Ltd +// All rights reserved. +// +// Licensed under the BSD 3-Clause License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once + +#ifndef LOG_LOG_H_ +#define LOG_LOG_H_ + +#include +#include + +namespace mx_driving { +namespace log { + +inline bool IsACLGlobalLogOn(aclLogLevel level) +{ + const static int getACLGlobalLogLevel = []() -> int { + char* env_val = std::getenv("ASCEND_GLOBAL_LOG_LEVEL"); + int64_t envFlag = (env_val != nullptr) ? strtol(env_val, nullptr, 10) : ACL_ERROR; + return static_cast(envFlag); + }(); + return (getACLGlobalLogLevel <= level); +} +} // namespace log +} // namespace mx_driving + +#define MX_DRIVING_LOGE(fmt, ...) \ + do { \ + if (mx_driving::log::IsACLGlobalLogOn(ACL_ERROR)) { \ + aclAppLog(ACL_ERROR, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ + } \ + } while (0); +#define MX_DRIVING_LOGW(fmt, ...) \ + do { \ + if (mx_driving::log::IsACLGlobalLogOn(ACL_WARNING)) { \ + aclAppLog(ACL_WARNING, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ + } \ + } while (0); +#define MX_DRIVING_LOGI(fmt, ...) \ + do { \ + if (mx_driving::log::IsACLGlobalLogOn(ACL_INFO)) { \ + aclAppLog(ACL_INFO, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ + } \ + } while (0); +#define MX_DRIVING_LOGD(fmt, ...) \ + do { \ + if (mx_driving::log::IsACLGlobalLogOn(ACL_DEBUG)) { \ + aclAppLog(ACL_DEBUG, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ + } \ + } while (0); +#endif // LOG_LOG_H_ diff --git a/mx_driving/fused/ops/kernels/op_host/multi_scale_deformable_attn.cpp b/mx_driving/fused/ops/kernels/op_host/multi_scale_deformable_attn.cpp index 4fa91a6951b36e145e0673b110b5f9447dfef49e..a2a7234af8c47f1ae6ae60cbab439a1ee013ba2e 100644 --- a/mx_driving/fused/ops/kernels/op_host/multi_scale_deformable_attn.cpp +++ b/mx_driving/fused/ops/kernels/op_host/multi_scale_deformable_attn.cpp @@ -3,6 +3,7 @@ */ #include +#include "log/log.h" #include "multi_scale_deformable_attn_tiling.h" #include "register/op_def_registry.h" #include "tiling/platform/platform_ascendc.h" @@ -89,6 +90,11 @@ static ge::graphStatus TilingFuncForMultiScaleDeformableAttn(gert::TilingContext tiling.set_coreNum(coreNum); tiling.set_pointLoops(pointLoops); tiling.set_realLevels(attnWeightShape.GetDim(REAL_LEVEL_DIM)); + MX_DRIVING_LOGI( + "MultiScaleDeformableAttn's tiling: batchSize=%d, numKeys=%d, numHeads=%d, embedDims=%d, numLevels=%d,numQueries=%d, numPoints=%d, coreNum=%d, pointLoops=%d,realLevels=%d", + tiling.get_batchSize(), tiling.get_numKeys(), tiling.get_numHeads(), tiling.get_embedDims(), + tiling.get_numLevels(), tiling.get_numQueries(), tiling.get_numPoints(), tiling.get_coreNum(), + tiling.get_pointLoops(), tiling.get_realLevels()); tiling.SaveToBuffer(context->GetRawTilingData()->GetData(), context->GetRawTilingData()->GetCapacity()); context->GetRawTilingData()->SetDataSize(tiling.GetDataSize());