Skip to content

Commit e419d24

Browse files
author
zhangyue
committed
style(ascend): reformat CMake comments + restore Gemm/MatMul backticks in common.h
- `src/ascend/custom/cmake/config_envs.cmake`: capitalize + period + Markdown backticks on all comments and status messages. - `src/ascend/custom/cmake/config_ascend.cmake`: fix `CANN` casing and backticks in the fatal-error message. - `src/ascend/custom/CMakeLists.txt`: polish status messages and inline comments (Markdown backticks + sentence case). - `src/ascend/common.h`: restore `Gemm` and `MatMul` backticks in the `BuildAclTensor` docstring per PR #64 review.
1 parent 1cef027 commit e419d24

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/ascend/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ inline bool IsAclRuntimeAlive() {
2626
// Build an `aclTensor` descriptor from an InfiniOps `Tensor`.
2727
//
2828
// When `transpose_last2` is true the last two dimensions are swapped in the
29-
// descriptor (shape and strides) without copying data. This is used by GEMM
30-
// and Matmul to express a transpose via the view.
29+
// descriptor (shape and strides) without copying data. This is used by `Gemm`
30+
// and `MatMul` to express a transpose via the view.
3131
inline aclTensor* BuildAclTensor(const Tensor& t,
3232
bool transpose_last2 = false) {
3333
std::vector<int64_t> shape(t.shape().begin(), t.shape().end());

src/ascend/custom/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ add_compile_options(-Wunused-value -Wcast-align -Wcast-qual -Wwrite-strings
2424
if(${CMAKE_BUILD_TYPE} MATCHES "RELEASE")
2525
add_compile_options(-O3 -fvisibility=hidden -fvisibility-inlines-hidden
2626
-fstack-protector-strong -fPIE -fPIC)
27-
message(STATUS "build type set to RELEASE")
27+
message(STATUS "Build type set to `RELEASE`.")
2828
else()
2929
add_compile_options(-g -rdynamic)
3030
endif()
@@ -38,15 +38,15 @@ include(cmake/config_ascend.cmake)
3838

3939
find_program(CCACHE_PROGRAM ccache)
4040
if(CCACHE_PROGRAM)
41-
message(STATUS "Found ccache: ${CCACHE_PROGRAM}")
41+
message(STATUS "Found `ccache`: ${CCACHE_PROGRAM}.")
4242
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
4343
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
4444
endif()
4545

4646
# Shared library output location.
4747
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_PATH})
4848

49-
# Host side files.
49+
# Host-side files.
5050
file(GLOB OP_SRCS
5151
${PROJECT_OP_SRC_BASE}/torch_binding.cpp
5252
${PROJECT_OP_SRC_BASE}/rms_norm/op_host/rms_norm.cpp
@@ -56,12 +56,12 @@ file(GLOB OP_SRCS
5656
# Python side via `import ascend_kernel`.
5757
set(OP_PLUGIN_NAME ascend_kernel)
5858

59-
# Kernel side files (device code compiled by `AscendC` toolchain).
59+
# Kernel-side files (device code compiled by the `AscendC` toolchain).
6060
ascendc_library(no_workspace_kernel STATIC
6161
${PROJECT_OP_SRC_BASE}/rms_norm/op_kernel/rms_norm.cpp
6262
)
6363

64-
# Create shared library libascend_kernel.so.
64+
# Create the shared library `libascend_kernel.so`.
6565
add_library(${OP_PLUGIN_NAME} SHARED ${OP_SRCS})
6666

6767
target_link_libraries(${OP_PLUGIN_NAME} PRIVATE

src/ascend/custom/cmake/config_ascend.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ elseif(EXISTS ${ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake)
3030
elseif(EXISTS ${ASCEND_HOME_PATH}/ascendc_devkit/tikcpp/samples/cmake)
3131
set(ASCENDC_CMAKE_DIR ${ASCEND_HOME_PATH}/ascendc_devkit/tikcpp/samples/cmake)
3232
else()
33-
message(FATAL_ERROR "ascendc_kernel_cmake does not exist, please check whether the cann package is installed.")
33+
message(FATAL_ERROR "`ascendc_kernel_cmake` does not exist; please check whether the `CANN` package is installed.")
3434
endif()
3535

3636
include(${ASCENDC_CMAKE_DIR}/ascendc.cmake)

src/ascend/custom/cmake/config_envs.cmake

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# find python binary
1+
# Find the Python binary.
22
find_program(PYTHON_EXECUTABLE NAMES python3)
33

44
if (NOT EXISTS ${PYTHON_EXECUTABLE})
5-
message(FATAL_ERROR "python3 is not found, install python firstly")
5+
message(FATAL_ERROR "`python3` is not found; install Python first.")
66
endif ()
77

8-
# get torch path, torch npu path, pybind11 path via python script
8+
# Get `torch`, `torch_npu`, and `pybind11` paths via a Python helper.
99
execute_process(
1010
COMMAND ${PYTHON_EXECUTABLE} "-c"
1111
"import torch; import torch_npu; import os; import pybind11; import sysconfig;
@@ -20,46 +20,46 @@ quit(0)
2020
RESULT_VARIABLE EXEC_RESULT
2121
OUTPUT_VARIABLE OUTPUT_ENV_DEFINES)
2222

23-
# if failed to run the python script
23+
# Abort if the Python helper failed.
2424
if (NOT ${EXEC_RESULT} EQUAL 0)
25-
message(FATAL_ERROR "failed to get run python script to get ENVS like TORCH_DIR etc")
25+
message(FATAL_ERROR "Failed to run Python script to probe env vars like `TORCH_DIR`.")
2626
else ()
27-
message(STATUS "run python script successfully, output string is [${OUTPUT_ENV_DEFINES}]")
27+
message(STATUS "Python probe succeeded; output string is [${OUTPUT_ENV_DEFINES}].")
2828
endif ()
2929

30-
# extract TORCH_DIR and set it
30+
# Extract `TORCH_DIR`.
3131
execute_process(
3232
COMMAND sh -c "echo \"${OUTPUT_ENV_DEFINES}\" | awk '{print $1}'"
3333
OUTPUT_VARIABLE TORCH_DIR
3434
RESULT_VARIABLE EXEC_RESULT
3535
OUTPUT_STRIP_TRAILING_WHITESPACE
3636
)
3737

38-
# extract TORCH_NPU_DIR and set it
38+
# Extract `TORCH_NPU_DIR`.
3939
execute_process(
4040
COMMAND sh -c "echo \"${OUTPUT_ENV_DEFINES}\" | awk '{print $2}'"
4141
OUTPUT_VARIABLE TORCH_NPU_DIR
4242
RESULT_VARIABLE EXEC_RESULT
4343
OUTPUT_STRIP_TRAILING_WHITESPACE
4444
)
4545

46-
# extract PYBIND11_DIR and set it
46+
# Extract `PYBIND11_DIR`.
4747
execute_process(
4848
COMMAND sh -c "echo \"${OUTPUT_ENV_DEFINES}\" | awk '{print $3}'"
4949
OUTPUT_VARIABLE PYBIND11_DIR
5050
RESULT_VARIABLE EXEC_RESULT
5151
OUTPUT_STRIP_TRAILING_WHITESPACE
5252
)
5353

54-
# extract PYTROCH_ABI and set it
54+
# Extract the PyTorch C++11 ABI flag.
5555
execute_process(
5656
COMMAND sh -c "echo \"${OUTPUT_ENV_DEFINES}\" | awk '{print $4}'"
5757
OUTPUT_VARIABLE TORCH_API_ENABLED
5858
RESULT_VARIABLE EXEC_RESULT
5959
OUTPUT_STRIP_TRAILING_WHITESPACE
6060
)
6161

62-
# extract PYTHON_INCLUDE_DIR and set it
62+
# Extract `PYTHON_INCLUDE_DIR`.
6363
execute_process(
6464
COMMAND sh -c "echo \"${OUTPUT_ENV_DEFINES}\" | awk '{print $5}'"
6565
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
@@ -73,7 +73,7 @@ message(STATUS "TORCH_NPU_DIR=${TORCH_NPU_DIR}")
7373
message(STATUS "PYBIND11_DIR=${PYBIND11_DIR}")
7474
message(STATUS "PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}")
7575

76-
# set _GLIBCXX_USE_CXX11_ABI
76+
# Set `_GLIBCXX_USE_CXX11_ABI` to match the PyTorch build.
7777
if (${TORCH_API_ENABLED} STREQUAL "True")
7878
add_compile_options(-D_GLIBCXX_USE_CXX11_ABI=1)
7979
message(STATUS "_GLIBCXX_USE_CXX11_ABI=1")

0 commit comments

Comments
 (0)