Loading...
Loading...
Compare original and translation side by side
csrc/opscsrc/opscsrc/opsEXEC_KERNEL_CMDcsrc/opsEXEC_KERNEL_CMDdigraph project_init {
rankdir=TB;
node [shape=box];
start [label="用户请求创建算子" shape=ellipse];
detect_ascend_kernel [label="检测ascend-kernel项目是否存在" shape=diamond];
detect_ops [label="检测csrc/ops/目录是否存在" shape=diamond];
copy_template [label="复制ascend-kernel项目模板到当前目录"];
create_ops_dir [label="创建csrc/ops目录"];
collect [label="收集算子信息"];
check_path [label="检查目标算子路径是否存在" shape=diamond];
show_exists [label="提示路径已存在,询问是否更换"];
show_result [label="展示目录结构和下一步指引"];
start -> detect_ascend_kernel;
detect_ascend_kernel -> detect_ops [label="存在"];
detect_ascend_kernel -> copy_template [label="不存在"];
copy_template -> collect;
detect_ops -> collect [label="存在ops/"];
detect_ops -> create_ops_dir [label="不存在ops/"];
create_ops_dir -> collect;
collect -> check_path;
check_path -> show_exists [label="存在"];
show_exists -> collect [label="更换名称"];
check_path -> show_result [label="不存在"];
}digraph project_init {
rankdir=TB;
node [shape=box];
start [label="用户请求创建算子" shape=ellipse];
detect_ascend_kernel [label="检测ascend-kernel项目是否存在" shape=diamond];
detect_ops [label="检测csrc/ops/目录是否存在" shape=diamond];
copy_template [label="复制ascend-kernel项目模板到当前目录"];
create_ops_dir [label="创建csrc/ops目录"];
collect [label="收集算子信息"];
check_path [label="检查目标算子路径是否存在" shape=diamond];
show_exists [label="提示路径已存在,询问是否更换"];
show_result [label="展示目录结构和下一步指引"];
start -> detect_ascend_kernel;
detect_ascend_kernel -> detect_ops [label="存在"];
detect_ascend_kernel -> copy_template [label="不存在"];
copy_template -> collect;
detect_ops -> collect [label="存在ops/"];
detect_ops -> create_ops_dir [label="不存在ops/"];
create_ops_dir -> collect;
collect -> check_path;
check_path -> show_exists [label="存在"];
show_exists -> collect [label="更换名称"];
check_path -> show_result [label="不存在"];
}op_host/op_kernel/ops.hregister.cppcsrc/CMakeLists.txtEXEC_KERNEL_CMDop_host/op_kernel/ops.hregister.cppcsrc/CMakeLists.txtEXEC_KERNEL_CMDbash <skill_dir>/scripts/detect_ascend_kernel_project.shbash <skill_dir>/scripts/detect_ascend_kernel_project.sh| 检测结果 | 处理方式 |
|---|---|
| 使用现有项目,继续步骤2 |
| 在项目中创建csrc/ops/目录,继续步骤2 |
| 复制ascend-kernel模板到当前目录,继续步骤2 |
| 列出所有项目,让用户选择 |
| Detection Result | Processing Method |
|---|---|
| Use the existing project and proceed to Step 2 |
| Create the csrc/ops/ directory in the project and proceed to Step 2 |
| Copy the ascend-kernel template to the current directory and proceed to Step 2 |
| List all projects and let the user select |
cp -r "<skill_dir>/templates/ascend-kernel" ./ascend-kernel
chmod +x ./ascend-kernel/build.shchmod +x build.shPermission deniedcp -r "<skill_dir>/templates/ascend-kernel" ./ascend-kernel
chmod +x ./ascend-kernel/build.shchmod +x build.shPermission denied| 信息 | 格式要求 | 说明 |
|---|---|---|
| 算子名称 | snake_case | 如 |
=== Ascend-Kernel算子信息 ===
算子名称: <op_name>
生成路径: <ascend_kernel_path>/csrc/ops/<op_name>
确认创建?[Y/n]| Information | Format Requirement | Description |
|---|---|---|
| Operator Name | snake_case | e.g., |
=== Ascend-Kernel Operator Information ===
Operator Name: <op_name>
Generation Path: <ascend_kernel_path>/csrc/ops/<op_name>
Confirm creation? [Y/n]mkdir -p csrc/opscsrc/ops/<op_name>mkdir -p csrc/opscsrc/ops/<op_name>mkdir -p csrc/ops/<op_name>/op_host csrc/ops/<op_name>/op_kernelcsrc/ops/<op_name>/csrc/ops/<op_name>/
├── CMakeLists.txt
├── design.md # 设计文档占位(由 design skill 填充)
├── op_host/
│ └── <op_name>.cpp # Host 占位(由 code-gen skill 替换)
└── op_kernel/
└── <op_name>.cpp # Kernel 占位(由 code-gen skill 替换)mkdir -p csrc/ops/<op_name>/op_host csrc/ops/<op_name>/op_kernelcsrc/ops/<op_name>/csrc/ops/<op_name>/
├── CMakeLists.txt
├── design.md # Design document placeholder (to be filled by design skill)
├── op_host/
│ └── <op_name>.cpp # Host placeholder (to be replaced by code-gen skill)
└── op_kernel/
└── <op_name>.cpp # Kernel placeholder (to be replaced by code-gen skill)CMakeLists.txtascendc_add_operator(OP_NAME <op_name>)op_host/<op_name>.cpptorch_kernel_helper.haclrtlaunch_<op_name>.hnamespace ascend_kernel { at::Tensor <op_name>(...) { ... } }op_kernel/<op_name>.cppkernel_operator.hextern "C" __global__ __aicore__ void <op_name>(...)CMakeLists.txtascendc_add_operator(OP_NAME <op_name>)op_host/<op_name>.cpptorch_kernel_helper.haclrtlaunch_<op_name>.hnamespace ascend_kernel { at::Tensor <op_name>(...) { ... } }op_kernel/<op_name>.cppkernel_operator.hextern "C" __global__ __aicore__ void <op_name>(...)csrc/ops.hcsrc/register.cppm.defm.implcsrc/CMakeLists.txtOP_SRCSascendc_library(...)aclnn/<op>.cpp说明:这是实战最高频遗漏点,必须在初始化阶段提前提示。
csrc/ops.hcsrc/register.cppm.defm.implcsrc/CMakeLists.txtOP_SRCSascendc_library(...)aclnn/<op>.cppNote: This is the most frequently missed point in practice, so it must be prompted in advance during the initialization phase.
Ascend-Kernel项目初始化成功!
项目结构:
<ascend_kernel_path>/
├── build.sh # 构建脚本
├── CMakeLists.txt # CMake配置
├── csrc/
│ ├── ops/ # 算子目录
│ ├── aclnn/ # ACLNN算子封装
│ ├── utils/ # 工具类
│ ├── ops.h # 算子声明
│ └── register.cpp # 算子注册
├── python/ # Python包
└── tests/ # 测试用例
下一步操作:
调用 ascendc-operator-design skill 完成设计文档Ascend-Kernel project initialization succeeded!
Project Structure:
<ascend_kernel_path>/
├── build.sh # Build script
├── CMakeLists.txt # CMake configuration
├── csrc/
│ ├── ops/ # Operator directory
│ ├── aclnn/ # ACLNN operator wrapper
│ ├── utils/ # Utility classes
│ ├── ops.h # Operator declarations
│ └── register.cpp # Operator registration
├── python/ # Python package
└── tests/ # Test cases
Next Steps:
Call ascendc-operator-design skill to complete the design documentEXEC_KERNEL_CMDdoublefloatEXEC_KERNEL_CMDdoubleascend-kernelcsrc/ops/<op_name>/ops.hregister.cppcsrc/CMakeLists.txtascend-kernelcsrc/ops/<op_name>/ops.hregister.cppcsrc/CMakeLists.txt