| Files | Last commit | Last update |
|---|---|---|
feat(conv): Support conv tileshape infer transdata vec tileshape Co-authored-by: Catherie<mayuan33@huawei.com> # message auto-generated for no-merge-commit merge: !5148 merge conv_tile_to_vec_tile into master feat(conv): Support conv tileshape infer transdata vec tileshape Created-by: xinweiliu Commit-by: Catherie Merged-by: cann-robot Description: 支持A2A3 通过Conv tileshape 内部推导Transdata Vec TileShape,用户不需要前端显示配置 See merge request: cann/pypto!5148 | 3 months ago | |
refactor(interface): Remove UpdateTensorDataUsage() Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !5451 merge test_data/1 into master refactor(interface): Remove UpdateTensorDataUsage() Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Remove per function importDict Related Issue: #2559 See merge request: cann/pypto!5451 | 3 months ago | |
feat(conv): Support conv tileshape infer transdata vec tileshape Co-authored-by: Catherie<mayuan33@huawei.com> # message auto-generated for no-merge-commit merge: !5148 merge conv_tile_to_vec_tile into master feat(conv): Support conv tileshape infer transdata vec tileshape Created-by: xinweiliu Commit-by: Catherie Merged-by: cann-robot Description: 支持A2A3 通过Conv tileshape 内部推导Transdata Vec TileShape,用户不需要前端显示配置 See merge request: cann/pypto!5148 | 3 months ago | |
fix(ir): Dump attr support map Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !4577 merge fix_ir_dump into master fix(ir): Dump attr support map Created-by: zhaojunhan Commit-by: zhaojunhan Merged-by: cann-robot Description: Dump operation attributes with support for map-type data. See merge request: cann/pypto!4577 | 4 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 | |
fix(ir): Fix missing replace of scalar vars Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !5308 merge shape into master fix(ir): Fix missing replace of scalar vars Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Related Issue: #2559 See merge request: cann/pypto!5308 | 3 months ago | |
feat(conv): Support conv tileshape infer transdata vec tileshape Co-authored-by: Catherie<mayuan33@huawei.com> # message auto-generated for no-merge-commit merge: !5148 merge conv_tile_to_vec_tile into master feat(conv): Support conv tileshape infer transdata vec tileshape Created-by: xinweiliu Commit-by: Catherie Merged-by: cann-robot Description: 支持A2A3 通过Conv tileshape 内部推导Transdata Vec TileShape,用户不需要前端显示配置 See merge request: cann/pypto!5148 | 3 months ago | |
去掉stride<dilated_kernel的限制,增加平台版本验证 | 3 months ago | |
feat(matmul): support GEMV (M=1) via TGEMV + ND data path Co-authored-by: zhuhongyu<zhuhongyu22@h-partners.com> # message auto-generated for no-merge-commit merge: !5563 merge pr/gemv into master feat(matmul): support GEMV (M=1) via TGEMV + ND data path Created-by: Zhu1418539395 Commit-by: zhuhongyu Merged-by: cann-robot Description: ## 功能描述<br> 支持 MatMul 的 GEMV(M=1,矩阵向量乘)场景:当 matmul 的 A 为单行(M=1,非 transA)时,算侧使用 pto::TGEMV(底层 mad 指令,M 硬编码 1),搬运侧 A 全程保持 ND 数据路径(不做 NZ 分形转换),并做 M 轴去 pad / K 对齐差异化,减少 L1/L0A buffer 占用。<br><br> ## 改动内容(按层)<br> **信号判定(op 创建处)**<br> - cube_operation_impl.cpp AddAMulBNode:非 transA 且 M==1 时设 OpAttributeKey::isGemv;transA(M=1)退化为普通 transA matmul。<br><br> **Tile graph pass(对齐/搬运)**<br> - generate_move_op.cpp ProcessUB2L1:GEMV A 来自 UB 时跳过 ND2NZ(A 保持 ND)。<br> - pad_local_buffer.cpp PadMatmul:GEMV 的 L1/L0A/UB2L1 输入按 K 对齐(L1/UB 32B、L0A 512B)、M 轴不打 pad;isUB2L1Scene 的 bank 冲突优化(+=1)对 GEMV 跳过。<br> - merge_view_assemble_utils.*:isGemv/copy_in_mode 白名单继承,跨 VIEW 重建存活。<br><br> **Codegen(指令分发)**<br> - codegen_op_npu.h / codegen_op_litenpu.*:新增虚函数 GetMatmulTileOpName()(LiteNPU 覆写读 isGemv)。<br> - codegen_mte.cpp:GEMV 的 UB→L1 生成 TCopyUB2L1ND2ND、L1→L0A 生成 TExtractL1ToL0ND2ND。<br> - codegen_cube.cpp:算侧读 isGemv 生成 TGEMV。<br><br> **TileLib(指令实现)**<br> - cube_pto.h:新增 TGEMV(#ifdef __LITE_NPU)、TCopyUB2L1ND2ND / TExtractL1ToL0ND2ND wrapper。<br> - mmad_impl.h:TMatmulImpl 加 isGemv 模板参数,GEMV 时 validM=1(M 不打 pad)并分派 pto::TGEMV 系列。<br> - copy_ub_to_l1_impl.h / copy_l1_to_l0_impl.h:GEMV 时 tile 声明 BLayout::RowMajor(+ SLayout::NoneBox),命中 pto-isa TExtractVecToMat/TExtractToAVector 的 ND 搬运分支。<br><br> **平台隔离**<br> - 框架 pass/codegen 层:仅源头 1 处运行时平台判断(LiteNPU)+ codegen 虚函数分派,非 LiteNPU 平台行为不变。<br> - tileop wrapper 层:TGEMV/ND2ND wrapper 用 __LITE_NPU 宏(kernel 编译域可见)。<br><br> ## 测试<br> - python/tests/ut/kirin/common_matmul.py:新增 GEMV 用例 41 个(id 015-055,s8s8 015-027 / FP16 028-055),覆盖 2D/3D/4D batch、bias、a/b_trans、深 K/N、非对齐 K/N、sub-fractal K-tile(tileKAL1>tileKL0)。<br> - common_attention.py / test_kirin9030_attention.py:修复 4input 测试 out shape;attention 复合场景(matmul A 来自 UB,M=1)回归验证。<br><br> ## 验证<br> - GEMV 全量用例(015-055)+ attention 4input 回归通过(kirin9030)。****<br> See merge request: cann/pypto!5563 | 3 months ago | |
fix(dfx): Modify error code h path Co-authored-by: meiqing2<meiqing2@hisilicon.com> # message auto-generated for no-merge-commit merge: !2697 merge errcode into master fix(dfx): Modify error code h path Created-by: meiqing2 Commit-by: meiqing2 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 规范](https://gitcode.com/cann/pypto/blob/master/docs/contribute/pull-request.md#commit-message) See merge request: cann/pypto!2697 | 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 | |
convbp infershape修正 | 3 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 | |
2d 3d op名调整 | 3 months ago | |
Rebase dev_wsh onto master (content from origin/dev) | 3 months ago | |
参数注册修正 | 3 months ago | |
检视意见修正 | 3 months ago | |
fix(operation): Add empty tensor validation for compare operations Co-authored-by: raoliang_sac<raoliang4@huawei.com> # message auto-generated for no-merge-commit merge: !5232 merge fix-compare-empty-tensor into master fix(operation): Add empty tensor validation for compare operations Created-by: raoliang_sac Commit-by: raoliang_sac Merged-by: cann-robot Description: ## 修复内容 compare 系列算子(eq、ne、gt、ge、lt、le、greater)在 Tensor-scalar 场景下传入空 Tensor(shape 含 0)时未拦截,静默编译通过并产生错误结果。Tensor-Tensor 场景虽报错但为不相关的 Pass 层内部错误。所有 compare 算子的文档均声明「不支持空Tensor」,但框架层缺少对应的 shape value == 0 检查。 ## 根因 C++ 层 compare.cpp 的 3 个 Compare 入口函数调用的 CheckTensorDimRange 和 CheckTensorShapeSize 均不检查 shape value == 0(operation_common.cpp 中 if (value > 0) 直接跳过 0 值)。 ## 修复方案 1. 在 operation_common 中新增 CheckTensorNonEmpty 工具函数,遍历 shape 各维度检查是否为 0 2. 在 compare.cpp 的 3 个 Compare 重载(Tensor-Tensor、Tensor-scalar、scalar-Tensor)中调用该检查 ## 验证 - 空 tensor(shape=(0,))在 Tensor-scalar 和 Tensor-Tensor 场景下全部正确拦截,报 CHECK FAILED: Empty tensor is not supported for op: COMPARE, dimension[0] has shape value 0. - 7 个 compare 函数(eq/gt/ge/ne/lt/le/greater)× 2 场景 = 14 个 case 全部验证通过 - 非空 tensor baseline 无回归 ## 改动文件 - framework/src/interface/operation/operation_common.h:新增 CheckTensorNonEmpty 声明 - framework/src/interface/operation/operation_common.cpp:新增 CheckTensorNonEmpty 实现 - framework/src/interface/operation/vector/compare.cpp:在 3 个 Compare 重载中调用 CheckTensorNonEmpty Related Issue: #2854 See merge request: cann/pypto!5232 | 3 months ago | |
fix(operation): Add empty tensor validation for compare operations Co-authored-by: raoliang_sac<raoliang4@huawei.com> # message auto-generated for no-merge-commit merge: !5232 merge fix-compare-empty-tensor into master fix(operation): Add empty tensor validation for compare operations Created-by: raoliang_sac Commit-by: raoliang_sac Merged-by: cann-robot Description: ## 修复内容 compare 系列算子(eq、ne、gt、ge、lt、le、greater)在 Tensor-scalar 场景下传入空 Tensor(shape 含 0)时未拦截,静默编译通过并产生错误结果。Tensor-Tensor 场景虽报错但为不相关的 Pass 层内部错误。所有 compare 算子的文档均声明「不支持空Tensor」,但框架层缺少对应的 shape value == 0 检查。 ## 根因 C++ 层 compare.cpp 的 3 个 Compare 入口函数调用的 CheckTensorDimRange 和 CheckTensorShapeSize 均不检查 shape value == 0(operation_common.cpp 中 if (value > 0) 直接跳过 0 值)。 ## 修复方案 1. 在 operation_common 中新增 CheckTensorNonEmpty 工具函数,遍历 shape 各维度检查是否为 0 2. 在 compare.cpp 的 3 个 Compare 重载(Tensor-Tensor、Tensor-scalar、scalar-Tensor)中调用该检查 ## 验证 - 空 tensor(shape=(0,))在 Tensor-scalar 和 Tensor-Tensor 场景下全部正确拦截,报 CHECK FAILED: Empty tensor is not supported for op: COMPARE, dimension[0] has shape value 0. - 7 个 compare 函数(eq/gt/ge/ne/lt/le/greater)× 2 场景 = 14 个 case 全部验证通过 - 非空 tensor baseline 无回归 ## 改动文件 - framework/src/interface/operation/operation_common.h:新增 CheckTensorNonEmpty 声明 - framework/src/interface/operation/operation_common.cpp:新增 CheckTensorNonEmpty 实现 - framework/src/interface/operation/vector/compare.cpp:在 3 个 Compare 重载中调用 CheckTensorNonEmpty Related Issue: #2854 See merge request: cann/pypto!5232 | 3 months ago | |
Rebase dev_wsh onto master (content from origin/dev) | 3 months ago | |
参数注册修正 | 3 months ago | |
Rebase dev_wsh onto master (content from origin/dev) | 3 months ago | |
feat(pass): Adapt slice and contract Co-authored-by: Immutable01<gaoqiancheng@huawei.com> # message auto-generated for no-merge-commit merge: !5521 merge feat/enable-slice-switch into master feat(pass): Adapt slice and contract Created-by: Immutable01 Commit-by: Immutable01 Merged-by: cann-robot Description: 1.ExpandFunction展开插入slice和contract 2.view和assemble会被展开 See merge request: cann/pypto!5521 | 3 months ago | |
feat(Operation): Add input tile shape resolver. Co-authored-by: Immutable01<gaoqiancheng@huawei.com> # message auto-generated for no-merge-commit merge: !5126 merge 0727_viewtile into master feat(Operation): Add input tile shape resolver. Created-by: Immutable01 Commit-by: Immutable01 Merged-by: cann-robot Description: # TileShapeResolver:算子输入/输出 Tile 形状解析器 ## 1. 背景与目标 PyPTO 的 tensor-graph 算子在展开( ExpandFunction)前只携带一个 **op 级 TileShape**(描述"输出怎么切")。但算子的**每个输入/输出 tensor 实际被切成的第一刀 tile 形状**并不等于 op 级 TileShape: - 广播算子的输入要按自身 shape 做 min clamp; - reduce 算子的 reduce 轴保持 full、非 reduce 轴按 vecTile 切; - gather/scatter/sort/topk/matmul/transdata 等各有专属切法; - 输出侧 cube 算子按 CubeTile 切、transdata 输出维度与输入不同…… 下游(内存估算、调度、合轴等)需要在不真正展开的前提下,**直接从一个 Operation 推断其每个输入/输出的真实 tile 形状**。TileShapeResolver 就是提供这个能力的单例工具类。 ## 2. 整体设计 framework/src/interface/operation/tile_shape_resolver.h cpp class TileShapeResolver { public: static TileShapeResolver& Instance(); // 由 op 的 opcode + op 级 TileShape + 各 operand 自身 shape,推算第 index 个输入的真实 tile 形状 TileShape GetInputTileShape(const Operation& op, int index) const; // 由 op 的 opcode + op 级 TileShape + 各 operand 自身 shape,推算第 index 个输出的真实 tile 形状 TileShape GetOutputTileShape(const Operation& op, int index) const; private: TileShapeResolver() = default; TileShapeResolver(const TileShapeResolver&) = delete; TileShapeResolver& operator=(const TileShapeResolver&) = delete; }; - **单例 + 无状态**:所有信息从 Operation 现取,线程安全。 - **只覆盖 tensor op**:只对有 REGISTER_OPERATION_TILED_FUNC(即有 tile 展开的 tensor op)的 opcode 给出语义;tile op 不在本解析器职责内。 - **返回 TileShape**:当前只填 VecTile(cube 算子填 CubeTile),其余 sub-tile 保持默认。 ## 3. 实现侧:GetInputTileShape framework/src/interface/operation/tile_shape_resolver.cpp ### 3.1 公共辅助 | 辅助 | 作用 | |---|---| | ElementwiseInputVecTile(inShape, opVecTile) | 逐轴 min(inShape, vecTile),超出 vecTile 维数的轴保持 full。elementwise 默认。 | | VecTileAxisFull(inShape, clampShape, opVecTile, fullAxis) | 指定轴保持 full,其余轴 min(clampShape, vecTile)。用于 reduce/gather/scatter 的"轴 full"语义。 | | TransDataInputVecTile(inShape, opVecTile, group, groupAxis) | groupAxis 按 inShape/group 切,其余 elementwise。用于 TransData 系列。 | | MakeTileShapeFromVec(vec) | 把 vector<int64_t> 包成 TileShape(只设 VecTile)。 | ### 3.2 分支策略 按 opcode switch,**默认分支**为 ElementwiseInputVecTile(覆盖所有 elementwise 算子:Add/Div/Cast/Expand/Axpy/Where/OneHot/PReLU…)。特殊分支: | 类别 | opcode | 输入 tile 规则 | |---|---|---| | **轴 full 类** | OP_ROW*_SINGLE(Sum/Amax/Amin/Prod/ArgMax/ArgMin) | reduce 轴 full,其余 min。axis 取 OP_ATTR_PREFIX+"AXIS"(缺失回退 0)。 | | | OP_ROWEXPMAX / OP_ROWEXPSUM | 2-D 专用,axis=1 full,axis0 min。 | | | OP_BITSORT / OP_MRGSORT | sort 轴(OP_ATTR_PREFIX+"axis")full,其余 min。 | | | OP_ARGSORT | sort 轴 full;axis 取**裸键 "axis"**(与 ArgSortOperationTileFunc 实际读取一致,非注册声明的带前缀键)。 | | | OP_EXTRACT | 末轴 full,其余 min。 | | | OP_SORT_UB | sort 轴 full。 | | | OP_INDEX_ADD / OP_INDEX_ADD_UB | self(index 0)轴 full;src(index 1)elementwise;indices full。 | | **gather/scatter 类** | OP_GATHER | params:axis full,其余按输出轴映射 min;indices:按 axis+j 映射 min。 | | | OP_GATHER_ELEMENT | params 轴 full;indices elementwise。 | | | OP_SCATTER / OP_SCATTER_ELEMENT | self 与 idx 都按 idx.shape 在 axis full、其余 min。 | | | OP_INDEX_OUTCAST | [src, index, dst]:src/dst 轴 full、非轴 min;index(2-D)axis full,**字面 axis 0 仅当 axis!=0 时按 vecTile[0] 切**,其余非轴 full(对齐 TiledScatterUpdate)。axis 取**裸键 "axis"**。 | | | OP_INDEX_PUT | self 前导轴 full、尾部按 values 轴 min;values elementwise;其余输入按 {min(in[0], vecTile[0])}。 | | **topk** | OP_TOPK | 非轴 elementwise;axis 按 32 对齐 chunk(复刻 TopkOperationTileFunc 的 align 逻辑:maxNumValue=8192、kBlockSize=32 阈值)。 | | **where** | OP_WHERE_TT/TS/ST/SS | cond(index 0)若为 DT_UINT8 末轴按 vecTile/8 切(mask 位宽);其余 elementwise。 | | **transdata** | OP_NCHW2NC1HWC0 等 6 个 | TransDataInputVecTile,groupAxis 按输入 layout 定(NCHW 系列为 1,NCDHW 系列为 2)。 | | **pack** | OP_PACK | 输出 1-D,输入 tile = {min(in[0], ∏vecTile)}。 | | **prelu** | OP_PRELU | input elementwise;weight 取 {min(weight[0], vecTile[1])}(channel 轴)。 | | **cube matmul** | OP_A_MUL_B / A_MUL_BT / A_MULACC_B / A_MULACC_BT | A={m[0],k[0]}(transA 反转),B={k[0],n[0]}(transB 反转);MX/bias/scale 等附加输入按 Matrix::CopyInMode::DN2NZ 等属性决定 scale 的 NZ 排布与 ceil(k/64)。属性键统一用 Matrix:: 限定。 | | 其它 | OP_RANGE / OP_UNIFORM / OP_VEC_DUP / OP_CUBE_CONV_D2S / OP_CUBE_CONCAT_C | 无 tensor 输入或非 vec 切,直接返回 op 级 TileShape。 | > **属性键一致性**:解析器严格对齐各 TileFunc 实际读取的键。OP_INDEX_OUTCAST/OP_ARGSORT 用裸 "axis"(与 TileFunc 一致),OP_BITSORT/OP_MRGSORT/OP_GATHER/... 用 OP_ATTR_PREFIX+"axis",reduce 单算子用 OP_ATTR_PREFIX+"AXIS"。 ## 4. 实现侧:GetOutputTileShape 与输入侧对称,按 opcode switch,**默认分支**为 ElementwiseInputVecTile(outShape, opVecTile)(逐轴 min(outShape, vecTile))。默认分支正确的前提:① op 级 VecTile 维数 == 输出维数;② 输出按 VecTile 逐轴 elementwise 切("必须 full 的轴"在合法展开下 vecTile[fullAxis] >= shape[fullAxis],min 自然得 full,故 scatter/sort/indexadd/inplace 等无需专门分支)。 需要专门分支的输出: | opcode | 输出 tile 规则 | |---|---| | OP_A_MUL_B / A_MUL_BT / A_MULACC_B / A_MULACC_BT | 输出 C 按 CubeTile 的 L0 {m[0], n[0]} 切,clamp 到真实 {M, N}(参考 SetVecTileBasedOnUbSize)。 | | TransData 6 个 | 输出是变换后 layout(C0/N0/group),输出维数 ≠ 输入维数,op 级 VecTile 维数跟输入走,逐轴 min 对不上。Handle*Format 把**整张 dstTensor** 作为 tile op 的 oOperand(非切片 View),即每个 tile op 写整份输出,故 first-cut 输出 tile = **完整 outShape**。 | | OP_PACK | 输出 1-D 字节流:outShape[0] = inShape[0]*byte。PackOperationTileFunc 产 outputShape{ min(inShape[0], tile)*byte }(tile = ∏vecTile),故 first-cut 输出 tile = {min(outShape[0], tile*byte)},byte = BytesOf(input[0])。 | | OP_PERMUTE / OP_PERMUTE_ELEMENT | 输出轴 i ← 输入轴 perm[i],op 级 VecTile 跟输入轴序,故输出 tile = **VecTile 按 perm 重排**后逐轴 clamp 到 outShape(TiledPermuteOperation:resultTileShape = PermuteTileVector(inputTile.shape, perm))。 | | OP_TRANSPOSE_MOVEOUT / MOVEIN / VNCHWCONV | 二轴转置:输出 tile = op 级 VecTile 的 shape[0]/shape[1] 两轴**互换**后 clamp 到 outShape(TiledInnerTranspose:resultTileShape = inputTile.shape 交换 shape[0]/shape[1])。 | | OP_UNPACK | 输出 1-D:outShape[0] = inShape[0]/dstByte。UnPackOperationTileFunc 产 outputShape{ min(inShape[0], vecTile[0]) / dstByte },dstByte = BytesOf(output)。 | | OP_DEINTERLEAVE_SINGLE | 末轴减半:outShape[last] = inShape[last]/2,末轴 tile = min(outShape[last], vecTile[last]/2),其余 min(两输出同形)。 | | OP_EXTRACT | 末轴不切(full),其余 min(TiledExtract 跳过末轴)——与输入侧一致。 | | OP_BITSORT / OP_MRGSORT | sort 轴(OP_ATTR_PREFIX+"axis")不切(full),其余 min(TiledBitSort/TiledMrgSort 跳过 sort 轴)——与输入侧一致。 | | OP_GATHER_MASK_BUILDIN | 末轴按 patternMode 缩:mode 1/2 → vecTile/2,mode 3-6 → vecTile/4,其余 vecTile;其它轴 min。 | | OP_CUBE_CONV_D2S / OP_CUBE_CONCAT_C | OpCalcType::CONV 且无注册 TileFunc,不被 ExpandFunction 展开,tiling 由 ConvTile 驱动——**不在本解析器职责内**,返回 op 级 TileShape 作安全占位(tensor-graph 路径不会调到)。 | **走默认分支的代表性类目**(已逐一核对 TileFunc 源码): - **elementwise**:Add/Div/Cast/Expand/Axpy/Where/OneHot/PReLU … - **reduction**:tensor-graph reduce 算子恒把 reduce 轴置为 dim 1(ProcessResultShape 把 keepDim=false 的 squeeze 放到**独立的 OP_RESHAPE** 里做,而 OP_RESHAPE 不是 tensor op),故 min(1, vecTile[axis]) = 1,默认分支正确——**keepDim=false 不是缺口**。 - **gather/scatter/topk**:op 级 VecTile 维数已与输出维数对齐,默认 min 即可。 - **cumsum/cumprod/interleave/pad/fillpad/quantize/dequantize/expand_exp_dif**:输出按 min(outShape, vecTile) 逐轴切,默认即可。 - **生成型 1-D 算子 OP_RANGE / OP_UNIFORM / OP_VEC_DUP**:TiledRange/TiledUniformBuildIn/TiledFull 各自按 vecTile[0] 切 1-D 输出,正是 min(outShape[0], vecTile[0])——**归入默认分支**(原先误放到"返回 op 级"分支,已修正)。 ## 5. 测试方案 framework/tests/ut/interface/src/operation/test_tile_shape_resolver.cpp **核心思想**:用 DSL 在 FUNCTION{} 里建**单算子** tensor graph,让算子吃 TileShape::Current();展开前用 resolver 算"期望"的 per-input/per-output tile,展开后扫 tile op 找首个消费/产出对应 RawTensor 的 View 取"实际"first-cut tile,逐 operand 比对。 **harness 关键点**: 1. **输出 Tensor 提到 FUNCTION{} 外持有**——其底层 LogicalTensor 因此存活,可被 harness 捕获身份。 2. **oOperand 补挂**:本 harness 语境下 tensor-graph 算子的 oOperand 在展开前还是空的(输出要等展开流水线里才挂上)。harness 在 op->GetOOperands() 为空时把 fixture 提供的输出 LogicalTensor 挂上去——这正是 ExpandFunction/TileFunc 实际消费的输出;inplace 算子(oOperand 已非空 {self})则不动。 3. **展开失败显式断言**:ASSERT_NE(expandFunction.RunOnFunction(*fn), Status::FAILED),避免展开失败被后续扫描误判为 tile 形状不匹配。 4. **RawTensor 身份匹配**:LogicalTensor::View 共享底层 RawTensor,故输入/输出身份用 GetRawTensor().get() 唯一标识。 **覆盖 26 个 representative fixture**:elementwise(Div/Where/OneHot/Cast/Expand/Axpy)、permute(Permute_AxisSwap,**判别性** fixture:默认分支会产 {2,4,8},正确分支产 {4,2,8})、gather/scatter(Gather/Scatter/GatherElements/ScatterElement)、index(IndexAdd/IndexAddUb)、reduce 单算子(Sum/Amax/Amin/Prod/ArgMax/ArgMin 6 个)、rowexp(RowExpMax/RowExpSum,手动构建)、sort(MrgSort/BitSort/Extract)、topk(TopK 双输出)、prelu。多输出用 std::tie,inplace 用 self 作输出,手动构建用外部 Tensor out。 See merge request: cann/pypto!5126 | 4 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 |
| Files | Last commit | Last update |
|---|---|---|
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 7 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago |