| Files | Last commit | Last update |
|---|---|---|
feat(ir): Keep int64 kwargs canonical and add narrowing accessors Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7673 merge feat/io_text_kwarg_int64 into master feat(ir): Keep int64 kwargs canonical and add narrowing accessors Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 一、背景 ir.Call.kwargs_ 是 vector<pair<string, std::any>>。同一份 IR 由两条路径产生时,payload 类型不一致: | 路径 | compact=1 | dims=[1,2,3] | |---|---|---| | pro 前端(Python 构造 Call,经 ConvertKwargsDict) | int | vector<int> | | 文本 load(ParseAttrValueInt 等) | int64_t | vector<any> | 直跑(前端)时 codegen 拿到 int,GetKwarg<int> 正常;续跑(文本 load)拿到 int64_t,std::any_cast 严格匹配失败: Invalid type for kwarg key: l2_cache_mode, expected int, but got long - **IR 层统一存 int64_t / vector<int64_t>**(规范化数值表示); - **pro 操作接口需要 32 位时,由 IR 提供窄化取值接口**(带范围检查); - 非数值类型(DataType / MemorySpace / vector<string>)的还原放在后续 stacked PR,不在本 PR。 ## 二、改动 ### 1)IR 窄化接口 framework/include/core/any_cast.h cpp template <typename T> T AnyCastNarrow(const std::any& value, const std::string& context = ""); - 类型完全匹配 → 直接取值; - int64_t → 其它整型:范围检查后 static_cast,越界抛 TypeError; - vector<int64_t> → vector<int>:逐元素范围检查; - 其它 → 回退 AnyCast<T>(保留原有可读报错)。 接入点: | 文件 | 改动 | |---|---| | framework/include/ir/expr.h | Call::GetKwarg<T> 改用 AnyCastNarrow | | framework/include/ir/type_inference.h | GetOpKwarg<T> 改用 AnyCastNarrow | ### 2)前端绑定:存 canonical int64 python/src/bindings/ir/ir.cpp ConvertKwargsDict: - Python int → int64_t - Python 枚举的底层值 → int64_t - list[int] → vector<int64_t> Call.kwargs getter 增加 vector<int64_t> 分支,保证 Python 视图能读到新类型。 ### 3)消费点适配 | 文件 | 改动 | |---|---| | framework/src/interface/ir/op/dist_ops.cpp | std::any_cast<int> → AnyCastNarrow<int>;类型检查接受 int64_t | | framework/src/interface/ir/op/vf_ops.cpp | dist kwarg 改用 AnyCastNarrow | | framework/src/interface/pypto_pro/backend/common/backend_utils.cpp | cmp_mode / offset 改用 AnyCastNarrow | | framework/src/interface/pypto_pro/backend/backend_cce_block_out_ops.cpp | pattern_mode 改用 AnyCastNarrow | | framework/src/interface/ir/op_registry.cpp | std::vector<int> 契约同时接受 vector<int64_t>,读取时窄化 | See merge request: cann/pypto!7673 | 3 days ago | |
feat(IR): Add ir text serialization Co-authored-by: Jie Yin<yinjie27@huawei.com> # message auto-generated for no-merge-commit merge: !5455 merge normalize-ir-rw into master feat(IR): Add ir text serialization Created-by: yinjie27_ Commit-by: Jie Yin Merged-by: cann-robot Description: feat(IR): Add ir text serialization See merge request: cann/pypto!5455 | 3 months ago | |
refactor(pypto_pro): address codecheck warnings Co-authored-by: fa<yangzf993@163.com> # message auto-generated for no-merge-commit merge: !7683 merge bugfix into master refactor(pypto_pro): address codecheck warnings Created-by: fafafafafa Commit-by: fa Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7683 | 3 days ago | |
refactor(ir): drop the unused INDEX dtype Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7713 merge feat/io_text_drop_index_dtype into master refactor(ir): drop the unused INDEX dtype Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 一、背景 DataType::INDEX(kIndexCode = 0x15)是历史上为"索引型 64 位整数"保留的占位类型,实际语义与 INT64 完全重复: - 与 INT64 共用同一个 C 类型串:DataType::GetDataTypeCTypeStringDict() 里同时有 {kInt64Code, "int64_t"} 和 {kIndexCode, "int64_t"}; - BiMap 的反查是 str2typeDict[s] = i(后写覆盖),导致 Find("int64_t") 返回的是 INDEX 而不是 INT64; - 为此在文本 load 和 kwarg 读取侧被迫加了特判: - io_text_loader.cpp 的 TryDTypeFromCTypeString(text, preferInt64)(pro/v0 门控); - AnyCastFromIR<DataType> 里的 if (text == "int64_t") return kInt64Code;; - 反向不唯一还带出另一个坑:{kHf4Code, "unknown"} 使 "unknown" 反查到 HF4。 评审确认 INDEX 已无真实使用点(所有出现都是"等价于 INT64"的类型标注),因此整体删除。 ## 二、改动 ### 1)dtype 定义(framework/include/core/dtype.h) - 删除 kIndexCode、DataType::INDEX 声明与定义; - 删除 BiMap 中的 {kIndexCode, IR_KW_TYPE_INT64}(反查恢复唯一,"int64_t" → INT64); - 删除 GetBit() 的 case kIndexCode、ToString() 的 "index" 分支、DTypeToString() 的 "INDEX" 分支。 ### 2)结构性去重(structural_hash.cpp / structural_equal.cpp) - 删除 CanonicalizeForSyntaxScalarDtype() / AreForSyntaxScalarDtypesEquivalent(); - 删除仅为该归一化存在的上下文机制:fieldNameStack_、IsLoopVarFieldContext()、IsConstIntTypeContext(); - structural_hash 的 nodeTypeStack_ 一并移除(仅该归一化使用);structural_equal 保留 nodeTypeStack_(assert 模式错误路径仍在用)。 ### 3)消费侧去掉冗余判断 - scalar_expr_ops.h:删除 INDEX↔INT64 免 Cast 分支; - atomic.cpp / sync.cpp / ptr_ops.cpp:dtype_.IsInt() || == INDEX → dtype_.IsInt(); - debug_ops.cpp:删除 IsPrintfIndexType() 及 6 处引用,同步精简报错文案; - backend_cce_ops.cpp / backend_cce_vf_ops.cpp / backend_cce_block_out_ops.cpp:删除 == INDEX 分支与注释里的 INDEX 说明。 ### 4)Python 侧 - bindings/ir/ir.cpp:删除 DataType.INDEX 只读属性; - python/pypto/ir.py:删除 INDEX = DataType.INDEX 别名,tuple_get_item() 内部改用 DataType.INT64; - python/pypto_pro/ir/op/debug_ops.py:删除 _is_index_dtype() 及其引用; - python/pypto_pro/language/parser/_gemm_lowering.py:类型校验改为 dtype.is_int(); - python/pypto_pro/runtime/jit.py:删除 (DataType.INDEX, "int64") 与 str(DataType.INDEX): ctypes.c_int64(INT64 已有对应项)。 ### 5)测试 - 14 个 Python 用例文件:ir.INDEX / DataType.INDEX → INT64; - 18 个 C++ UT 文件:DataType::INDEX → DataType::INT64; - 删除只验证"INDEX 存在"的用例: - test_structural_equal_ext.cpp:TestLoopVarInt64IndexNotEquivalent、TestConstIntTypeInt64IndexNotEquivalent; - test_dtype.py:test_limits_of_index_matches_int64; - test_scalar_range.py:test_explicit_legacy_index_dtype_is_preserved; - test_backend_cce_vf_ops.cpp:删除重复的 IndexVal 用例,测试更名为 MulsAcceptsInt64ScalarConvertedToSrcType。 ### 6)文档 - docs/zh|en/.../basic_data_structures/DataType.md:删除 static const DataType INDEX; 行(中英同步,保持原 CRLF 行尾)。 ## 三、行为变化(对外可见) | 场景 | 改动前 | 改动后 | |---|---|---| | GetDataTypeCTypeStringDict().Find("int64_t") | INDEX | INT64 | | v0 文本 incast(int64_t %a) 的 dtype | INDEX | INT64 | | DataType.INDEX / ir.INDEX | 存在 | **不存在**(调用方需改用 INT64) | | str(DataType.INDEX) | "index" | 类型已删除 | | structural hash/equal 的 INT64≡INDEX 归一化 | 存在 | 不再需要(两者本就是一个类型) | | debug.printf/assert 的 index 标量 | 单独归类 | 按 INT64 处理(行为等价) | **兼容性**:IR 文本不变(int64_t 前后一致);不涉及序列化格式;只影响直接使用 DataType.INDEX 的 C++/Python 调用点,本 PR 已全部迁移。 See merge request: cann/pypto!7713 | 3 days ago | |
refactor(all): Remove trailing whitespace Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !2188 merge pre-commit into master refactor(all): Remove trailing whitespace Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Introduce pre-commit tools, and remove trailing white space with default plugin Related Issue: #1017 See merge request: cann/pypto!2188 | 7 months ago | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 months ago |