已合并
补充cppgen框架 #817
init__zhb__创建于 7月6日
补充cppgen框架 #817
已合并
init__zhb__创建于 7月6日
init__zhb__成员
7月6日

描述

catlass_cppgen 是一个基于 Python 的代码生成框架,用于构建和生成 CATLASS 高性能算子。该框架提供接口以定义算子参数、选择优化策略,并自动生成对应的 C++ 核函数代码。

本次补充的内容结构如下:

./catlass_cppgen
├── catlass_cppgen
│   ├── __init__.py
│   ├── catlass                      # CATLASS 相关特性组件
│   │   ├── __init__.py
│   │   ├── arch                     # 代际声明
│   │   ├── evg                      # EVG 特性承载
│   │   ├── evg_extension.py
│   │   ├── gemm
│   │   ├── gemm_coord.py
│   │   ├── layout
│   │   └── library.py
│   ├── common                       # 通用组件
│   │   ├── __init__.py
│   │   ├── data_type.py
│   │   ├── op_tensor.py
│   │   ├── typing.py
│   │   └── utils.py
│   ├── kernel
│   │   ├── __init__.py
│   │   ├── gemm                      # GEMM 类算子特化类
│   │   ├── group_gemm                # Group GEMM 类算子特化类
│   │   ├── kernel_base.py
│   │   └── visitor_kernel_base.py
│   ├── op                            # 算子Kernel基类
│   │   ├── __init__.py
│   │   ├── gemm.py
│   │   ├── group_gemm.py
│   │   └── op.py
│   └── _version.py
├── docs                              # API 文档
│   ├── evg_api.md
│   ├── kernel_api.md
│   └── optensor_api.md
├── pyproject.toml
├── README.md                         # 主README文档
└── uv.lock

相关的测试路径:

./
├── catlass
│   ├── test_arch.py
│   ├── test_dispatch_policy.py
│   ├── test_gemm_coord.py
│   └── test_layout.py
├── common
│   ├── test_data_type.py
│   └── test_op_tensor.py
└── op
    ├── assertion_helper.py
    ├── test_evg.py
    ├── test_gemm.py
    └── test_group_gemm.py

关联的Issue

原因

演进与完善

测试

gen-match 测试(UT-level)
执行tests/run_cppgen.sh测试PASS

============================================
Step 3: Preparing test all testcases...
============================================
--- catlass/test_arch.py ---

...
----------------------------------------------------------------------
Ran 3 tests in 0.000s

OK

--- catlass/test_dispatch_policy.py ---

.......
----------------------------------------------------------------------
Ran 7 tests in 0.001s

OK

--- catlass/test_gemm_coord.py ---

....
----------------------------------------------------------------------
Ran 4 tests in 0.000s

OK

--- catlass/test_layout.py ---

.........................
----------------------------------------------------------------------
Ran 25 tests in 0.001s

OK

--- common/test_data_type.py ---

........................
----------------------------------------------------------------------
Ran 24 tests in 0.001s

OK

--- common/test_op_tensor.py ---

.......
----------------------------------------------------------------------
Ran 7 tests in 0.001s

OK

--- op/test_evg.py ---

............
----------------------------------------------------------------------
Ran 12 tests in 0.030s

OK

--- op/test_gemm.py ---

.............
----------------------------------------------------------------------
Ran 13 tests in 0.014s

OK

--- op/test_group_gemm.py ---

........
----------------------------------------------------------------------
Ran 8 tests in 0.003s

OK
============================================
Step 4: Cleaning and uninstalling catlass_cppgen...
============================================
Found existing installation: catlass-cppgen 0.1.0+20260706144530
Uninstalling catlass-cppgen-0.1.0+20260706144530:
  Successfully uninstalled catlass-cppgen-0.1.0+20260706144530
Found existing installation: build 1.5.0
Uninstalling build-1.5.0:
  Successfully uninstalled build-1.5.0

============================================
All steps completed successfully!
 SUMMARY: 9 passed, 0 failed
============================================

文档更新

更新下述文档:

  • python/catlass_cppgen/README.md
  • python/catlass_cppgen/docs/evg_api.md
  • python/catlass_cppgen/docs/kernel_api.md
  • python/catlass_cppgen/docs/optensor_api.md

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 init__zhb__ 的贡献)
CANN-robot
CANN-robot成员7月6日进行代码检视1
python/catlass_cppgen/catlass_cppgen/common/typing.py
@@ -0,0 +12,2 @@
12+# 使用字符串形式避免循环导入,from __future__ import annotations 会自动处理
13+SupportedTensor = Union[torch.Tensor, np.ndarray, "OpTensor"] # type: ignore[name-defined]
14+SupportedDataType = Union[torch.dtype, np.dtype]
CANN-robot
CANN-robot7月6日评论:

此条代码评论区间+12+23

【openlibing.ci】识别到代码检查告警抑制注释,匹配工具:mypy,请Committer检视其合理性。

likedislike
CANN-robotCANN-robot成员
7月6日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
7月6日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月6日 评论:

CLA Signature Pass

init__zhb__, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robot成员
7月6日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/catlass yuantao_, sunhao_hw (2/2) yuantao_ (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

init__zhb__, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了73条消息 查看更多
Iinit__zhb__成员
7月10日 关联了issue:[Requirement|需求建议]: 建议补充一个适用于模板库的cpp算子代码生成工具框架
yuantao
yuantao成员
7月10日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
7月10日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
7月10日 合入了pull request
CANN-robot
CANN-robot成员
7月10日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike