已合并
feat: pre-commit & update clang-fmt #1377
maohp_hw创建于 4月1日
feat: pre-commit & update clang-fmt #1377
已合并
共 99 个文件变更+3366-2545
| @@ -1,213 +1,67 @@ | |||
| 1 | -# 语言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto | 1 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 2 | -Language: Cpp | 2 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 3 | -# BasedOnStyle: LLVM | 3 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 4 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 5 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 6 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 7 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 8 | +# ============================================================================ | ||
| 4 | 9 | ||
| 5 | -# 访问说明符(public、private等)的偏移 | 10 | +# Usage: |
| 11 | +# Using clang-format to reformat a file: | ||
| 12 | +# clang-format -i -style=Google <file> | ||
| 13 | + | ||
| 14 | +BasedOnStyle: Google | ||
| 15 | +ColumnLimit: 120 | ||
| 6 | AccessModifierOffset: -4 | 16 | AccessModifierOffset: -4 |
| 17 | +SortIncludes: false | ||
| 18 | +BreakBeforeBraces: Custom | ||
| 7 | 19 | ||
| 8 | -# 开括号(开圆括号、开尖括号、开方括号)后的对齐: Align, DontAlign, AlwaysBreak(总是在开括号后换行) | 20 | +# 大括号换行配置 |
| 9 | -AlignAfterOpenBracket: Align | 21 | +BraceWrapping: |
| 22 | + AfterCaseLabel: false | ||
| 23 | + AfterClass: false | ||
| 24 | + AfterControlStatement: false | ||
| 25 | + # AfterEnum: false (紧凑模式,左大括号和enum同行, enum Color {...), AfterEnum: true (左大括号和enum换行). | ||
| 26 | + AfterEnum: false | ||
| 27 | + AfterFunction: true | ||
| 28 | + AfterNamespace: false | ||
| 29 | + AfterStruct: false | ||
| 30 | + AfterUnion: false | ||
| 31 | + AfterExternBlock: false | ||
| 32 | + BeforeCatch: false | ||
| 33 | + BeforeElse: false | ||
| 34 | + IndentBraces: false | ||
| 35 | + SplitEmptyFunction: false | ||
| 36 | + SplitEmptyRecord: true | ||
| 37 | + SplitEmptyNamespace: true | ||
| 10 | 38 | ||
| 11 | -# 连续赋值时,对齐所有等号 | 39 | +# Align |
| 12 | -AlignConsecutiveAssignments: false | 40 | +AlignAfterOpenBracket: AlwaysBreak |
| 13 | - | 41 | +AlignEscapedNewlines: Left |
| 14 | -# 连续声明时,对齐所有声明的变量名 | ||
| 15 | -AlignConsecutiveDeclarations: false | ||
| 16 | - | ||
| 17 | -# 右对齐逃脱换行(使用反斜杠换行)的反斜杠 | ||
| 18 | -AlignEscapedNewlines: Right | ||
| 19 | - | ||
| 20 | -# 水平对齐二元和三元表达式的操作数 | ||
| 21 | AlignOperands: true | 42 | AlignOperands: true |
| 22 | - | ||
| 23 | -# 对齐连续的尾随的注释 | ||
| 24 | AlignTrailingComments: true | 43 | AlignTrailingComments: true |
| 25 | - | 44 | +AllowAllArgumentsOnNextLine: true |
| 26 | -# 不允许函数声明的所有参数在放在下一行 | 45 | +AllowAllParametersOfDeclarationOnNextLine: true |
| 27 | -AllowAllParametersOfDeclarationOnNextLine: false | ||
| 28 | - | ||
| 29 | -# 不允许短的块放在同一行 | ||
| 30 | -AllowShortBlocksOnASingleLine: true | ||
| 31 | - | ||
| 32 | -# 允许短的case标签放在同一行 | ||
| 33 | -AllowShortCaseLabelsOnASingleLine: false | ||
| 34 | - | ||
| 35 | -# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All | ||
| 36 | -AllowShortFunctionsOnASingleLine: Empty | ||
| 37 | - | ||
| 38 | -# 允许短的if语句保持在同一行 | ||
| 39 | -AllowShortIfStatementsOnASingleLine: false | ||
| 40 | - | ||
| 41 | -# 禁止将短的循环体(如单行语句)放在同一行 | ||
| 42 | -AllowShortLoopsOnASingleLine: false | ||
| 43 | - | ||
| 44 | -# 总是在返回类型后换行: None, All, TopLevel(顶级函数,不包括在类中的函数), | ||
| 45 | -# AllDefinitions(所有的定义,不包括声明), TopLevelDefinitions(所有的顶级函数的定义) | ||
| 46 | -AlwaysBreakAfterReturnType: None | ||
| 47 | - | ||
| 48 | -# 总是在多行string字面量前换行 | ||
| 49 | AlwaysBreakBeforeMultilineStrings: false | 46 | AlwaysBreakBeforeMultilineStrings: false |
| 50 | - | ||
| 51 | -# 总是在template声明后换行 | ||
| 52 | AlwaysBreakTemplateDeclarations: true | 47 | AlwaysBreakTemplateDeclarations: true |
| 53 | 48 | ||
| 54 | -# false表示函数实参要么都在同一行,要么都各自一行 | ||
| 55 | BinPackArguments: true | 49 | BinPackArguments: true |
| 56 | - | ||
| 57 | -# false表示所有形参要么都在同一行,要么都各自一行 | ||
| 58 | -BinPackParameters: true | ||
| 59 | - | ||
| 60 | -# 大括号换行,只有当BreakBeforeBraces设置为Custom时才有效 | ||
| 61 | -BraceWrapping: | ||
| 62 | - # class定义后面 | ||
| 63 | - AfterClass: false | ||
| 64 | - # 控制语句后面 | ||
| 65 | - AfterControlStatement: false | ||
| 66 | - # enum定义后面 | ||
| 67 | - AfterEnum: false | ||
| 68 | - # 函数定义后面 | ||
| 69 | - AfterFunction: true | ||
| 70 | - # 命名空间定义后面 | ||
| 71 | - AfterNamespace: false | ||
| 72 | - # struct定义后面 | ||
| 73 | - AfterStruct: false | ||
| 74 | - # union定义后面 | ||
| 75 | - AfterUnion: false | ||
| 76 | - # extern之后 | ||
| 77 | - AfterExternBlock: false | ||
| 78 | - # catch之前 | ||
| 79 | - BeforeCatch: false | ||
| 80 | - # else之前 | ||
| 81 | - BeforeElse: false | ||
| 82 | - # 缩进大括号 | ||
| 83 | - IndentBraces: false | ||
| 84 | - # 分离空函数 | ||
| 85 | - SplitEmptyFunction: false | ||
| 86 | - # 分离空语句 | ||
| 87 | - SplitEmptyRecord: false | ||
| 88 | - # 分离空命名空间 | ||
| 89 | - SplitEmptyNamespace: false | ||
| 90 | - | ||
| 91 | -# 在二元运算符前换行: None(在操作符后换行), NonAssignment(在非赋值的操作符前换行), All(在操作符前换行) | ||
| 92 | -BreakBeforeBinaryOperators: NonAssignment | ||
| 93 | - | ||
| 94 | -# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似), | ||
| 95 | -# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似), | ||
| 96 | -# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom | ||
| 97 | -# 注:这里认为语句块也属于函数 | ||
| 98 | -BreakBeforeBraces: Custom | ||
| 99 | - | ||
| 100 | -# 在三元运算符前换行 | ||
| 101 | BreakBeforeTernaryOperators: false | 50 | BreakBeforeTernaryOperators: false |
| 102 | - | ||
| 103 | -# 在构造函数的初始化列表的冒号后换行 | ||
| 104 | -BreakConstructorInitializers: AfterColon | ||
| 105 | - | ||
| 106 | -#BreakInheritanceList: AfterColon | ||
| 107 | - | ||
| 108 | -BreakStringLiterals: false | ||
| 109 | - | ||
| 110 | -# 每行字符的限制,0表示没有限制 | ||
| 111 | -ColumnLimit: 120 | ||
| 112 | - | ||
| 113 | -CompactNamespaces: false | ||
| 114 | - | ||
| 115 | -# 构造函数的初始化列表要么都在同一行,要么都各自一行 | ||
| 116 | -ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
| 117 | - | ||
| 118 | -# 构造函数的初始化列表的缩进宽度 | ||
| 119 | -ConstructorInitializerIndentWidth: 4 | ||
| 120 | - | ||
| 121 | -# 延续的行的缩进宽度 | ||
| 122 | -ContinuationIndentWidth: 4 | ||
| 123 | - | ||
| 124 | -# 去除C++11的列表初始化的大括号{后和}前的空格 | ||
| 125 | -Cpp11BracedListStyle: true | ||
| 126 | - | ||
| 127 | -# 继承最常用的指针和引用的对齐方式 | ||
| 128 | -DerivePointerAlignment: false | ||
| 129 | - | ||
| 130 | -# 固定命名空间注释 | ||
| 131 | -FixNamespaceComments: true | ||
| 132 | - | ||
| 133 | -# 缩进case标签 | ||
| 134 | -IndentCaseLabels: false | ||
| 135 | - | ||
| 136 | -IndentPPDirectives: None | ||
| 137 | - | ||
| 138 | -# 缩进宽度 | ||
| 139 | -IndentWidth: 4 | ||
| 140 | - | ||
| 141 | -# 函数返回类型换行时,缩进函数声明或函数定义的函数名 | ||
| 142 | -IndentWrappedFunctionNames: false | ||
| 143 | - | ||
| 144 | -# 保留在块开始处的空行 | ||
| 145 | -KeepEmptyLinesAtTheStartOfBlocks: false | ||
| 146 | - | ||
| 147 | -# 连续空行的最大数量 | ||
| 148 | -MaxEmptyLinesToKeep: 1 | ||
| 149 | - | ||
| 150 | -# 命名空间的缩进: None, Inner(缩进嵌套的命名空间中的内容), All | ||
| 151 | -NamespaceIndentation: None | ||
| 152 | - | ||
| 153 | -# 指针和引用的对齐: Left, Right, Middle | ||
| 154 | -PointerAlignment: Left | ||
| 155 | - | ||
| 156 | -# 允许重新排版注释 | ||
| 157 | -ReflowComments: true | ||
| 158 | - | ||
| 159 | -# 允许排序#include | ||
| 160 | -SortIncludes: false | ||
| 161 | - | ||
| 162 | -# 允许排序 using 声明 | ||
| 163 | -SortUsingDeclarations: false | ||
| 164 | - | ||
| 165 | -# 在C风格类型转换后添加空格 | ||
| 166 | -SpaceAfterCStyleCast: false | ||
| 167 | - | ||
| 168 | -# 在Template 关键字后面添加空格 | ||
| 169 | -SpaceAfterTemplateKeyword: true | ||
| 170 | - | ||
| 171 | -# 在赋值运算符之前添加空格 | ||
| 172 | -SpaceBeforeAssignmentOperators: true | ||
| 173 | - | ||
| 174 | -# SpaceBeforeCpp11BracedList: true | ||
| 175 | - | ||
| 176 | -# SpaceBeforeCtorInitializerColon: true | ||
| 177 | - | ||
| 178 | -# SpaceBeforeInheritanceColon: true | ||
| 179 | - | ||
| 180 | -# 开圆括号之前添加一个空格: Never, ControlStatements, Always | ||
| 181 | -SpaceBeforeParens: ControlStatements | ||
| 182 | - | ||
| 183 | -# SpaceBeforeRangeBasedForLoopColon: true | ||
| 184 | - | ||
| 185 | -# 在空的圆括号中添加空格 | ||
| 186 | -SpaceInEmptyParentheses: false | ||
| 187 | - | ||
| 188 | -# 在尾随的评论前添加的空格数(只适用于//) | ||
| 189 | SpacesBeforeTrailingComments: 1 | 51 | SpacesBeforeTrailingComments: 1 |
| 190 | 52 | ||
| 191 | -# 在尖括号的<后和>前添加空格 | 53 | +# poniter aligment |
| 192 | -SpacesInAngles: false | 54 | +DerivePointerAlignment: false |
| 55 | +PointerAlignment: Left | ||
| 193 | 56 | ||
| 194 | -# 在C风格类型转换的括号中添加空格 | 57 | +# single line layout |
| 195 | -SpacesInCStyleCastParentheses: false | 58 | +AllowShortBlocksOnASingleLine: false |
| 59 | +AllowShortCaseLabelsOnASingleLine: false | ||
| 60 | +AllowShortFunctionsOnASingleLine: true | ||
| 61 | +AllowShortIfStatementsOnASingleLine: false | ||
| 62 | +AllowShortLoopsOnASingleLine: false | ||
| 196 | 63 | ||
| 197 | -# 在容器(ObjC和JavaScript的数组和字典等)字面量中添加空格 | 64 | +# tab space |
| 198 | -SpacesInContainerLiterals: true | 65 | +UseTab: Never |
| 199 | - | 66 | +IndentWidth: 4 |
| 200 | -# 在圆括号的(后和)前添加空格 | 67 | +TabWidth: 4 |
| 201 | -SpacesInParentheses: false | ||
| 202 | - | ||
| 203 | -# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响 | ||
| 204 | -SpacesInSquareBrackets: false | ||
| 205 | - | ||
| 206 | -# 标准: Cpp03, Cpp11, Auto | ||
| 207 | -Standard: Cpp11 | ||
| 208 | - | ||
| 209 | -# tab宽度 | ||
| 210 | -TabWidth: 4 | ||
| 211 | - | ||
| 212 | -# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always | ||
| 213 | -UseTab: Never | ||
| @@ -4,4 +4,41 @@ build_out | |||
| 4 | output | 4 | output |
| 5 | __pycache__/ | 5 | __pycache__/ |
| 6 | /examples/**/build/ | 6 | /examples/**/build/ |
| 7 | -AGENTS.md | 7 | +AGENTS.md |
| 8 | +oat_reports/ | ||
| 9 | + | ||
| 10 | +oat_reports/ | ||
| 11 | + | ||
| 12 | +oat_reports/ | ||
| 13 | + | ||
| 14 | +oat_reports/ | ||
| 15 | + | ||
| 16 | +oat_reports/ | ||
| 17 | + | ||
| 18 | +oat_reports/ | ||
| 19 | + | ||
| 20 | +oat_reports/ | ||
| 21 | + | ||
| 22 | +oat_reports/ | ||
| 23 | + | ||
| 24 | +oat_reports/ | ||
| 25 | + | ||
| 26 | +oat_reports/ | ||
| 27 | + | ||
| 28 | +oat_reports/ | ||
| 29 | + | ||
| 30 | +log/ | ||
| 31 | + | ||
| 32 | +log/ | ||
| 33 | + | ||
| 34 | +log/ | ||
| 35 | + | ||
| 36 | +oat_reports/ | ||
| 37 | + | ||
| 38 | +oat_reports/ | ||
| 39 | + | ||
| 40 | +oat_reports/ | ||
| 41 | + | ||
| 42 | +oat_reports/ | ||
| 43 | + | ||
| 44 | +log/ | ||
| @@ -0,0 +1,18 @@ | |||
| 1 | +repos: | ||
| 2 | + - repo: https://github.com/pre-commit/mirrors-clang-format | ||
| 3 | + rev: v16.0.0 | ||
| 4 | + hooks: | ||
| 5 | + - id: clang-format | ||
| 6 | + types_or: [c++, c] | ||
| 7 | + | ||
| 8 | + # OAT compliance check (Open Source Audit Tool) | ||
| 9 | + - repo: local | ||
| 10 | + hooks: | ||
| 11 | + - id: oat-check | ||
| 12 | + name: OAT Compliance Check | ||
| 13 | + entry: bash scripts/oat_check.sh | ||
| 14 | + language: system | ||
| 15 | + pass_filenames: true | ||
| 16 | + types: [file] | ||
| 17 | + stages: [commit] | ||
| 18 | + verbose: true | ||
| @@ -67,6 +67,8 @@ asc-devkit: | |||
| 67 | - impl/c_api/instr_impl/npu_arch_3510/sync_impl/asc_get_buf_impl.h | 67 | - impl/c_api/instr_impl/npu_arch_3510/sync_impl/asc_get_buf_impl.h |
| 68 | - impl/c_api/instr_impl/npu_arch_2201/sync_impl.h | 68 | - impl/c_api/instr_impl/npu_arch_2201/sync_impl.h |
| 69 | - impl/c_api/instr_impl/npu_arch_3510/sync_impl.h | 69 | - impl/c_api/instr_impl/npu_arch_3510/sync_impl.h |
| 70 | + - impl/c_api/instr_impl/npu_arch_2201/vector_compute_impl/asc_transto5hd_impl.h | ||
| 71 | + - impl/c_api/instr_impl/npu_arch_3510/vector_compute_impl/asc_transto5hd_impl.h | ||
| 70 | - impl/basic_api/dav_c310/kernel_operator_determine_compute_sync_impl.h | 72 | - impl/basic_api/dav_c310/kernel_operator_determine_compute_sync_impl.h |
| 71 | - impl/experimental/tensor_api/algorithm/gemm_impl.h | 73 | - impl/experimental/tensor_api/algorithm/gemm_impl.h |
| 72 | - impl/experimental/tensor_api/atom/cube_datamove/cube_datamove_impl.h | 74 | - impl/experimental/tensor_api/atom/cube_datamove/cube_datamove_impl.h |
| @@ -4925,42 +4925,29 @@ __aicore__ inline void asc_transpose_sync(__ubuf__ uint16_t* dst, __ubuf__ uint1 | |||
| 4925 | asc_transpose_sync_impl(dst, src); | 4925 | asc_transpose_sync_impl(dst, src); |
| 4926 | } | 4926 | } |
| 4927 | 4927 | ||
| 4928 | -// ==========asc_transto5hd========== | 4928 | +// __aicore__ inline void asc_transto5hd_b8(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 4929 | -__aicore__ inline void asc_transto5hd_b8(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4929 | +#define asc_transto5hd_b8(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 4930 | - uint16_t src_stride, bool dst_high_half, bool src_high_half) | 4930 | + asc_transto5hd_b8_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)) |
| 4931 | -{ | ||
| 4932 | - asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | ||
| 4933 | -} | ||
| 4934 | 4931 | ||
| 4935 | -__aicore__ inline void asc_transto5hd_b8_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4932 | +// __aicore__ inline void asc_transto5hd_b8_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 4936 | - uint16_t src_stride, bool dst_high_half, bool src_high_half) | 4933 | +#define asc_transto5hd_b8_sync(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 4937 | -{ | 4934 | + asc_transto5hd_b8_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)) |
| 4938 | - asc_transto5hd_b8_sync_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | ||
| 4939 | -} | ||
| 4940 | 4935 | ||
| 4941 | -__aicore__ inline void asc_transto5hd_b16(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4936 | +// __aicore__ inline void asc_transto5hd_b16(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 4942 | - uint16_t src_stride) | 4937 | +#define asc_transto5hd_b16(dst, src, repeat, dst_stride, src_stride) \ |
| 4943 | -{ | 4938 | + asc_transto5hd_b16_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 4944 | - asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride); | ||
| 4945 | -} | ||
| 4946 | 4939 | ||
| 4947 | -__aicore__ inline void asc_transto5hd_b16_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4940 | +// __aicore__ inline void asc_transto5hd_b16_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 4948 | - uint16_t src_stride) | 4941 | +#define asc_transto5hd_b16_sync(dst, src, repeat, dst_stride, src_stride) \ |
| 4949 | -{ | 4942 | + asc_transto5hd_b16_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 4950 | - asc_transto5hd_b16_sync_impl(dst, src, repeat, dst_stride, src_stride); | ||
| 4951 | -} | ||
| 4952 | 4943 | ||
| 4953 | -__aicore__ inline void asc_transto5hd_b32(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4944 | +// __aicore__ inline void asc_transto5hd_b32(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 4954 | - uint16_t src_stride) | 4945 | +#define asc_transto5hd_b32(dst, src, repeat, dst_stride, src_stride) \ |
| 4955 | -{ | 4946 | + asc_transto5hd_b32_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 4956 | - asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride); | ||
| 4957 | -} | ||
| 4958 | 4947 | ||
| 4959 | -__aicore__ inline void asc_transto5hd_b32_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 4948 | +// __aicore__ inline void asc_transto5hd_b32_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 4960 | - uint16_t src_stride) | 4949 | +#define asc_transto5hd_b32_sync(dst, src, repeat, dst_stride, src_stride) \ |
| 4961 | -{ | 4950 | + asc_transto5hd_b32_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 4962 | - asc_transto5hd_b32_sync_impl(dst, src, repeat, dst_stride, src_stride); | ||
| 4963 | -} | ||
| 4964 | 4951 | ||
| 4965 | // ==========asc_duplicate(half/int16_t/uint16_t/bfloat16_t/float/int32_t/uint32_t)========== | 4952 | // ==========asc_duplicate(half/int16_t/uint16_t/bfloat16_t/float/int32_t/uint32_t)========== |
| 4966 | __aicore__ inline void asc_duplicate(__ubuf__ half* dst, half src, uint8_t repeat, | 4953 | __aicore__ inline void asc_duplicate(__ubuf__ half* dst, half src, uint8_t repeat, |
| @@ -20,50 +20,51 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | -__aicore__ inline void asc_transto5hd_b8_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 23 | +// __aicore__ inline void asc_transto5hd_b8_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 24 | - uint16_t src_stride, bool dst_high_half, bool src_high_half) | 24 | +#define asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 25 | -{ | 25 | + do { \ |
| 26 | - if ASC_IS_AIV { | 26 | + if ASC_IS_AIV { \ |
| 27 | - scatter_vnchwconv_b8(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | 27 | + scatter_vnchwconv_b8((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), \ |
| 28 | - } | 28 | + (src_high_half)); \ |
| 29 | -} | 29 | + } \ |
| 30 | + } while (0) | ||
| 30 | 31 | ||
| 31 | -__aicore__ inline void asc_transto5hd_b8_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 32 | +// __aicore__ inline void asc_transto5hd_b8_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 32 | - uint16_t src_stride, bool dst_high_half, bool src_high_half) | 33 | +#define asc_transto5hd_b8_sync_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 33 | -{ | 34 | + do { \ |
| 34 | - asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | 35 | + asc_transto5hd_b8_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)); \ |
| 35 | - asc_sync_post_process(); | 36 | + asc_sync_post_process(); \ |
| 36 | -} | 37 | + } while (0) |
| 37 | 38 | ||
| 38 | -__aicore__ inline void asc_transto5hd_b16_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 39 | +// __aicore__ inline void asc_transto5hd_b16_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 39 | - uint16_t src_stride) | 40 | +#define asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 40 | -{ | 41 | + do { \ |
| 41 | - if ASC_IS_AIV { | 42 | + if ASC_IS_AIV { \ |
| 42 | - scatter_vnchwconv_b16(dst, src, repeat, dst_stride, src_stride); | 43 | + scatter_vnchwconv_b16((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 43 | - } | 44 | + } \ |
| 44 | -} | 45 | + } while (0) |
| 45 | 46 | ||
| 46 | -__aicore__ inline void asc_transto5hd_b16_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, | 47 | +// __aicore__ inline void asc_transto5hd_b16_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 47 | - uint16_t dst_stride, uint16_t src_stride) | 48 | +#define asc_transto5hd_b16_sync_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 48 | -{ | 49 | + do { \ |
| 49 | - asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride); | 50 | + asc_transto5hd_b16_impl((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 50 | - asc_sync_post_process(); | 51 | + asc_sync_post_process(); \ |
| 51 | -} | 52 | + } while (0) |
| 52 | 53 | ||
| 53 | -__aicore__ inline void asc_transto5hd_b32_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, | 54 | +// __aicore__ inline void asc_transto5hd_b32_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 54 | - uint16_t src_stride) | 55 | +#define asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 55 | -{ | 56 | + do { \ |
| 56 | - if ASC_IS_AIV { | 57 | + if ASC_IS_AIV { \ |
| 57 | - scatter_vnchwconv_b32(dst, src, repeat, dst_stride, src_stride); | 58 | + scatter_vnchwconv_b32((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 58 | - } | 59 | + } \ |
| 59 | -} | 60 | + } while (0) |
| 60 | 61 | ||
| 61 | -__aicore__ inline void asc_transto5hd_b32_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, | 62 | +// __aicore__ inline void asc_transto5hd_b32_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 62 | - uint16_t dst_stride, uint16_t src_stride) | 63 | +#define asc_transto5hd_b32_sync_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 63 | -{ | 64 | + do { \ |
| 64 | - asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride); | 65 | + asc_transto5hd_b32_impl((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 65 | - asc_sync_post_process(); | 66 | + asc_sync_post_process(); \ |
| 66 | -} | 67 | + } while (0) |
| 67 | 68 | ||
| 68 | 69 | ||
| 69 | 70 | ||
| @@ -71,4 +72,3 @@ __aicore__ inline void asc_transto5hd_b32_sync_impl(ub_addr8_t dst, ub_addr8_t s | |||
| 71 | 72 | ||
| 72 | 73 | ||
| 73 | 74 | ||
| 74 | - | ||
| @@ -5170,37 +5170,29 @@ __aicore__ inline void asc_transpose_sync(__ubuf__ uint16_t* dst, __ubuf__ uint1 | |||
| 5170 | asc_transpose_sync_impl(dst, src); | 5170 | asc_transpose_sync_impl(dst, src); |
| 5171 | } | 5171 | } |
| 5172 | 5172 | ||
| 5173 | -// ==========asc_transto5hd========== | 5173 | +// __aicore__ inline void asc_transto5hd_b8(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 5174 | -__aicore__ inline void asc_transto5hd_b8(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) | 5174 | +#define asc_transto5hd_b8(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 5175 | -{ | 5175 | + asc_transto5hd_b8_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)) |
| 5176 | - asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | ||
| 5177 | -} | ||
| 5178 | 5176 | ||
| 5179 | -__aicore__ inline void asc_transto5hd_b8_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) | 5177 | +// __aicore__ inline void asc_transto5hd_b8_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 5180 | -{ | 5178 | +#define asc_transto5hd_b8_sync(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 5181 | - asc_transto5hd_b8_sync_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | 5179 | + asc_transto5hd_b8_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)) |
| 5182 | -} | ||
| 5183 | 5180 | ||
| 5184 | -__aicore__ inline void asc_transto5hd_b16(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 5181 | +// __aicore__ inline void asc_transto5hd_b16(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 5185 | -{ | 5182 | +#define asc_transto5hd_b16(dst, src, repeat, dst_stride, src_stride) \ |
| 5186 | - asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride); | 5183 | + asc_transto5hd_b16_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 5187 | -} | ||
| 5188 | 5184 | ||
| 5189 | -__aicore__ inline void asc_transto5hd_b16_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 5185 | +// __aicore__ inline void asc_transto5hd_b16_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 5190 | -{ | 5186 | +#define asc_transto5hd_b16_sync(dst, src, repeat, dst_stride, src_stride) \ |
| 5191 | - asc_transto5hd_b16_sync_impl(dst, src, repeat, dst_stride, src_stride); | 5187 | + asc_transto5hd_b16_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 5192 | -} | ||
| 5193 | 5188 | ||
| 5194 | -__aicore__ inline void asc_transto5hd_b32(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 5189 | +// __aicore__ inline void asc_transto5hd_b32(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 5195 | -{ | 5190 | +#define asc_transto5hd_b32(dst, src, repeat, dst_stride, src_stride) \ |
| 5196 | - asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride); | 5191 | + asc_transto5hd_b32_impl((dst), (src), (repeat), (dst_stride), (src_stride)) |
| 5197 | -} | ||
| 5198 | - | ||
| 5199 | -__aicore__ inline void asc_transto5hd_b32_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | ||
| 5200 | -{ | ||
| 5201 | - asc_transto5hd_b32_sync_impl(dst, src, repeat, dst_stride, src_stride); | ||
| 5202 | -} | ||
| 5203 | 5192 | ||
| 5193 | +// __aicore__ inline void asc_transto5hd_b32_sync(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | ||
| 5194 | + | ||
| 5195 | + asc_transto5hd_b32_sync_impl((dst), (src), (repeat), (dst_stride), (src_stride)) | ||
| 5204 | 5196 | ||
| 5205 | // ===================asc_set_va_reg===================== | 5197 | // ===================asc_set_va_reg===================== |
| 5206 | __aicore__ inline void asc_set_va_reg(ub_addr8_t addr, __ubuf__ int8_t** src_array) | 5198 | __aicore__ inline void asc_set_va_reg(ub_addr8_t addr, __ubuf__ int8_t** src_array) |
| @@ -5242,4 +5234,4 @@ __aicore__ inline void asc_set_va_reg(ub_addr8_t addr, __ubuf__ float** src_arra | |||
| 5242 | { | 5234 | { |
| 5243 | asc_set_va_reg_impl(addr, src_array); | 5235 | asc_set_va_reg_impl(addr, src_array); |
| 5244 | } | 5236 | } |
| 5245 | -#endif | 5237 | +#endif |
| @@ -25,44 +25,51 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | -__aicore__ inline void asc_transto5hd_b8_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) | 28 | +// __aicore__ inline void asc_transto5hd_b8_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 29 | -{ | 29 | +#define asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 30 | - if ASC_IS_AIV { | 30 | + do { \ |
| 31 | - scatter_vnchwconv_b8(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | 31 | + if ASC_IS_AIV { \ |
| 32 | - } | 32 | + scatter_vnchwconv_b8((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), \ |
| 33 | -} | 33 | + (src_high_half)); \ |
| 34 | + } \ | ||
| 35 | + } while (0) | ||
| 34 | 36 | ||
| 35 | -__aicore__ inline void asc_transto5hd_b8_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) | 37 | +// __aicore__ inline void asc_transto5hd_b8_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride, bool dst_high_half, bool src_high_half) |
| 36 | -{ | 38 | +#define asc_transto5hd_b8_sync_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half) \ |
| 37 | - asc_transto5hd_b8_impl(dst, src, repeat, dst_stride, src_stride, dst_high_half, src_high_half); | 39 | + do { \ |
| 38 | - asc_sync_post_process(); | 40 | + asc_transto5hd_b8_impl((dst), (src), (repeat), (dst_stride), (src_stride), (dst_high_half), (src_high_half)); \ |
| 39 | -} | 41 | + asc_sync_post_process(); \ |
| 42 | + } while (0) | ||
| 40 | 43 | ||
| 41 | -__aicore__ inline void asc_transto5hd_b16_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 44 | +// __aicore__ inline void asc_transto5hd_b16_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 42 | -{ | 45 | +#define asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 43 | - if ASC_IS_AIV { | 46 | + do { \ |
| 44 | - scatter_vnchwconv_b16(dst, src, repeat, dst_stride, src_stride); | 47 | + if ASC_IS_AIV { \ |
| 45 | - } | 48 | + scatter_vnchwconv_b16((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 46 | -} | 49 | + } \ |
| 50 | + } while (0) | ||
| 47 | 51 | ||
| 48 | -__aicore__ inline void asc_transto5hd_b16_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 52 | +// __aicore__ inline void asc_transto5hd_b16_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 49 | -{ | 53 | +#define asc_transto5hd_b16_sync_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 50 | - asc_transto5hd_b16_impl(dst, src, repeat, dst_stride, src_stride); | 54 | + do { \ |
| 51 | - asc_sync_post_process(); | 55 | + asc_transto5hd_b16_impl((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 52 | -} | 56 | + asc_sync_post_process(); \ |
| 57 | + } while (0) | ||
| 53 | 58 | ||
| 54 | -__aicore__ inline void asc_transto5hd_b32_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 59 | +// __aicore__ inline void asc_transto5hd_b32_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 55 | -{ | 60 | +#define asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 56 | - if ASC_IS_AIV { | 61 | + do { \ |
| 57 | - scatter_vnchwconv_b32(dst, src, repeat, dst_stride, src_stride); | 62 | + if ASC_IS_AIV { \ |
| 58 | - } | 63 | + scatter_vnchwconv_b32((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 59 | -} | 64 | + } \ |
| 65 | + } while (0) | ||
| 60 | 66 | ||
| 61 | -__aicore__ inline void asc_transto5hd_b32_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) | 67 | +// __aicore__ inline void asc_transto5hd_b32_sync_impl(ub_addr8_t dst, ub_addr8_t src, uint8_t repeat, uint16_t dst_stride, uint16_t src_stride) |
| 62 | -{ | 68 | +#define asc_transto5hd_b32_sync_impl(dst, src, repeat, dst_stride, src_stride) \ |
| 63 | - asc_transto5hd_b32_impl(dst, src, repeat, dst_stride, src_stride); | 69 | + do { \ |
| 64 | - asc_sync_post_process(); | 70 | + asc_transto5hd_b32_impl((dst), (src), (repeat), (dst_stride), (src_stride)); \ |
| 65 | -} | 71 | + asc_sync_post_process(); \ |
| 72 | + } while (0) | ||
| 66 | 73 | ||
| 67 | 74 | ||
| 68 | 75 | ||
| @@ -1,24 +1,24 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/algorithm/copy_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/algorithm/copy_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | /*! | 18 | /*! |
| 19 | -* \file copy_impl.h | 19 | + * \file copy_impl.h |
| 20 | -* \brief | 20 | + * \brief |
| 21 | -*/ | 21 | + */ |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| @@ -28,24 +28,25 @@ namespace AscendC { | |||
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | 29 | ||
| 30 | template <typename Tp, const Tp& traits, typename T, typename... Params> | 30 | template <typename Tp, const Tp& traits, typename T, typename... Params> |
| 31 | -__aicore__ inline void Copy(const CopyAtom<T>& atomCopy, const Params& ...params) | 31 | +__aicore__ inline void Copy(const CopyAtom<T>& atomCopy, const Params&... params) |
| 32 | { | 32 | { |
| 33 | atomCopy.template Call<traits>(params...); | 33 | atomCopy.template Call<traits>(params...); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | template <typename T, typename... Params> | 36 | template <typename T, typename... Params> |
| 37 | -__aicore__ inline void Copy(const CopyAtom<T>& atomCopy, const Params& ...params) | 37 | +__aicore__ inline void Copy(const CopyAtom<T>& atomCopy, const Params&... params) |
| 38 | { | 38 | { |
| 39 | atomCopy.Call(params...); | 39 | atomCopy.Call(params...); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | template <typename... Args> | 42 | template <typename... Args> |
| 43 | -__aicore__ inline auto MakeCopy(const Args& ...traits) { | 43 | +__aicore__ inline auto MakeCopy(const Args&... traits) |
| 44 | +{ | ||
| 44 | return CopyAtom<CopyTraits<Args...>>{}; | 45 | return CopyAtom<CopyTraits<Args...>>{}; |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | -} | 48 | +} // namespace Te |
| 48 | -} | 49 | +} // namespace AscendC |
| 49 | 50 | ||
| 50 | 51 | ||
| 51 | 52 | ||
| @@ -1,24 +1,24 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/algorithm/mad_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/algorithm/mad_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | /*! | 18 | /*! |
| 19 | -* \file mad_impl.h | 19 | + * \file mad_impl.h |
| 20 | -* \brief | 20 | + * \brief |
| 21 | -*/ | 21 | + */ |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| @@ -28,24 +28,25 @@ namespace AscendC { | |||
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | 29 | ||
| 30 | template <typename Tp, const Tp& traits, typename T, typename... Params> | 30 | template <typename Tp, const Tp& traits, typename T, typename... Params> |
| 31 | -__aicore__ inline void Mad(const MmadAtom<T>& atomMad, const Params& ...params) | 31 | +__aicore__ inline void Mad(const MmadAtom<T>& atomMad, const Params&... params) |
| 32 | { | 32 | { |
| 33 | atomMad.template Call<traits>(params...); | 33 | atomMad.template Call<traits>(params...); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | template <typename T, typename... Params> | 36 | template <typename T, typename... Params> |
| 37 | -__aicore__ inline void Mad(const MmadAtom<T>& atomMad, const Params& ...params) | 37 | +__aicore__ inline void Mad(const MmadAtom<T>& atomMad, const Params&... params) |
| 38 | { | 38 | { |
| 39 | atomMad.Call(params...); | 39 | atomMad.Call(params...); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | template <typename... Args> | 42 | template <typename... Args> |
| 43 | -__aicore__ inline auto MakeMad(const Args& ...traits) { | 43 | +__aicore__ inline auto MakeMad(const Args&... traits) |
| 44 | +{ | ||
| 44 | return MmadAtom<MmadTraits<Args...>>{}; | 45 | return MmadAtom<MmadTraits<Args...>>{}; |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | -} | 48 | +} // namespace Te |
| 48 | -} | 49 | +} // namespace AscendC |
| 49 | 50 | ||
| 50 | 51 | ||
| 51 | 52 | ||
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_compute/mmad/mmad_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_compute/mmad/mmad_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -34,36 +34,34 @@ constexpr MmadParams defaultMmadParams = {0, 0, 0, 0, true}; | |||
| 34 | constexpr MmadParams defaultMmadWithBiasParams = {0, 0, 0, 0, false}; | 34 | constexpr MmadParams defaultMmadWithBiasParams = {0, 0, 0, 0, false}; |
| 35 | 35 | ||
| 36 | template <typename T, typename U, typename S> | 36 | template <typename T, typename U, typename S> |
| 37 | -static constexpr bool VerifyingMmadTemplate = (IsTileTensorV<T> && IsTileTensorV<U> | 37 | +static constexpr bool VerifyingMmadTemplate = (IsTileTensorV<T> && IsTileTensorV<U> && IsTileTensorV<S>); |
| 38 | - && IsTileTensorV<S>); | ||
| 39 | 38 | ||
| 40 | template <typename T, typename U, typename S, typename V> | 39 | template <typename T, typename U, typename S, typename V> |
| 41 | -static constexpr bool VerifyingMmadWithBiasTemplate = (IsTileTensorV<T> && IsTileTensorV<U> | 40 | +static constexpr bool VerifyingMmadWithBiasTemplate = |
| 42 | - && IsTileTensorV<S> && IsTileTensorV<V>); | 41 | + (IsTileTensorV<T> && IsTileTensorV<U> && IsTileTensorV<S> && IsTileTensorV<V>); |
| 43 | 42 | ||
| 44 | template <const MmadTrait& trait = DEFAULT_MMAD_TRAIT, typename T, typename U, typename S, typename Params> | 43 | template <const MmadTrait& trait = DEFAULT_MMAD_TRAIT, typename T, typename U, typename S, typename Params> |
| 45 | -__aicore__ inline typename Std::enable_if<VerifyingMmadTemplate<T, U, S>, void>::type | 44 | +__aicore__ inline typename Std::enable_if<VerifyingMmadTemplate<T, U, S>, void>::type Mmad( |
| 46 | -Mmad(const T& dst, const U& fm, const S& filter, const Params& params) | 45 | + const T& dst, const U& fm, const S& filter, const Params& params) |
| 47 | { | 46 | { |
| 48 | - constexpr Hardware dstPos = GetHardPos<T>(); | 47 | + constexpr Hardware dstPos = GetHardPos<T>(); |
| 49 | - constexpr Hardware fmPos = GetHardPos<U>(); | 48 | + constexpr Hardware fmPos = GetHardPos<U>(); |
| 50 | - constexpr Hardware filterPos = GetHardPos<S>(); | 49 | + constexpr Hardware filterPos = GetHardPos<S>(); |
| 51 | - using Tensor2Tensor = typename MmadTensor2Tensor<dstPos, fmPos, filterPos, Hardware::MAX, | 50 | + using Tensor2Tensor = |
| 52 | - CURRENT_ARCH_VERSION>::type; | 51 | + typename MmadTensor2Tensor<dstPos, fmPos, filterPos, Hardware::MAX, CURRENT_ARCH_VERSION>::type; |
| 53 | - Tensor2Tensor{}.template Run<trait>(dst, fm, filter, params); | 52 | + Tensor2Tensor{}.template Run<trait>(dst, fm, filter, params); |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | template <const MmadTrait& trait = DEFAULT_MMAD_TRAIT, typename T, typename U, typename S, typename V, typename Params> | 55 | template <const MmadTrait& trait = DEFAULT_MMAD_TRAIT, typename T, typename U, typename S, typename V, typename Params> |
| 57 | -__aicore__ inline typename Std::enable_if<VerifyingMmadWithBiasTemplate<T, U, S, V>, void>::type | 56 | +__aicore__ inline typename Std::enable_if<VerifyingMmadWithBiasTemplate<T, U, S, V>, void>::type Mmad( |
| 58 | -Mmad(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) | 57 | + const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) |
| 59 | { | 58 | { |
| 60 | - constexpr Hardware dstPos = GetHardPos<T>(); | 59 | + constexpr Hardware dstPos = GetHardPos<T>(); |
| 61 | - constexpr Hardware fmPos = GetHardPos<U>(); | 60 | + constexpr Hardware fmPos = GetHardPos<U>(); |
| 62 | - constexpr Hardware filterPos = GetHardPos<S>(); | 61 | + constexpr Hardware filterPos = GetHardPos<S>(); |
| 63 | - constexpr Hardware biasPos = GetHardPos<V>(); | 62 | + constexpr Hardware biasPos = GetHardPos<V>(); |
| 64 | - using Tensor2Tensor = typename MmadTensor2Tensor<dstPos, fmPos, filterPos, biasPos, | 63 | + using Tensor2Tensor = typename MmadTensor2Tensor<dstPos, fmPos, filterPos, biasPos, CURRENT_ARCH_VERSION>::type; |
| 65 | - CURRENT_ARCH_VERSION>::type; | 64 | + Tensor2Tensor{}.template Run<trait>(dst, fm, filter, bias, params); |
| 66 | - Tensor2Tensor{}.template Run<trait>(dst, fm, filter, bias, params); | ||
| 67 | } | 65 | } |
| 68 | } // namespace Te | 66 | } // namespace Te |
| 69 | } // namespace AscendC | 67 | } // namespace AscendC |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_compute/mmad/mmad_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_compute/mmad/mmad_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -28,34 +28,30 @@ | |||
| 28 | namespace AscendC { | 28 | namespace AscendC { |
| 29 | namespace Te { | 29 | namespace Te { |
| 30 | 30 | ||
| 31 | -class MmadIgnore | 31 | +class MmadIgnore { |
| 32 | -{ | ||
| 33 | public: | 32 | public: |
| 34 | - template <const MmadTrait& trait, typename ...Args> | 33 | + template <const MmadTrait& trait, typename... Args> |
| 35 | - __aicore__ inline void Run(const Args&... args) {} | 34 | + __aicore__ inline void Run(const Args&... args) |
| 35 | + {} | ||
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | -template<Hardware dstPos, Hardware fmPos, Hardware filterPos, Hardware biasPos, uint32_t Version> | 38 | +template <Hardware dstPos, Hardware fmPos, Hardware filterPos, Hardware biasPos, uint32_t Version> |
| 39 | -struct MmadTensor2Tensor | 39 | +struct MmadTensor2Tensor { |
| 40 | -{ | ||
| 41 | using type = MmadIgnore; | 40 | using type = MmadIgnore; |
| 42 | }; | 41 | }; |
| 43 | 42 | ||
| 44 | -template<> | 43 | +template <> |
| 45 | -struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::MAX, ArchVersion::V3510> | 44 | +struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::MAX, ArchVersion::V3510> { |
| 46 | -{ | ||
| 47 | using type = Mmad3510; | 45 | using type = Mmad3510; |
| 48 | }; | 46 | }; |
| 49 | 47 | ||
| 50 | -template<> | 48 | +template <> |
| 51 | -struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::L0C, ArchVersion::V3510> | 49 | +struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::L0C, ArchVersion::V3510> { |
| 52 | -{ | ||
| 53 | using type = MmadWithBias3510; | 50 | using type = MmadWithBias3510; |
| 54 | }; | 51 | }; |
| 55 | 52 | ||
| 56 | -template<> | 53 | +template <> |
| 57 | -struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::BIAS, ArchVersion::V3510> | 54 | +struct MmadTensor2Tensor<Hardware::L0C, Hardware::L0A, Hardware::L0B, Hardware::BIAS, ArchVersion::V3510> { |
| 58 | -{ | ||
| 59 | using type = MmadWithBias3510; | 55 | using type = MmadWithBias3510; |
| 60 | }; | 56 | }; |
| 61 | } // namespace Te | 57 | } // namespace Te |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -32,15 +32,18 @@ namespace Te { | |||
| 32 | class MmadInstr { | 32 | class MmadInstr { |
| 33 | public: | 33 | public: |
| 34 | template <typename T, typename U, typename S, typename... Params> | 34 | template <typename T, typename U, typename S, typename... Params> |
| 35 | - __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const Params& ...params) | 35 | + __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const Params&... params) |
| 36 | { | 36 | { |
| 37 | // MTE2 | 37 | // MTE2 |
| 38 | MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), params...); | 38 | MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), params...); |
| 39 | } | 39 | } |
| 40 | + | ||
| 40 | private: | 41 | private: |
| 41 | template <typename T, typename U, typename S> | 42 | template <typename T, typename U, typename S> |
| 42 | - __aicore__ inline static void MmadImpl(__cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint16_t m, uint16_t k, uint16_t n, | 43 | + __aicore__ inline static void MmadImpl( |
| 43 | - uint8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) { | 44 | + __cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint16_t m, uint16_t k, uint16_t n, uint8_t unitFlag, |
| 45 | + bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) | ||
| 46 | + { | ||
| 44 | if ASCEND_IS_AIV { | 47 | if ASCEND_IS_AIV { |
| 45 | return; | 48 | return; |
| 46 | } | 49 | } |
| @@ -53,16 +56,21 @@ private: | |||
| 53 | class MmadBiasInstr { | 56 | class MmadBiasInstr { |
| 54 | public: | 57 | public: |
| 55 | template <typename T, typename U, typename S, typename V, typename... Params> | 58 | template <typename T, typename U, typename S, typename V, typename... Params> |
| 56 | - __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const V& bias, const Params& ...params) | 59 | + __aicore__ inline static void Mmad( |
| 60 | + const T& dst, const U& fm, const S& filter, const V& bias, const Params&... params) | ||
| 57 | { | 61 | { |
| 58 | // MTE2 | 62 | // MTE2 |
| 59 | - MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), | 63 | + MmadImpl( |
| 60 | - reinterpret_cast<uint64_t>(bias.Data().Get()), params...); | 64 | + dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), reinterpret_cast<uint64_t>(bias.Data().Get()), |
| 65 | + params...); | ||
| 61 | } | 66 | } |
| 67 | + | ||
| 62 | private: | 68 | private: |
| 63 | template <typename T, typename U, typename S> | 69 | template <typename T, typename U, typename S> |
| 64 | - __aicore__ inline static void MmadImpl(__cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint64_t bias, uint16_t m, uint16_t k, uint16_t n, | 70 | + __aicore__ inline static void MmadImpl( |
| 65 | - int8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) { | 71 | + __cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint64_t bias, uint16_t m, uint16_t k, uint16_t n, |
| 72 | + int8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) | ||
| 73 | + { | ||
| 66 | if ASCEND_IS_AIV { | 74 | if ASCEND_IS_AIV { |
| 67 | return; | 75 | return; |
| 68 | } | 76 | } |
| @@ -77,15 +85,18 @@ private: | |||
| 77 | class MmadMxInstr { | 85 | class MmadMxInstr { |
| 78 | public: | 86 | public: |
| 79 | template <typename T, typename U, typename S, typename... Params> | 87 | template <typename T, typename U, typename S, typename... Params> |
| 80 | - __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const Params& ...params) | 88 | + __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const Params&... params) |
| 81 | { | 89 | { |
| 82 | // MTE2 | 90 | // MTE2 |
| 83 | MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), params...); | 91 | MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), params...); |
| 84 | } | 92 | } |
| 93 | + | ||
| 85 | private: | 94 | private: |
| 86 | template <typename T, typename U, typename S> | 95 | template <typename T, typename U, typename S> |
| 87 | - __aicore__ inline static void MmadImpl(__cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint16_t m, uint16_t k, uint16_t n, | 96 | + __aicore__ inline static void MmadImpl( |
| 88 | - uint8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) { | 97 | + __cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint16_t m, uint16_t k, uint16_t n, uint8_t unitFlag, |
| 98 | + bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) | ||
| 99 | + { | ||
| 89 | if ASCEND_IS_AIV { | 100 | if ASCEND_IS_AIV { |
| 90 | return; | 101 | return; |
| 91 | } | 102 | } |
| @@ -98,16 +109,21 @@ private: | |||
| 98 | class MmadMxBiasInstr { | 109 | class MmadMxBiasInstr { |
| 99 | public: | 110 | public: |
| 100 | template <typename T, typename U, typename S, typename V, typename... Params> | 111 | template <typename T, typename U, typename S, typename V, typename... Params> |
| 101 | - __aicore__ inline static void Mmad(const T& dst, const U& fm, const S& filter, const V& bias, const Params& ...params) | 112 | + __aicore__ inline static void Mmad( |
| 113 | + const T& dst, const U& fm, const S& filter, const V& bias, const Params&... params) | ||
| 102 | { | 114 | { |
| 103 | // MTE2 | 115 | // MTE2 |
| 104 | - MmadImpl(dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), | 116 | + MmadImpl( |
| 105 | - reinterpret_cast<uint64_t>(bias.Data().Get()), params...); | 117 | + dst.Data().Get(), fm.Data().Get(), filter.Data().Get(), reinterpret_cast<uint64_t>(bias.Data().Get()), |
| 118 | + params...); | ||
| 106 | } | 119 | } |
| 120 | + | ||
| 107 | private: | 121 | private: |
| 108 | template <typename T, typename U, typename S> | 122 | template <typename T, typename U, typename S> |
| 109 | - __aicore__ inline static void MmadImpl(__cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint64_t bias, uint16_t m, uint16_t k, uint16_t n, | 123 | + __aicore__ inline static void MmadImpl( |
| 110 | - int8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) { | 124 | + __cc__ T* dst, __ca__ U* fm, __cb__ S* filter, uint64_t bias, uint16_t m, uint16_t k, uint16_t n, |
| 125 | + int8_t unitFlag, bool disableGemv, bool cmatrixSource, bool cmatrixInitVal) | ||
| 126 | + { | ||
| 111 | if ASCEND_IS_AIV { | 127 | if ASCEND_IS_AIV { |
| 112 | return; | 128 | return; |
| 113 | } | 129 | } |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/mmad.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/mmad.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -29,9 +29,9 @@ namespace Te { | |||
| 29 | 29 | ||
| 30 | class MmadNoBiasDetails { | 30 | class MmadNoBiasDetails { |
| 31 | public: | 31 | public: |
| 32 | - template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> | 32 | + template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& fm, const S& filter, const Params& params) | 33 | + __aicore__ inline static void Run(const T& dst, const U& fm, const S& filter, const Params& params) |
| 34 | - { | 34 | + { |
| 35 | MmadImpl<trait, T, U, S>(dst, fm, filter, params); | 35 | MmadImpl<trait, T, U, S>(dst, fm, filter, params); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -53,18 +53,20 @@ private: | |||
| 53 | CheckFormat::CheckZNTemplate<S>(); | 53 | CheckFormat::CheckZNTemplate<S>(); |
| 54 | CheckDataTypeFor3510::CheckMxMmadDataType<T, U, S>(); | 54 | CheckDataTypeFor3510::CheckMxMmadDataType<T, U, S>(); |
| 55 | } | 55 | } |
| 56 | - | 56 | + |
| 57 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> | 57 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> |
| 58 | __aicore__ inline static void MmadImpl(const T& dst, const U& fm, const S& filter, const Params& params) | 58 | __aicore__ inline static void MmadImpl(const T& dst, const U& fm, const S& filter, const Params& params) |
| 59 | { | 59 | { |
| 60 | if constexpr (trait.mmadType == MmadType::NORMAL) { | 60 | if constexpr (trait.mmadType == MmadType::NORMAL) { |
| 61 | CheckTemplateForNormal<trait, T, U, S>(); | 61 | CheckTemplateForNormal<trait, T, U, S>(); |
| 62 | - MmadInstr::Mmad(dst, fm, filter, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, trait.cmatrixSource, | 62 | + MmadInstr::Mmad( |
| 63 | - params.cmatrixInitVal); | 63 | + dst, fm, filter, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, trait.cmatrixSource, |
| 64 | + params.cmatrixInitVal); | ||
| 64 | } else if constexpr (trait.mmadType == MmadType::MX) { | 65 | } else if constexpr (trait.mmadType == MmadType::MX) { |
| 65 | CheckTemplateForMx<trait, T, U, S>(); | 66 | CheckTemplateForMx<trait, T, U, S>(); |
| 66 | - MmadMxInstr::Mmad(dst, fm, filter, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, trait.cmatrixSource, | 67 | + MmadMxInstr::Mmad( |
| 67 | - params.cmatrixInitVal); | 68 | + dst, fm, filter, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, trait.cmatrixSource, |
| 69 | + params.cmatrixInitVal); | ||
| 68 | } | 70 | } |
| 69 | } | 71 | } |
| 70 | }; | 72 | }; |
| @@ -72,14 +74,15 @@ private: | |||
| 72 | class Mmad3510 { | 74 | class Mmad3510 { |
| 73 | public: | 75 | public: |
| 74 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> | 76 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> |
| 75 | - __aicore__ inline void Run(const T& dst, const U& fm, const S& filter, const Params& params) | 77 | + __aicore__ inline void Run(const T& dst, const U& fm, const S& filter, const Params& params) |
| 76 | - { | 78 | + { |
| 77 | Execute<trait, T, U, S>(dst, fm, filter, params); | 79 | Execute<trait, T, U, S>(dst, fm, filter, params); |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | private: | 82 | private: |
| 81 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> | 83 | template <const MmadTrait& trait, typename T, typename U, typename S, typename Params> |
| 82 | - __aicore__ inline void Execute(const T& dst, const U& fm, const S& filter, const Params& params) { | 84 | + __aicore__ inline void Execute(const T& dst, const U& fm, const S& filter, const Params& params) |
| 85 | + { | ||
| 83 | MmadNoBiasDetails::Run<trait, T, U, S>(dst, fm, filter, params); | 86 | MmadNoBiasDetails::Run<trait, T, U, S>(dst, fm, filter, params); |
| 84 | } | 87 | } |
| 85 | }; | 88 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/mmad_with_bias.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_compute/mmad/npu_arch_3510/mmad_with_bias.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -29,8 +29,8 @@ namespace Te { | |||
| 29 | 29 | ||
| 30 | class MmadWithBias { | 30 | class MmadWithBias { |
| 31 | public: | 31 | public: |
| 32 | - template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> | 32 | + template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) | 33 | + __aicore__ inline static void Run(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) |
| 34 | { | 34 | { |
| 35 | MmadImpl<trait, T, U, S, V>(dst, fm, filter, bias, params); | 35 | MmadImpl<trait, T, U, S, V>(dst, fm, filter, bias, params); |
| 36 | } | 36 | } |
| @@ -52,12 +52,13 @@ private: | |||
| 52 | CheckFormat::CheckL0CNZTemplate<T>(); | 52 | CheckFormat::CheckL0CNZTemplate<T>(); |
| 53 | CheckFormat::CheckNZTemplate<U>(); | 53 | CheckFormat::CheckNZTemplate<U>(); |
| 54 | CheckFormat::CheckZNTemplate<S>(); | 54 | CheckFormat::CheckZNTemplate<S>(); |
| 55 | - CheckFormat::CheckNDTemplate<V>(); | 55 | + CheckFormat::CheckNDTemplate<V>(); |
| 56 | CheckDataTypeFor3510::CheckMxMmadBiasDataType<T, U, S, V>(); | 56 | CheckDataTypeFor3510::CheckMxMmadBiasDataType<T, U, S, V>(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> | 59 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> |
| 60 | - __aicore__ inline static void MmadImpl(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) | 60 | + __aicore__ inline static void MmadImpl( |
| 61 | + const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) | ||
| 61 | { | 62 | { |
| 62 | if constexpr (trait.mmadType == MmadType::NORMAL) { | 63 | if constexpr (trait.mmadType == MmadType::NORMAL) { |
| 63 | CheckTemplateForNormal<trait, T, U, S, V>(); | 64 | CheckTemplateForNormal<trait, T, U, S, V>(); |
| @@ -72,11 +73,13 @@ private: | |||
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | if constexpr (trait.mmadType == MmadType::NORMAL) { | 75 | if constexpr (trait.mmadType == MmadType::NORMAL) { |
| 75 | - MmadBiasInstr::Mmad(dst, fm, filter, bias, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, cmatrixSource, | 76 | + MmadBiasInstr::Mmad( |
| 76 | - false); | 77 | + dst, fm, filter, bias, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, cmatrixSource, |
| 78 | + false); | ||
| 77 | } else if constexpr (trait.mmadType == MmadType::MX) { | 79 | } else if constexpr (trait.mmadType == MmadType::MX) { |
| 78 | - MmadMxBiasInstr::Mmad(dst, fm, filter, bias, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, cmatrixSource, | 80 | + MmadMxBiasInstr::Mmad( |
| 79 | - false); | 81 | + dst, fm, filter, bias, params.m, params.k, params.n, params.unitFlag, trait.disableGemv, cmatrixSource, |
| 82 | + false); | ||
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| 82 | }; | 85 | }; |
| @@ -84,14 +87,15 @@ private: | |||
| 84 | class MmadWithBias3510 { | 87 | class MmadWithBias3510 { |
| 85 | public: | 88 | public: |
| 86 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> | 89 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> |
| 87 | - __aicore__ inline void Run(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) | 90 | + __aicore__ inline void Run(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) |
| 88 | { | 91 | { |
| 89 | Execute<trait, T, U, S, V, Params>(dst, fm, filter, bias, params); | 92 | Execute<trait, T, U, S, V, Params>(dst, fm, filter, bias, params); |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | private: | 95 | private: |
| 93 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> | 96 | template <const MmadTrait& trait, typename T, typename U, typename S, typename V, typename Params> |
| 94 | - __aicore__ inline void Execute(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) { | 97 | + __aicore__ inline void Execute(const T& dst, const U& fm, const S& filter, const V& bias, const Params& params) |
| 98 | + { | ||
| 95 | MmadWithBias::Run<trait, T, U, S, V>(dst, fm, filter, bias, params); | 99 | MmadWithBias::Run<trait, T, U, S, V>(dst, fm, filter, bias, params); |
| 96 | } | 100 | } |
| 97 | }; | 101 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/data_copy/data_copy_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/data_copy_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -36,19 +36,18 @@ template <typename T, typename U, typename Coord> | |||
| 36 | constexpr bool VerifyingDataCopyTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingDataCopyTemplate<T, U>; | 36 | constexpr bool VerifyingDataCopyTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingDataCopyTemplate<T, U>; |
| 37 | 37 | ||
| 38 | template <const DataCopyTrait& trait = DEFAULT_DATA_COPY_TRAIT, typename T, typename U> | 38 | template <const DataCopyTrait& trait = DEFAULT_DATA_COPY_TRAIT, typename T, typename U> |
| 39 | -__aicore__ inline typename Std::enable_if<VerifyingDataCopyTemplate<T, U>, void>::type | 39 | +__aicore__ inline typename Std::enable_if<VerifyingDataCopyTemplate<T, U>, void>::type DataCopy( |
| 40 | -DataCopy(const T& dst, const U& src) | 40 | + const T& dst, const U& src) |
| 41 | { | 41 | { |
| 42 | constexpr Hardware dstTPos = GetHardPos<T>(); | 42 | constexpr Hardware dstTPos = GetHardPos<T>(); |
| 43 | constexpr Hardware srcTPos = GetHardPos<U>(); | 43 | constexpr Hardware srcTPos = GetHardPos<U>(); |
| 44 | - using Tensor2Tensor = typename | 44 | + using Tensor2Tensor = typename DataCopyTensor2Tensor<dstTPos, srcTPos, CURRENT_ARCH_VERSION>::type; |
| 45 | - DataCopyTensor2Tensor<dstTPos, srcTPos, CURRENT_ARCH_VERSION>::type; | ||
| 46 | Tensor2Tensor{}.template Run<trait, T, U>(dst, src); | 45 | Tensor2Tensor{}.template Run<trait, T, U>(dst, src); |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | template <const DataCopyTrait& trait = DEFAULT_DATA_COPY_TRAIT, typename T, typename U, typename Coord> | 48 | template <const DataCopyTrait& trait = DEFAULT_DATA_COPY_TRAIT, typename T, typename U, typename Coord> |
| 50 | -__aicore__ inline typename Std::enable_if<VerifyingDataCopyTemplateWithCoord<T, U, Coord>, void>::type | 49 | +__aicore__ inline typename Std::enable_if<VerifyingDataCopyTemplateWithCoord<T, U, Coord>, void>::type DataCopy( |
| 51 | -DataCopy(const T& dst, const U& src, const Coord& coord) | 50 | + const T& dst, const U& src, const Coord& coord) |
| 52 | { | 51 | { |
| 53 | auto sliceTensor = src(coord, dst); | 52 | auto sliceTensor = src(coord, dst); |
| 54 | DataCopy<trait, T, decltype(sliceTensor)>(dst, sliceTensor); | 53 | DataCopy<trait, T, decltype(sliceTensor)>(dst, sliceTensor); |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/data_copy/data_copy_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/data_copy_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -31,8 +31,9 @@ namespace Te { | |||
| 31 | 31 | ||
| 32 | class DataCopyIgnore { | 32 | class DataCopyIgnore { |
| 33 | public: | 33 | public: |
| 34 | - template <const DataCopyTrait& trait, typename ...Args> | 34 | + template <const DataCopyTrait& trait, typename... Args> |
| 35 | - __aicore__ inline void Run(const Args&... args) {} | 35 | + __aicore__ inline void Run(const Args&... args) |
| 36 | + {} | ||
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | template <Hardware dstTPos, Hardware srcTpos, uint32_t Version> | 39 | template <Hardware dstTPos, Hardware srcTpos, uint32_t Version> |
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2nn.h+5-3
| @@ -46,11 +46,13 @@ private: | |||
| 46 | 46 | ||
| 47 | auto srcRowShape = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout); | 47 | auto srcRowShape = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout); |
| 48 | uint32_t srcColShape = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout); | 48 | uint32_t srcColShape = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout); |
| 49 | - uint16_t srcBColStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout); | 49 | + uint16_t srcBColStride = |
| 50 | - uint16_t dstBColStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 50 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout); |
| 51 | + uint16_t dstBColStride = | ||
| 52 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | ||
| 51 | 53 | ||
| 52 | uint16_t dnNum = 1; | 54 | uint16_t dnNum = 1; |
| 53 | - uint16_t nValue = srcRowShape >> 1; // use b16 for DN2NZ, so nValue = srcRowShape / 2 | 55 | + uint16_t nValue = srcRowShape >> 1; // use b16 for DN2NZ, so nValue = srcRowShape / 2 |
| 54 | uint16_t dValue = srcColShape; | 56 | uint16_t dValue = srcColShape; |
| 55 | uint16_t dstNzNStride = 1; | 57 | uint16_t dstNzNStride = 1; |
| 56 | 58 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2nz.h+4-4
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -80,8 +79,9 @@ private: | |||
| 80 | 79 | ||
| 81 | uint8_t cacheMode = GetCacheModeFromTensor(src); | 80 | uint8_t cacheMode = GetCacheModeFromTensor(src); |
| 82 | 81 | ||
| 83 | - CopyGmToCbufMultiDn2nzInstr::DataCopy(dst, src, dnNum, loop2DstStride, loop3DstStride, loop4DstStride, | 82 | + CopyGmToCbufMultiDn2nzInstr::DataCopy( |
| 84 | - loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, false); | 83 | + dst, src, dnNum, loop2DstStride, loop3DstStride, loop4DstStride, loop1SrcStride, cacheMode, nValue, dValue, |
| 84 | + loop4SrcStride, false); | ||
| 85 | } | 85 | } |
| 86 | }; | 86 | }; |
| 87 | 87 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zn.h+18-15
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,20 +30,23 @@ namespace Te { | |||
| 31 | class CopyGmToCbufMultiDN2Zn { | 30 | class CopyGmToCbufMultiDN2Zn { |
| 32 | public: | 31 | public: |
| 33 | template <const DataCopyTrait& trait, typename T, typename U> | 32 | template <const DataCopyTrait& trait, typename T, typename U> |
| 34 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 35 | DataCopyImpl<trait>(dst, src); | 35 | DataCopyImpl<trait>(dst, src); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | private: | 38 | private: |
| 39 | template <const DataCopyTrait& trait, typename T, typename U> | 39 | template <const DataCopyTrait& trait, typename T, typename U> |
| 40 | - __aicore__ inline static constexpr void CheckTemplate() { | 40 | + __aicore__ inline static constexpr void CheckTemplate() |
| 41 | + { | ||
| 41 | CheckFormat::CheckDNTemplate<U>(); | 42 | CheckFormat::CheckDNTemplate<U>(); |
| 42 | CheckFormat::CheckZNTemplate<T>(); | 43 | CheckFormat::CheckZNTemplate<T>(); |
| 43 | CheckDataTypeFor3510::CheckGm2L1Fp4DataType<T, U>(); | 44 | CheckDataTypeFor3510::CheckGm2L1Fp4DataType<T, U>(); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | template <const DataCopyTrait& trait, typename T, typename U> | 47 | template <const DataCopyTrait& trait, typename T, typename U> |
| 47 | - __aicore__ inline static void DataCopyImpl(const T& dst, const U& src) { | 48 | + __aicore__ inline static void DataCopyImpl(const T& dst, const U& src) |
| 49 | + { | ||
| 48 | CheckTemplate<trait, T, U>(); | 50 | CheckTemplate<trait, T, U>(); |
| 49 | 51 | ||
| 50 | using type = typename U::elementType; | 52 | using type = typename U::elementType; |
| @@ -78,8 +80,9 @@ private: | |||
| 78 | 80 | ||
| 79 | uint8_t cacheMode = GetCacheModeFromTensor(src); | 81 | uint8_t cacheMode = GetCacheModeFromTensor(src); |
| 80 | 82 | ||
| 81 | - CopyGmToCbufMultiNd2nzInstr::DataCopy(dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, | 83 | + CopyGmToCbufMultiNd2nzInstr::DataCopy( |
| 82 | - loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, false); | 84 | + dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, loop1SrcStride, cacheMode, nValue, dValue, |
| 85 | + loop4SrcStride, false); | ||
| 83 | } | 86 | } |
| 84 | }; | 87 | }; |
| 85 | 88 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zz.h+1-2
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/dn2zz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nd.h+5-7
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -78,9 +77,8 @@ private: | |||
| 78 | uint8_t leftPaddingCnt = 0; | 77 | uint8_t leftPaddingCnt = 0; |
| 79 | uint8_t rightPaddingCnt = padCount; | 78 | uint8_t rightPaddingCnt = padCount; |
| 80 | 79 | ||
| 81 | - if ((srcShapeRows == 1) || (srcShapeColumns == 1) | 80 | + if ((srcShapeRows == 1) || (srcShapeColumns == 1) || |
| 82 | - || (srcStrideRows == srcShapeColumns && dstStrideRows == dstShapeColumns | 81 | + (srcStrideRows == srcShapeColumns && dstStrideRows == dstShapeColumns && srcStrideRows == dstStrideRows)) { |
| 83 | - && srcStrideRows == dstStrideRows)) { | ||
| 84 | // compact mode | 82 | // compact mode |
| 85 | blockCount = 1; | 83 | blockCount = 1; |
| 86 | // must use srcShape, there is a scenario of small to large, using dstShape will cause src out of bound | 84 | // must use srcShape, there is a scenario of small to large, using dstShape will cause src out of bound |
| @@ -90,8 +88,8 @@ private: | |||
| 90 | srcStride = 0; | 88 | srcStride = 0; |
| 91 | dstStride = blockLen; | 89 | dstStride = blockLen; |
| 92 | } | 90 | } |
| 93 | - CopyGmToCbufAlignV2Base::DataCopy(dst, src, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, cacheMode, | 91 | + CopyGmToCbufAlignV2Base::DataCopy( |
| 94 | - srcStride, dstStride); | 92 | + dst, src, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, cacheMode, srcStride, dstStride); |
| 95 | } | 93 | } |
| 96 | }; | 94 | }; |
| 97 | } // namespace Te | 95 | } // namespace Te |
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nz.h+16-15
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,7 +30,8 @@ namespace Te { | |||
| 31 | class CopyGmToCbufMultiND2Nz { | 30 | class CopyGmToCbufMultiND2Nz { |
| 32 | public: | 31 | public: |
| 33 | template <const DataCopyTrait& trait, typename T, typename U> | 32 | template <const DataCopyTrait& trait, typename T, typename U> |
| 34 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 35 | DataCopyImpl<trait>(dst, src); | 35 | DataCopyImpl<trait>(dst, src); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -79,13 +79,14 @@ private: | |||
| 79 | uint16_t loop4DstStride = static_cast<uint16_t>(dstNzMatrixStride / C0_ELEMENT<type>); | 79 | uint16_t loop4DstStride = static_cast<uint16_t>(dstNzMatrixStride / C0_ELEMENT<type>); |
| 80 | uint8_t cacheMode = GetCacheModeFromTensor(src); | 80 | uint8_t cacheMode = GetCacheModeFromTensor(src); |
| 81 | 81 | ||
| 82 | - CopyGmToCbufMultiNd2nzInstr::DataCopy(dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, | 82 | + CopyGmToCbufMultiNd2nzInstr::DataCopy( |
| 83 | - loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, false); | 83 | + dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, loop1SrcStride, cacheMode, nValue, dValue, |
| 84 | + loop4SrcStride, false); | ||
| 84 | } | 85 | } |
| 85 | }; | 86 | }; |
| 86 | 87 | ||
| 87 | -} | 88 | +} // namespace Te |
| 88 | -} | 89 | +} // namespace AscendC |
| 89 | 90 | ||
| 90 | 91 | ||
| 91 | 92 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zn.h+16-15
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,7 +30,8 @@ namespace Te { | |||
| 31 | class CopyGmToCbufMultiND2Zn { | 30 | class CopyGmToCbufMultiND2Zn { |
| 32 | public: | 31 | public: |
| 33 | template <const DataCopyTrait& trait, typename T, typename U> | 32 | template <const DataCopyTrait& trait, typename T, typename U> |
| 34 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 35 | DataCopyImpl<trait>(dst, src); | 35 | DataCopyImpl<trait>(dst, src); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -78,13 +78,14 @@ private: | |||
| 78 | 78 | ||
| 79 | uint8_t cacheMode = GetCacheModeFromTensor(src); | 79 | uint8_t cacheMode = GetCacheModeFromTensor(src); |
| 80 | 80 | ||
| 81 | - CopyGmToCbufMultiDn2nzInstr::DataCopy(dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, | 81 | + CopyGmToCbufMultiDn2nzInstr::DataCopy( |
| 82 | - loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, false); | 82 | + dst, src, ndNum, loop2DstStride, loop3DstStride, loop4DstStride, loop1SrcStride, cacheMode, nValue, dValue, |
| 83 | + loop4SrcStride, false); | ||
| 83 | } | 84 | } |
| 84 | }; | 85 | }; |
| 85 | 86 | ||
| 86 | -} | 87 | +} // namespace Te |
| 87 | -} | 88 | +} // namespace AscendC |
| 88 | 89 | ||
| 89 | 90 | ||
| 90 | 91 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zz.h+1-2
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nd2zz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nn2nn.h+3-3
| @@ -63,9 +63,9 @@ private: | |||
| 63 | 63 | ||
| 64 | uint8_t leftPaddingCnt = 0; | 64 | uint8_t leftPaddingCnt = 0; |
| 65 | uint8_t rightPaddingCnt = 0; | 65 | uint8_t rightPaddingCnt = 0; |
| 66 | - CopyGmToCbufAlignV2Base::CopyGmToCbufAlignV2((__cbuf__ half*)(dst.Data().Get()), | 66 | + CopyGmToCbufAlignV2Base::CopyGmToCbufAlignV2( |
| 67 | - (__gm__ half*)(src.Data().Get()), blockCount, blockLen, | 67 | + (__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), blockCount, blockLen, leftPaddingCnt, |
| 68 | - leftPaddingCnt, rightPaddingCnt, cacheMode, srcStride, dstStride); | 68 | + rightPaddingCnt, cacheMode, srcStride, dstStride); |
| 69 | } | 69 | } |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nz2nz.h+5-6
| @@ -8,9 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | - | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -55,8 +54,8 @@ private: | |||
| 55 | 54 | ||
| 56 | using type = typename U::elementType; | 55 | using type = typename U::elementType; |
| 57 | 56 | ||
| 58 | - auto smallFractalSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) | 57 | + auto smallFractalSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 59 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout); | 58 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout); |
| 60 | auto bigFractalSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout); | 59 | auto bigFractalSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout); |
| 61 | auto srcStrideSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout); | 60 | auto srcStrideSize = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout); |
| 62 | auto dstStrideSize = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 61 | auto dstStrideSize = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| @@ -70,8 +69,8 @@ private: | |||
| 70 | auto srcStride = srcStrideSize * sizeof(type); | 69 | auto srcStride = srcStrideSize * sizeof(type); |
| 71 | auto dstStride = dstStrideSize * sizeof(type); | 70 | auto dstStride = dstStrideSize * sizeof(type); |
| 72 | 71 | ||
| 73 | - CopyGmToCbufAlignV2Base::DataCopy(dst, src, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, cacheMode, | 72 | + CopyGmToCbufAlignV2Base::DataCopy( |
| 74 | - srcStride, dstStride); | 73 | + dst, src, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, cacheMode, srcStride, dstStride); |
| 75 | } | 74 | } |
| 76 | }; | 75 | }; |
| 77 | } // namespace Te | 76 | } // namespace Te |
Mimpl/experimental/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_gm2l1/zz2zz.h+3-3
| @@ -65,9 +65,9 @@ private: | |||
| 65 | 65 | ||
| 66 | uint8_t leftPaddingCnt = 0; | 66 | uint8_t leftPaddingCnt = 0; |
| 67 | uint8_t rightPaddingCnt = 0; | 67 | uint8_t rightPaddingCnt = 0; |
| 68 | - CopyGmToCbufAlignV2Base::CopyGmToCbufAlignV2((__cbuf__ half*)(dst.Data().Get()), | 68 | + CopyGmToCbufAlignV2Base::CopyGmToCbufAlignV2( |
| 69 | - (__gm__ half*)(src.Data().Get()), blockCount, blockLen, | 69 | + (__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), blockCount, blockLen, leftPaddingCnt, |
| 70 | - leftPaddingCnt, rightPaddingCnt, cacheMode, srcStride, dstStride); | 70 | + rightPaddingCnt, cacheMode, srcStride, dstStride); |
| 71 | } | 71 | } |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_l12bt.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_l12bt.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,7 +30,8 @@ namespace Te { | |||
| 31 | class DataCopyL12BT3510 { | 30 | class DataCopyL12BT3510 { |
| 32 | public: | 31 | public: |
| 33 | template <const DataCopyTrait& trait, typename T, typename U> | 32 | template <const DataCopyTrait& trait, typename T, typename U> |
| 34 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 35 | DataCopyImpl<trait, T, U>(dst, src); | 35 | DataCopyImpl<trait, T, U>(dst, src); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_l12fb.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/data_copy_l12fb.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,7 +30,8 @@ namespace Te { | |||
| 31 | class DataCopyL12FB3510 { | 30 | class DataCopyL12FB3510 { |
| 32 | public: | 31 | public: |
| 33 | template <const DataCopyTrait& trait, typename T, typename U> | 32 | template <const DataCopyTrait& trait, typename T, typename U> |
| 34 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 35 | DataCopyImpl<trait, T, U>(dst, src); | 35 | DataCopyImpl<trait, T, U>(dst, src); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -1,16 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | - | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | -#warning \ | 12 | +#warning \ |
| 14 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/data_copy/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 15 | 14 | ||
| 16 | 15 | ||
| @@ -31,7 +30,8 @@ namespace AscendC { | |||
| 31 | namespace Te { | 30 | namespace Te { |
| 32 | 31 | ||
| 33 | template <typename T> | 32 | template <typename T> |
| 34 | -__aicore__ inline void SetMTE2NzPara(const T& para) { | 33 | +__aicore__ inline void SetMTE2NzPara(const T& para) |
| 34 | +{ | ||
| 35 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { | 35 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { |
| 36 | set_mte2_nz_para(para); | 36 | set_mte2_nz_para(para); |
| 37 | } | 37 | } |
| @@ -40,29 +40,34 @@ __aicore__ inline void SetMTE2NzPara(const T& para) { | |||
| 40 | class CopyGmToCbufAlignV2Base { | 40 | class CopyGmToCbufAlignV2Base { |
| 41 | public: | 41 | public: |
| 42 | template <typename T, typename U, typename... Params> | 42 | template <typename T, typename U, typename... Params> |
| 43 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) { | 43 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 44 | + { | ||
| 44 | using srcType = typename U::elementType; | 45 | using srcType = typename U::elementType; |
| 45 | - if constexpr(sizeof(srcType) == sizeof(int8_t)) { | 46 | + if constexpr (sizeof(srcType) == sizeof(int8_t)) { |
| 46 | CopyGmToCbufAlignV2((__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); | 47 | CopyGmToCbufAlignV2((__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); |
| 47 | } else if constexpr (sizeof(srcType) == sizeof(half)) { | 48 | } else if constexpr (sizeof(srcType) == sizeof(half)) { |
| 48 | CopyGmToCbufAlignV2((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); | 49 | CopyGmToCbufAlignV2((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); |
| 49 | } else if constexpr (sizeof(srcType) == sizeof(float)) { | 50 | } else if constexpr (sizeof(srcType) == sizeof(float)) { |
| 50 | CopyGmToCbufAlignV2((__cbuf__ float*)(dst.Data().Get()), (__gm__ float*)(src.Data().Get()), params...); | 51 | CopyGmToCbufAlignV2((__cbuf__ float*)(dst.Data().Get()), (__gm__ float*)(src.Data().Get()), params...); |
| 51 | } else if constexpr (sizeof(srcType) == sizeof(uint64_t)) { | 52 | } else if constexpr (sizeof(srcType) == sizeof(uint64_t)) { |
| 52 | - CopyGmToCbufAlignV2((__cbuf__ uint32_t*)(dst.Data().Get()), (__gm__ uint32_t*)(src.Data().Get()), params...); | 53 | + CopyGmToCbufAlignV2( |
| 53 | - } | 54 | + (__cbuf__ uint32_t*)(dst.Data().Get()), (__gm__ uint32_t*)(src.Data().Get()), params...); |
| 55 | + } | ||
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | template <typename T> | 58 | template <typename T> |
| 57 | - __aicore__ inline static void CopyGmToCbufAlignV2(__cbuf__ T* dst, __gm__ T* src, uint32_t blockCount, uint32_t blockLen, | 59 | + __aicore__ inline static void CopyGmToCbufAlignV2( |
| 58 | - uint8_t leftPaddingCnt, uint8_t rightPaddingCnt, uint8_t cacheMode, uint64_t srcStride, uint32_t dstStride) { | 60 | + __cbuf__ T* dst, __gm__ T* src, uint32_t blockCount, uint32_t blockLen, uint8_t leftPaddingCnt, |
| 61 | + uint8_t rightPaddingCnt, uint8_t cacheMode, uint64_t srcStride, uint32_t dstStride) | ||
| 62 | + { | ||
| 59 | if ASCEND_IS_AIV { | 63 | if ASCEND_IS_AIV { |
| 60 | return; | 64 | return; |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 63 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { | 67 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { |
| 64 | - copy_gm_to_cbuf_align_v2(dst, src, 0, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, true, | 68 | + copy_gm_to_cbuf_align_v2( |
| 65 | - cacheMode, srcStride, dstStride); | 69 | + dst, src, 0, blockCount, blockLen, leftPaddingCnt, rightPaddingCnt, true, cacheMode, srcStride, |
| 70 | + dstStride); | ||
| 66 | } | 71 | } |
| 67 | } | 72 | } |
| 68 | }; | 73 | }; |
| @@ -70,10 +75,12 @@ public: | |||
| 70 | class CopyGmToCbufMultiNd2nzInstr { | 75 | class CopyGmToCbufMultiNd2nzInstr { |
| 71 | public: | 76 | public: |
| 72 | template <typename T, typename U, typename... Params> | 77 | template <typename T, typename U, typename... Params> |
| 73 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) { | 78 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 79 | + { | ||
| 74 | using srcType = typename U::elementType; | 80 | using srcType = typename U::elementType; |
| 75 | - if constexpr(sizeof(srcType) == sizeof(int8_t)) { | 81 | + if constexpr (sizeof(srcType) == sizeof(int8_t)) { |
| 76 | - CopyGmToCbufMultiNd2nz((__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); | 82 | + CopyGmToCbufMultiNd2nz( |
| 83 | + (__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); | ||
| 77 | } else if constexpr (sizeof(srcType) == sizeof(half)) { | 84 | } else if constexpr (sizeof(srcType) == sizeof(half)) { |
| 78 | CopyGmToCbufMultiNd2nz((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); | 85 | CopyGmToCbufMultiNd2nz((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); |
| 79 | } else if constexpr (sizeof(srcType) == sizeof(float)) { | 86 | } else if constexpr (sizeof(srcType) == sizeof(float)) { |
| @@ -82,9 +89,10 @@ public: | |||
| 82 | } | 89 | } |
| 83 | 90 | ||
| 84 | template <typename T> | 91 | template <typename T> |
| 85 | - __aicore__ inline static void CopyGmToCbufMultiNd2nz(__cbuf__ T* dst, __gm__ T* src, uint16_t ndNum, uint16_t loop2DstStride, | 92 | + __aicore__ inline static void CopyGmToCbufMultiNd2nz( |
| 86 | - uint16_t loop3DstStride, uint16_t loop4DstStride, uint64_t loop1SrcStride, uint8_t cacheMode, uint16_t nValue, | 93 | + __cbuf__ T* dst, __gm__ T* src, uint16_t ndNum, uint16_t loop2DstStride, uint16_t loop3DstStride, |
| 87 | - uint32_t dValue, uint64_t loop4SrcStride, bool enableSmallC0) | 94 | + uint16_t loop4DstStride, uint64_t loop1SrcStride, uint8_t cacheMode, uint16_t nValue, uint32_t dValue, |
| 95 | + uint64_t loop4SrcStride, bool enableSmallC0) | ||
| 88 | { | 96 | { |
| 89 | if ASCEND_IS_AIV { | 97 | if ASCEND_IS_AIV { |
| 90 | return; | 98 | return; |
| @@ -93,9 +101,10 @@ public: | |||
| 93 | uint64_t mte2NzPara = static_cast<uint64_t>(loop4DstStride) << 48; // MTE2_NZ_PARA[63:48] | 101 | uint64_t mte2NzPara = static_cast<uint64_t>(loop4DstStride) << 48; // MTE2_NZ_PARA[63:48] |
| 94 | mte2NzPara |= static_cast<uint64_t>(loop3DstStride) << 32; // MTE2_NZ_PARA[47:32] | 102 | mte2NzPara |= static_cast<uint64_t>(loop3DstStride) << 32; // MTE2_NZ_PARA[47:32] |
| 95 | mte2NzPara |= static_cast<uint64_t>(loop2DstStride) << 16; // MTE2_NZ_PARA[31:16] | 103 | mte2NzPara |= static_cast<uint64_t>(loop2DstStride) << 16; // MTE2_NZ_PARA[31:16] |
| 96 | - mte2NzPara |= static_cast<uint64_t>(ndNum); // MTE2_NZ_PARA[15:0] | 104 | + mte2NzPara |= static_cast<uint64_t>(ndNum); // MTE2_NZ_PARA[15:0] |
| 97 | - SetMTE2NzPara(mte2NzPara); // CCE: store parameters for ND2NZ DMA instructions | 105 | + SetMTE2NzPara(mte2NzPara); // CCE: store parameters for ND2NZ DMA instructions |
| 98 | - copy_gm_to_cbuf_multi_nd2nz(dst, src, 0, loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, enableSmallC0); | 106 | + copy_gm_to_cbuf_multi_nd2nz( |
| 107 | + dst, src, 0, loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, enableSmallC0); | ||
| 99 | } | 108 | } |
| 100 | } | 109 | } |
| 101 | }; | 110 | }; |
| @@ -103,10 +112,12 @@ public: | |||
| 103 | class CopyGmToCbufMultiDn2nzInstr { | 112 | class CopyGmToCbufMultiDn2nzInstr { |
| 104 | public: | 113 | public: |
| 105 | template <typename T, typename U, typename... Params> | 114 | template <typename T, typename U, typename... Params> |
| 106 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) { | 115 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 116 | + { | ||
| 107 | using srcType = typename U::elementType; | 117 | using srcType = typename U::elementType; |
| 108 | - if constexpr(sizeof(srcType) == sizeof(int8_t)) { | 118 | + if constexpr (sizeof(srcType) == sizeof(int8_t)) { |
| 109 | - CopyGmToCbufMultiDn2nz((__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); | 119 | + CopyGmToCbufMultiDn2nz( |
| 120 | + (__cbuf__ uint8_t*)(dst.Data().Get()), (__gm__ uint8_t*)(src.Data().Get()), params...); | ||
| 110 | } else if constexpr (sizeof(srcType) == sizeof(half)) { | 121 | } else if constexpr (sizeof(srcType) == sizeof(half)) { |
| 111 | CopyGmToCbufMultiDn2nz((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); | 122 | CopyGmToCbufMultiDn2nz((__cbuf__ half*)(dst.Data().Get()), (__gm__ half*)(src.Data().Get()), params...); |
| 112 | } else if constexpr (sizeof(srcType) == sizeof(float)) { | 123 | } else if constexpr (sizeof(srcType) == sizeof(float)) { |
| @@ -115,9 +126,10 @@ public: | |||
| 115 | } | 126 | } |
| 116 | 127 | ||
| 117 | template <typename T> | 128 | template <typename T> |
| 118 | - __aicore__ inline static void CopyGmToCbufMultiDn2nz(__cbuf__ T* dst, __gm__ T* src, uint16_t dnNum, uint16_t loop2DstStride, | 129 | + __aicore__ inline static void CopyGmToCbufMultiDn2nz( |
| 119 | - uint16_t loop3DstStride, uint16_t loop4DstStride, uint64_t loop1SrcStride, uint8_t cacheMode, uint16_t nValue, | 130 | + __cbuf__ T* dst, __gm__ T* src, uint16_t dnNum, uint16_t loop2DstStride, uint16_t loop3DstStride, |
| 120 | - uint32_t dValue, uint64_t loop4SrcStride, bool enableSmallC0) | 131 | + uint16_t loop4DstStride, uint64_t loop1SrcStride, uint8_t cacheMode, uint16_t nValue, uint32_t dValue, |
| 132 | + uint64_t loop4SrcStride, bool enableSmallC0) | ||
| 121 | { | 133 | { |
| 122 | if ASCEND_IS_AIV { | 134 | if ASCEND_IS_AIV { |
| 123 | return; | 135 | return; |
| @@ -127,9 +139,10 @@ public: | |||
| 127 | uint64_t mte2NzPara = static_cast<uint64_t>(loop4DstStride) << 48; // MTE2_NZ_PARA[63:48] | 139 | uint64_t mte2NzPara = static_cast<uint64_t>(loop4DstStride) << 48; // MTE2_NZ_PARA[63:48] |
| 128 | mte2NzPara |= static_cast<uint64_t>(loop3DstStride) << 32; // MTE2_NZ_PARA[47:32] | 140 | mte2NzPara |= static_cast<uint64_t>(loop3DstStride) << 32; // MTE2_NZ_PARA[47:32] |
| 129 | mte2NzPara |= static_cast<uint64_t>(loop2DstStride) << 16; // MTE2_NZ_PARA[31:16] | 141 | mte2NzPara |= static_cast<uint64_t>(loop2DstStride) << 16; // MTE2_NZ_PARA[31:16] |
| 130 | - mte2NzPara |= static_cast<uint64_t>(dnNum); // MTE2_NZ_PARA[15:0] | 142 | + mte2NzPara |= static_cast<uint64_t>(dnNum); // MTE2_NZ_PARA[15:0] |
| 131 | - SetMTE2NzPara(mte2NzPara); // CCE: store parameters for DN2NZ DMA instructions | 143 | + SetMTE2NzPara(mte2NzPara); // CCE: store parameters for DN2NZ DMA instructions |
| 132 | - copy_gm_to_cbuf_multi_dn2nz(dst, src, 0, loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, enableSmallC0); | 144 | + copy_gm_to_cbuf_multi_dn2nz( |
| 145 | + dst, src, 0, loop1SrcStride, cacheMode, nValue, dValue, loop4SrcStride, enableSmallC0); | ||
| 133 | } | 146 | } |
| 134 | } | 147 | } |
| 135 | }; | 148 | }; |
| @@ -137,14 +150,16 @@ public: | |||
| 137 | class CopyL12BTInstr { | 150 | class CopyL12BTInstr { |
| 138 | public: | 151 | public: |
| 139 | template <typename T, typename U, typename... Params> | 152 | template <typename T, typename U, typename... Params> |
| 140 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) { | 153 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 154 | + { | ||
| 141 | CopyL12BT(reinterpret_cast<uint64_t>(dst.Data().Get()), src.Data().Get(), params...); | 155 | CopyL12BT(reinterpret_cast<uint64_t>(dst.Data().Get()), src.Data().Get(), params...); |
| 142 | } | 156 | } |
| 143 | 157 | ||
| 144 | private: | 158 | private: |
| 145 | template <typename T> | 159 | template <typename T> |
| 146 | - __aicore__ inline static void CopyL12BT(uint64_t dst, __cbuf__ T* src, bool convControl, uint16_t blockCount, uint16_t blockLen, | 160 | + __aicore__ inline static void CopyL12BT( |
| 147 | - uint16_t srcStride, uint16_t dstStride) | 161 | + uint64_t dst, __cbuf__ T* src, bool convControl, uint16_t blockCount, uint16_t blockLen, uint16_t srcStride, |
| 162 | + uint16_t dstStride) | ||
| 148 | { | 163 | { |
| 149 | if ASCEND_IS_AIV { | 164 | if ASCEND_IS_AIV { |
| 150 | return; | 165 | return; |
| @@ -159,14 +174,15 @@ private: | |||
| 159 | class CopyL12FBInstr { | 174 | class CopyL12FBInstr { |
| 160 | public: | 175 | public: |
| 161 | template <typename T, typename U, typename... Params> | 176 | template <typename T, typename U, typename... Params> |
| 162 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) { | 177 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 178 | + { | ||
| 163 | CopyL12FB(reinterpret_cast<uint64_t>(dst.Data().Get()), src.Data().Get(), params...); | 179 | CopyL12FB(reinterpret_cast<uint64_t>(dst.Data().Get()), src.Data().Get(), params...); |
| 164 | } | 180 | } |
| 165 | 181 | ||
| 166 | private: | 182 | private: |
| 167 | template <typename T> | 183 | template <typename T> |
| 168 | - __aicore__ inline static void CopyL12FB(uint64_t dst, __cbuf__ T* src, uint16_t blockCount, uint16_t blockLen, | 184 | + __aicore__ inline static void CopyL12FB( |
| 169 | - uint16_t srcStride, uint16_t dstStride) | 185 | + uint64_t dst, __cbuf__ T* src, uint16_t blockCount, uint16_t blockLen, uint16_t srcStride, uint16_t dstStride) |
| 170 | { | 186 | { |
| 171 | if ASCEND_IS_AIV { | 187 | if ASCEND_IS_AIV { |
| 172 | return; | 188 | return; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -40,11 +40,12 @@ template <typename T, typename U, typename Coord> | |||
| 40 | constexpr bool VerifyingFixpipeTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingFixpipeTemplate<T, U>; | 40 | constexpr bool VerifyingFixpipeTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingFixpipeTemplate<T, U>; |
| 41 | 41 | ||
| 42 | template <typename T, typename U, typename S, typename Coord> | 42 | template <typename T, typename U, typename S, typename Coord> |
| 43 | -constexpr bool VerifyingFixpipeQuantTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingFixpipeQuantTemplate<T, U, S>; | 43 | +constexpr bool VerifyingFixpipeQuantTemplateWithCoord = |
| 44 | + Std::is_tuple_v<Coord> && VerifyingFixpipeQuantTemplate<T, U, S>; | ||
| 44 | 45 | ||
| 45 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U> | 46 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U> |
| 46 | -__aicore__ inline typename Std::enable_if<VerifyingFixpipeTemplate<T, U>, void>::type | 47 | +__aicore__ inline typename Std::enable_if<VerifyingFixpipeTemplate<T, U>, void>::type Fixpipe( |
| 47 | -Fixpipe(const T& dst, const U& src, const FixpipeParams& params = FixpipeParams{}) | 48 | + const T& dst, const U& src, const FixpipeParams& params = FixpipeParams{}) |
| 48 | { | 49 | { |
| 49 | constexpr Hardware dstPos = GetHardPos<T>(); | 50 | constexpr Hardware dstPos = GetHardPos<T>(); |
| 50 | constexpr Hardware srcPos = GetHardPos<U>(); | 51 | constexpr Hardware srcPos = GetHardPos<U>(); |
| @@ -54,8 +55,8 @@ Fixpipe(const T& dst, const U& src, const FixpipeParams& params = FixpipeParams{ | |||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename S> | 57 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename S> |
| 57 | -__aicore__ inline typename Std::enable_if<VerifyingFixpipeQuantTemplate<T, U, S>, void>::type | 58 | +__aicore__ inline typename Std::enable_if<VerifyingFixpipeQuantTemplate<T, U, S>, void>::type Fixpipe( |
| 58 | -Fixpipe(const T& dst, const U& src, const S& quant, const FixpipeParams& params = FixpipeParams{}) | 59 | + const T& dst, const U& src, const S& quant, const FixpipeParams& params = FixpipeParams{}) |
| 59 | { | 60 | { |
| 60 | constexpr Hardware dstPos = GetHardPos<T>(); | 61 | constexpr Hardware dstPos = GetHardPos<T>(); |
| 61 | constexpr Hardware srcPos = GetHardPos<U>(); | 62 | constexpr Hardware srcPos = GetHardPos<U>(); |
| @@ -65,16 +66,16 @@ Fixpipe(const T& dst, const U& src, const S& quant, const FixpipeParams& params | |||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename Coord> | 68 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename Coord> |
| 68 | -__aicore__ inline typename Std::enable_if<VerifyingFixpipeTemplateWithCoord<T, U, Coord>, void>::type | 69 | +__aicore__ inline typename Std::enable_if<VerifyingFixpipeTemplateWithCoord<T, U, Coord>, void>::type Fixpipe( |
| 69 | -Fixpipe(const T& dst, const U& src, const Coord& coord, const FixpipeParams& params = FixpipeParams{}) | 70 | + const T& dst, const U& src, const Coord& coord, const FixpipeParams& params = FixpipeParams{}) |
| 70 | { | 71 | { |
| 71 | auto sliceTensor = dst(coord, src); | 72 | auto sliceTensor = dst(coord, src); |
| 72 | Fixpipe<trait>(sliceTensor, src, params); | 73 | Fixpipe<trait>(sliceTensor, src, params); |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename S, typename Coord> | 76 | template <const FixpipeTrait& trait = DEFAULT_FIXPIPE_TRAIT, typename T, typename U, typename S, typename Coord> |
| 76 | -__aicore__ inline typename Std::enable_if<VerifyingFixpipeQuantTemplateWithCoord<T, U, S, Coord>, void>::type | 77 | +__aicore__ inline typename Std::enable_if<VerifyingFixpipeQuantTemplateWithCoord<T, U, S, Coord>, void>::type Fixpipe( |
| 77 | -Fixpipe(const T& dst, const U& src, const S& quant, const Coord& coord, const FixpipeParams& params = FixpipeParams{}) | 78 | + const T& dst, const U& src, const S& quant, const Coord& coord, const FixpipeParams& params = FixpipeParams{}) |
| 78 | { | 79 | { |
| 79 | auto sliceTensor = dst(coord, src); | 80 | auto sliceTensor = dst(coord, src); |
| 80 | Fixpipe<trait>(sliceTensor, src, quant, params); | 81 | Fixpipe<trait>(sliceTensor, src, quant, params); |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -30,8 +30,9 @@ namespace Te { | |||
| 30 | 30 | ||
| 31 | class FixpipeIgnore { | 31 | class FixpipeIgnore { |
| 32 | public: | 32 | public: |
| 33 | - template <const FixpipeTrait& trait, typename ...Args> | 33 | + template <const FixpipeTrait& trait, typename... Args> |
| 34 | - __aicore__ inline void Run(const Args&... args) {} | 34 | + __aicore__ inline void Run(const Args&... args) |
| 35 | + {} | ||
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | template <Hardware dstPos, Hardware srcpos, Hardware quantpos, uint32_t Version> | 38 | template <Hardware dstPos, Hardware srcpos, Hardware quantpos, uint32_t Version> |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_utils.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/fixpipe_utils.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | -namespace Te{ | 28 | +namespace Te { |
| 29 | 29 | ||
| 30 | constexpr uint32_t MAIN_LOOP_N_SIZE_3510 = 512; | 30 | constexpr uint32_t MAIN_LOOP_N_SIZE_3510 = 512; |
| 31 | constexpr uint32_t CBURST_NUM_3510 = MAIN_LOOP_N_SIZE_3510 / BLOCK_CUBE; | 31 | constexpr uint32_t CBURST_NUM_3510 = MAIN_LOOP_N_SIZE_3510 / BLOCK_CUBE; |
| @@ -34,8 +34,7 @@ template <typename T> | |||
| 34 | __aicore__ inline auto AllocTempBuf(const T& calNSize) | 34 | __aicore__ inline auto AllocTempBuf(const T& calNSize) |
| 35 | { | 35 | { |
| 36 | uint64_t deqTensorTempBuf = 0; | 36 | uint64_t deqTensorTempBuf = 0; |
| 37 | - if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || | 37 | + if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || CURRENT_ARCH_VERSION == ArchVersion::V2201) { |
| 38 | - CURRENT_ARCH_VERSION == ArchVersion::V2201) { | ||
| 39 | deqTensorTempBuf = reinterpret_cast<uint64_t>(get_imm(0)); | 38 | deqTensorTempBuf = reinterpret_cast<uint64_t>(get_imm(0)); |
| 40 | } | 39 | } |
| 41 | return deqTensorTempBuf; | 40 | return deqTensorTempBuf; |
| @@ -44,8 +43,7 @@ __aicore__ inline auto AllocTempBuf(const T& calNSize) | |||
| 44 | template <typename T> | 43 | template <typename T> |
| 45 | __aicore__ inline void SetFpc(const T& deqTensorTempBuf) | 44 | __aicore__ inline void SetFpc(const T& deqTensorTempBuf) |
| 46 | { | 45 | { |
| 47 | - if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || | 46 | + if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || CURRENT_ARCH_VERSION == ArchVersion::V2201) { |
| 48 | - CURRENT_ARCH_VERSION == ArchVersion::V2201) { | ||
| 49 | uint64_t deqTensorAddr = (reinterpret_cast<uint64_t>(deqTensorTempBuf) >> static_cast<uint64_t>(7)) << 8; | 47 | uint64_t deqTensorAddr = (reinterpret_cast<uint64_t>(deqTensorTempBuf) >> static_cast<uint64_t>(7)) << 8; |
| 50 | set_fpc(deqTensorAddr); | 48 | set_fpc(deqTensorAddr); |
| 51 | } | 49 | } |
| @@ -53,8 +51,7 @@ __aicore__ inline void SetFpc(const T& deqTensorTempBuf) | |||
| 53 | 51 | ||
| 54 | __aicore__ inline void InsertSync() | 52 | __aicore__ inline void InsertSync() |
| 55 | { | 53 | { |
| 56 | - if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || | 54 | + if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510 || CURRENT_ARCH_VERSION == ArchVersion::V2201) { |
| 57 | - CURRENT_ARCH_VERSION == ArchVersion::V2201) { | ||
| 58 | pipe_barrier(PIPE_FIX); | 55 | pipe_barrier(PIPE_FIX); |
| 59 | } | 56 | } |
| 60 | } | 57 | } |
| @@ -70,10 +67,13 @@ public: | |||
| 70 | DataCopyL12FB3510::Run<DEFAULT_DATA_COPY_TRAIT>(dst, tileSrc); | 67 | DataCopyL12FB3510::Run<DEFAULT_DATA_COPY_TRAIT>(dst, tileSrc); |
| 71 | SetFpc(dstAddr); | 68 | SetFpc(dstAddr); |
| 72 | } | 69 | } |
| 70 | + | ||
| 73 | private: | 71 | private: |
| 74 | template <typename T> | 72 | template <typename T> |
| 75 | - __aicore__ inline static decltype(auto) TileSrcTensor(const T& src, uint16_t calNSize, uint16_t nIterIndex) { | 73 | + __aicore__ inline static decltype(auto) TileSrcTensor(const T& src, uint16_t calNSize, uint16_t nIterIndex) |
| 76 | - auto coord = MakeCoord(MakeCoord(Std::Int<0>{}, Std::Int<0>{}), MakeCoord(Std::Int<0>{}, nIterIndex * MAIN_LOOP_N_SIZE_3510)); | 74 | + { |
| 75 | + auto coord = MakeCoord( | ||
| 76 | + MakeCoord(Std::Int<0>{}, Std::Int<0>{}), MakeCoord(Std::Int<0>{}, nIterIndex * MAIN_LOOP_N_SIZE_3510)); | ||
| 77 | auto shape = MakeShape(MakeShape(Std::Int<1>{}, Std::Int<1>{}), MakeShape(Std::Int<1>{}, calNSize)); | 77 | auto shape = MakeShape(MakeShape(Std::Int<1>{}, Std::Int<1>{}), MakeShape(Std::Int<1>{}, calNSize)); |
| 78 | return src(coord, shape); | 78 | return src(coord, shape); |
| 79 | } | 79 | } |
| @@ -89,78 +89,93 @@ __aicore__ inline constexpr QuantMode_t GetFixpipeQuantPre() | |||
| 89 | 89 | ||
| 90 | if constexpr (trait.roundMode == RoundMode::HYBRID) { | 90 | if constexpr (trait.roundMode == RoundMode::HYBRID) { |
| 91 | static_assert( | 91 | static_assert( |
| 92 | - (Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>), | 92 | + (Std::is_same_v<srcType, __cc__ float> && |
| 93 | + Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>), | ||
| 93 | "Only when L0CType is float and output Type is hifloat8_t support RoundMode::HYBRID in Fixpipe"); | 94 | "Only when L0CType is float and output Type is hifloat8_t support RoundMode::HYBRID in Fixpipe"); |
| 94 | } | 95 | } |
| 95 | if constexpr (isTensor) { | 96 | if constexpr (isTensor) { |
| 96 | - if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | 97 | + if constexpr ( |
| 98 | + Std::is_same_v<srcType, __cc__ int32_t> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | ||
| 97 | return QuantMode_t::VDEQF16; | 99 | return QuantMode_t::VDEQF16; |
| 98 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 100 | + } else if constexpr ( |
| 101 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 99 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { | 102 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { |
| 100 | return QuantMode_t::VQF322B8_PRE; | 103 | return QuantMode_t::VQF322B8_PRE; |
| 101 | - } else if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && | 104 | + } else if constexpr ( |
| 105 | + Std::is_same_v<srcType, __cc__ int32_t> && | ||
| 102 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { | 106 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { |
| 103 | return QuantMode_t::VREQ8; | 107 | return QuantMode_t::VREQ8; |
| 104 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 108 | + } else if constexpr ( |
| 109 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 105 | Std::is_one_of_v<dstType, __gm__ fp8_e4m3fn_t, __ubuf__ fp8_e4m3fn_t>) { | 110 | Std::is_one_of_v<dstType, __gm__ fp8_e4m3fn_t, __ubuf__ fp8_e4m3fn_t>) { |
| 106 | return QuantMode_t::VQF322FP8_PRE; | 111 | return QuantMode_t::VQF322FP8_PRE; |
| 107 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 112 | + } else if constexpr ( |
| 113 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 108 | Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>) { | 114 | Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>) { |
| 109 | if constexpr (trait.roundMode == RoundMode::HYBRID) { | 115 | if constexpr (trait.roundMode == RoundMode::HYBRID) { |
| 110 | return QuantMode_t::VQF322HIF8_PRE_HYBRID; | 116 | return QuantMode_t::VQF322HIF8_PRE_HYBRID; |
| 111 | } else { | 117 | } else { |
| 112 | return QuantMode_t::VQF322HIF8_PRE; | 118 | return QuantMode_t::VQF322HIF8_PRE; |
| 113 | } | 119 | } |
| 114 | - } else if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && | 120 | + } else if constexpr ( |
| 121 | + Std::is_same_v<srcType, __cc__ int32_t> && | ||
| 115 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | 122 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { |
| 116 | return QuantMode_t::VQS322BF16_PRE; | 123 | return QuantMode_t::VQS322BF16_PRE; |
| 117 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 124 | + } else if constexpr ( |
| 118 | - Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | 125 | + Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { |
| 119 | return QuantMode_t::VQF322F16_PRE; | 126 | return QuantMode_t::VQF322F16_PRE; |
| 120 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 127 | + } else if constexpr ( |
| 128 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 121 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | 129 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { |
| 122 | return QuantMode_t::VQF322BF16_PRE; | 130 | return QuantMode_t::VQF322BF16_PRE; |
| 123 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 131 | + } else if constexpr ( |
| 124 | - Std::is_one_of_v<dstType, __gm__ float, __ubuf__ float>) { | 132 | + Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ float, __ubuf__ float>) { |
| 125 | return QuantMode_t::VQF322F32_PRE; | 133 | return QuantMode_t::VQF322F32_PRE; |
| 126 | } | 134 | } |
| 127 | } else if constexpr (isScalar) { | 135 | } else if constexpr (isScalar) { |
| 128 | - if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && | 136 | + if constexpr ( |
| 129 | - Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | 137 | + Std::is_same_v<srcType, __cc__ int32_t> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { |
| 130 | return QuantMode_t::DEQF16; | 138 | return QuantMode_t::DEQF16; |
| 131 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 139 | + } else if constexpr ( |
| 140 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 132 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { | 141 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { |
| 133 | return QuantMode_t::QF322B8_PRE; | 142 | return QuantMode_t::QF322B8_PRE; |
| 134 | - } else if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && | 143 | + } else if constexpr ( |
| 144 | + Std::is_same_v<srcType, __cc__ int32_t> && | ||
| 135 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { | 145 | Std::is_one_of_v<dstType, __gm__ uint8_t, __gm__ int8_t, __ubuf__ uint8_t, __ubuf__ int8_t>) { |
| 136 | return QuantMode_t::REQ8; | 146 | return QuantMode_t::REQ8; |
| 137 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 147 | + } else if constexpr ( |
| 148 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 138 | Std::is_one_of_v<dstType, __gm__ fp8_e4m3fn_t, __ubuf__ fp8_e4m3fn_t>) { | 149 | Std::is_one_of_v<dstType, __gm__ fp8_e4m3fn_t, __ubuf__ fp8_e4m3fn_t>) { |
| 139 | return QuantMode_t::QF322FP8_PRE; | 150 | return QuantMode_t::QF322FP8_PRE; |
| 140 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 151 | + } else if constexpr ( |
| 152 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 141 | Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>) { | 153 | Std::is_one_of_v<dstType, __gm__ hifloat8_t, __ubuf__ hifloat8_t>) { |
| 142 | if constexpr (trait.roundMode == RoundMode::HYBRID) { | 154 | if constexpr (trait.roundMode == RoundMode::HYBRID) { |
| 143 | return QuantMode_t::QF322HIF8_PRE_HYBRID; | 155 | return QuantMode_t::QF322HIF8_PRE_HYBRID; |
| 144 | } else { | 156 | } else { |
| 145 | return QuantMode_t::QF322HIF8_PRE; | 157 | return QuantMode_t::QF322HIF8_PRE; |
| 146 | } | 158 | } |
| 147 | - } else if constexpr (Std::is_same_v<srcType, __cc__ int32_t> && | 159 | + } else if constexpr ( |
| 160 | + Std::is_same_v<srcType, __cc__ int32_t> && | ||
| 148 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | 161 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { |
| 149 | return QuantMode_t::QS322BF16_PRE; | 162 | return QuantMode_t::QS322BF16_PRE; |
| 150 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 163 | + } else if constexpr ( |
| 151 | - Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | 164 | + Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { |
| 152 | return QuantMode_t::QF322F16_PRE; | 165 | return QuantMode_t::QF322F16_PRE; |
| 153 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> | 166 | + } else if constexpr ( |
| 154 | - && Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | 167 | + Std::is_same_v<srcType, __cc__ float> && |
| 168 | + Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | ||
| 155 | return QuantMode_t::QF322BF16_PRE; | 169 | return QuantMode_t::QF322BF16_PRE; |
| 156 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 170 | + } else if constexpr ( |
| 157 | - Std::is_one_of_v<dstType, __gm__ float, __ubuf__ float>) { | 171 | + Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ float, __ubuf__ float>) { |
| 158 | return QuantMode_t::QF322F32_PRE; | 172 | return QuantMode_t::QF322F32_PRE; |
| 159 | } | 173 | } |
| 160 | } else { | 174 | } else { |
| 161 | if constexpr (Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { | 175 | if constexpr (Std::is_same_v<srcType, __cc__ float> && Std::is_one_of_v<dstType, __gm__ half, __ubuf__ half>) { |
| 162 | return QuantMode_t::F322F16; | 176 | return QuantMode_t::F322F16; |
| 163 | - } else if constexpr (Std::is_same_v<srcType, __cc__ float> && | 177 | + } else if constexpr ( |
| 178 | + Std::is_same_v<srcType, __cc__ float> && | ||
| 164 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { | 179 | Std::is_one_of_v<dstType, __gm__ bfloat16_t, __ubuf__ bfloat16_t>) { |
| 165 | return QuantMode_t::F322BF16; | 180 | return QuantMode_t::F322BF16; |
| 166 | } else { | 181 | } else { |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -32,13 +32,15 @@ namespace Te { | |||
| 32 | class FixpipeL0C2Out3510 { | 32 | class FixpipeL0C2Out3510 { |
| 33 | public: | 33 | public: |
| 34 | template <const FixpipeTrait& trait, typename T, typename U, typename... Params> | 34 | template <const FixpipeTrait& trait, typename T, typename U, typename... Params> |
| 35 | - __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) { | 35 | + __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) |
| 36 | + { | ||
| 36 | Execute<trait>(dst, src, params...); | 37 | Execute<trait>(dst, src, params...); |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | private: | 40 | private: |
| 40 | template <const FixpipeTrait& trait, typename T, typename U, typename... Params> | 41 | template <const FixpipeTrait& trait, typename T, typename U, typename... Params> |
| 41 | - __aicore__ inline static void Execute(const T& dst, const U& src, const Params&... params) { | 42 | + __aicore__ inline static void Execute(const T& dst, const U& src, const Params&... params) |
| 43 | + { | ||
| 42 | constexpr auto quantPre = GetFixpipeQuantPre<trait, T, U>(); | 44 | constexpr auto quantPre = GetFixpipeQuantPre<trait, T, U>(); |
| 43 | if constexpr (IsL0cNZFormat<U>::value && (IsNZFormat<T>::value || IsL0cNZFormat<T>::value)) { | 45 | if constexpr (IsL0cNZFormat<U>::value && (IsNZFormat<T>::value || IsL0cNZFormat<T>::value)) { |
| 44 | Fixpipe2OutNz2Nz3510::Run<trait, quantPre, T, U>(dst, src, params...); | 46 | Fixpipe2OutNz2Nz3510::Run<trait, quantPre, T, U>(dst, src, params...); |
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2dn.h+25-22
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2dn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2dn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -30,7 +30,8 @@ namespace Te { | |||
| 30 | class Fixpipe2OutNz2Dn3510 { | 30 | class Fixpipe2OutNz2Dn3510 { |
| 31 | public: | 31 | public: |
| 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> | 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) |
| 34 | + { | ||
| 34 | SetRegisterImpl<trait, T, U>(dst, src); | 35 | SetRegisterImpl<trait, T, U>(dst, src); |
| 35 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); | 36 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); |
| 36 | } | 37 | } |
| @@ -64,14 +65,16 @@ private: | |||
| 64 | CheckTemplate<trait, quantPre, T, U>(); | 65 | CheckTemplate<trait, quantPre, T, U>(); |
| 65 | const auto& dstLayout = dst.Layout(); | 66 | const auto& dstLayout = dst.Layout(); |
| 66 | const auto& srcLayout = src.Layout(); | 67 | const auto& srcLayout = src.Layout(); |
| 67 | - uint32_t nSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) | 68 | + uint32_t nSize = Std::min( |
| 68 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 69 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 70 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | ||
| 69 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 71 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 70 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); | 72 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 71 | - uint32_t mSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) | 73 | + uint32_t mSize = Std::min( |
| 72 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 74 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 75 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | ||
| 73 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 76 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 74 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); | 77 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 75 | uint32_t srcStride = | 78 | uint32_t srcStride = |
| 76 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 79 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 77 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 80 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| @@ -83,15 +86,15 @@ private: | |||
| 83 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 86 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 84 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 87 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 85 | bool isChannelSplit = trait.enableChannelSplit; | 88 | bool isChannelSplit = trait.enableChannelSplit; |
| 86 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 89 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 87 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 90 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 88 | - nz2dnEn); | 91 | + nz2dnEn); |
| 89 | } else { | 92 | } else { |
| 90 | uint8_t dualDstCtl = trait.dualDstCtl; | 93 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 91 | bool subBlockId = false; | 94 | bool subBlockId = false; |
| 92 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 95 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 93 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 96 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 94 | - nz2dnEn); | 97 | + nz2dnEn); |
| 95 | } | 98 | } |
| 96 | } | 99 | } |
| 97 | }; | 100 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nd.h+25-22
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -30,7 +30,8 @@ namespace Te { | |||
| 30 | class Fixpipe2OutNz2Nd3510 { | 30 | class Fixpipe2OutNz2Nd3510 { |
| 31 | public: | 31 | public: |
| 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> | 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) |
| 34 | + { | ||
| 34 | SetRegisterImpl<trait, T, U>(dst, src); | 35 | SetRegisterImpl<trait, T, U>(dst, src); |
| 35 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); | 36 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); |
| 36 | } | 37 | } |
| @@ -63,14 +64,16 @@ private: | |||
| 63 | CheckTemplate<trait, quantPre, T, U>(); | 64 | CheckTemplate<trait, quantPre, T, U>(); |
| 64 | const auto& dstLayout = dst.Layout(); | 65 | const auto& dstLayout = dst.Layout(); |
| 65 | const auto& srcLayout = src.Layout(); | 66 | const auto& srcLayout = src.Layout(); |
| 66 | - uint32_t nSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) | 67 | + uint32_t nSize = Std::min( |
| 67 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 68 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 69 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | ||
| 68 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 70 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 69 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); | 71 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 70 | - uint32_t mSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) | 72 | + uint32_t mSize = Std::min( |
| 71 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 73 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 74 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | ||
| 72 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 75 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 73 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); | 76 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 74 | uint32_t srcStride = | 77 | uint32_t srcStride = |
| 75 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 78 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 76 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout); | 79 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout); |
| @@ -82,9 +85,9 @@ private: | |||
| 82 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 85 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 83 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 86 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 84 | bool isChannelSplit = trait.enableChannelSplit; | 87 | bool isChannelSplit = trait.enableChannelSplit; |
| 85 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 88 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 86 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 89 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 87 | - nz2dnEn); | 90 | + nz2dnEn); |
| 88 | } else { | 91 | } else { |
| 89 | if (trait.dualDstCtl == DUAL_DST_SPLIT_N) { | 92 | if (trait.dualDstCtl == DUAL_DST_SPLIT_N) { |
| 90 | dstStride = dstStride >> 1; | 93 | dstStride = dstStride >> 1; |
| @@ -92,9 +95,9 @@ private: | |||
| 92 | 95 | ||
| 93 | uint8_t dualDstCtl = trait.dualDstCtl; | 96 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 94 | bool subBlockId = false; | 97 | bool subBlockId = false; |
| 95 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 98 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 96 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 99 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 97 | - nz2dnEn); | 100 | + nz2dnEn); |
| 98 | } | 101 | } |
| 99 | } | 102 | } |
| 100 | }; | 103 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nz.h+26-23
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_l0c2out/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -30,7 +30,8 @@ namespace Te { | |||
| 30 | class Fixpipe2OutNz2Nz3510 { | 30 | class Fixpipe2OutNz2Nz3510 { |
| 31 | public: | 31 | public: |
| 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> | 32 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename... Params> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src, const Params&... params) |
| 34 | + { | ||
| 34 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); | 35 | DataCopyImpl<trait, quantPre, T, U>(dst, src, params...); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| @@ -53,15 +54,17 @@ private: | |||
| 53 | CheckTemplate<trait, quantPre, T, U>(); | 54 | CheckTemplate<trait, quantPre, T, U>(); |
| 54 | const auto& dstLayout = dst.Layout(); | 55 | const auto& dstLayout = dst.Layout(); |
| 55 | const auto& srcLayout = src.Layout(); | 56 | const auto& srcLayout = src.Layout(); |
| 56 | - uint32_t nSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) | 57 | + uint32_t nSize = Std::min( |
| 57 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 58 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 59 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | ||
| 58 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 60 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 59 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); | 61 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 60 | - uint32_t mSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) | 62 | + uint32_t mSize = Std::min( |
| 61 | - * GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 63 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 64 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | ||
| 62 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 65 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 63 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); | 66 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 64 | - uint32_t srcStride = | 67 | + uint32_t srcStride = |
| 65 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 68 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 66 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 69 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| 67 | 70 | ||
| @@ -72,16 +75,16 @@ private: | |||
| 72 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 75 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 73 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 76 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 74 | bool isChannelSplit = trait.enableChannelSplit; | 77 | bool isChannelSplit = trait.enableChannelSplit; |
| 75 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 78 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 76 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 79 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 77 | - nz2dnEn); | 80 | + nz2dnEn); |
| 78 | } else { | 81 | } else { |
| 79 | static_assert(trait.dualDstCtl != DUAL_DST_SPLIT_N, "If split N when fixpipe, NZ is not supported"); | 82 | static_assert(trait.dualDstCtl != DUAL_DST_SPLIT_N, "If split N when fixpipe, NZ is not supported"); |
| 80 | uint8_t dualDstCtl = trait.dualDstCtl; | 83 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 81 | bool subBlockId = false; | 84 | bool subBlockId = false; |
| 82 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 85 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 83 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 86 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 84 | - nz2dnEn); | 87 | + nz2dnEn); |
| 85 | } | 88 | } |
| 86 | } | 89 | } |
| 87 | }; | 90 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out.h+17-15
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -31,8 +31,9 @@ namespace Te { | |||
| 31 | 31 | ||
| 32 | class FormatRegistorIgnore3510 { | 32 | class FormatRegistorIgnore3510 { |
| 33 | public: | 33 | public: |
| 34 | - template <const FixpipeTrait& trait, QuantMode_t quantPre, typename ...Args> | 34 | + template <const FixpipeTrait& trait, QuantMode_t quantPre, typename... Args> |
| 35 | - __aicore__ inline static void Run(const Args&... args) {} | 35 | + __aicore__ inline static void Run(const Args&... args) |
| 36 | + {} | ||
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | template <Format3510 dstFormat, Format3510 srcFormat, QuantMode3510 QuantMode3510> | 39 | template <Format3510 dstFormat, Format3510 srcFormat, QuantMode3510 QuantMode3510> |
| @@ -88,7 +89,8 @@ struct FormatRegistorFixpipe2Out3510<Format3510::DN, Format3510::NZ, QuantMode35 | |||
| 88 | class FixpipeQuantL0C2Out3510 { | 89 | class FixpipeQuantL0C2Out3510 { |
| 89 | public: | 90 | public: |
| 90 | template <const FixpipeTrait& trait, typename T, typename U, typename V, typename... Params> | 91 | template <const FixpipeTrait& trait, typename T, typename U, typename V, typename... Params> |
| 91 | - __aicore__ inline static void Run(const T& dst, const U& src, const V& quant, const Params&... params) { | 92 | + __aicore__ inline static void Run(const T& dst, const U& src, const V& quant, const Params&... params) |
| 93 | + { | ||
| 92 | Execute<trait>(dst, src, quant, params...); | 94 | Execute<trait>(dst, src, quant, params...); |
| 93 | } | 95 | } |
| 94 | 96 | ||
| @@ -103,10 +105,10 @@ private: | |||
| 103 | } | 105 | } |
| 104 | }; | 106 | }; |
| 105 | 107 | ||
| 106 | -} // namespace Te | 108 | +} // namespace Te |
| 107 | -} // namespace AscendC | 109 | +} // namespace AscendC |
| 108 | 110 | ||
| 109 | -#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_H | 111 | +#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_H |
| 110 | 112 | ||
| 111 | 113 | ||
| 112 | 114 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2dn.h+33-32
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2dn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2dn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -62,16 +62,14 @@ private: | |||
| 62 | const auto& dstLayout = dst.Layout(); | 62 | const auto& dstLayout = dst.Layout(); |
| 63 | uint32_t nSize = Std::min( | 63 | uint32_t nSize = Std::min( |
| 64 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * | 64 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 65 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 65 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), |
| 66 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 66 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 67 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) | 67 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 68 | - ); | ||
| 69 | uint32_t mSize = Std::min( | 68 | uint32_t mSize = Std::min( |
| 70 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * | 69 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 71 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 70 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), |
| 72 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 71 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 73 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) | 72 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 74 | - ); | ||
| 75 | uint32_t srcStride = | 73 | uint32_t srcStride = |
| 76 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 74 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 77 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 75 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| @@ -82,15 +80,15 @@ private: | |||
| 82 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 80 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 83 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 81 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 84 | bool isChannelSplit = trait.enableChannelSplit; | 82 | bool isChannelSplit = trait.enableChannelSplit; |
| 85 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 83 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 86 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 84 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 87 | - nz2dnEn); | 85 | + nz2dnEn); |
| 88 | } else { | 86 | } else { |
| 89 | uint8_t dualDstCtl = trait.dualDstCtl; | 87 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 90 | bool subBlockId = false; | 88 | bool subBlockId = false; |
| 91 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 89 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 92 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 90 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 93 | - nz2dnEn); | 91 | + nz2dnEn); |
| 94 | } | 92 | } |
| 95 | } | 93 | } |
| 96 | }; | 94 | }; |
| @@ -98,7 +96,8 @@ private: | |||
| 98 | class Fixpipe2OutNZ2DNVector3510 { | 96 | class Fixpipe2OutNZ2DNVector3510 { |
| 99 | public: | 97 | public: |
| 100 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 98 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 101 | - __aicore__ inline static void FixpipeNZ2DNVectorEntrance(const T& dst, const U& src, const V& quant, const Params& ...params) | 99 | + __aicore__ inline static void FixpipeNZ2DNVectorEntrance( |
| 100 | + const T& dst, const U& src, const V& quant, const Params&... params) | ||
| 102 | { | 101 | { |
| 103 | FixpipeNZ2DNVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); | 102 | FixpipeNZ2DNVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); |
| 104 | } | 103 | } |
| @@ -143,8 +142,9 @@ private: | |||
| 143 | } | 142 | } |
| 144 | 143 | ||
| 145 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 144 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 146 | - __aicore__ inline static void FixpipeNZ2DNVectorCompute(const T& dst, const U& src, const V& quant, uint32_t nIterNum, | 145 | + __aicore__ inline static void FixpipeNZ2DNVectorCompute( |
| 147 | - uint32_t calNSize, uint32_t tailNSize, const Params&... params) | 146 | + const T& dst, const U& src, const V& quant, uint32_t nIterNum, uint32_t calNSize, uint32_t tailNSize, |
| 147 | + const Params&... params) | ||
| 148 | { | 148 | { |
| 149 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); | 149 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); |
| 150 | for (uint16_t i = 0; i < nIterNum; ++i) { | 150 | for (uint16_t i = 0; i < nIterNum; ++i) { |
| @@ -152,8 +152,8 @@ private: | |||
| 152 | InsertSync(); | 152 | InsertSync(); |
| 153 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); | 153 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); |
| 154 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * MAIN_LOOP_N_SIZE_3510)); | 154 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * MAIN_LOOP_N_SIZE_3510)); |
| 155 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 155 | + DataCopyWrapper<trait, quantPre>( |
| 156 | - mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); | 156 | + dst(dstCoord), src(srcCoord), mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); |
| 157 | } | 157 | } |
| 158 | if (tailNSize) { | 158 | if (tailNSize) { |
| 159 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); | 159 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); |
| @@ -161,13 +161,14 @@ private: | |||
| 161 | InsertSync(); | 161 | InsertSync(); |
| 162 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); | 162 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); |
| 163 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * MAIN_LOOP_N_SIZE_3510)); | 163 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * MAIN_LOOP_N_SIZE_3510)); |
| 164 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 164 | + DataCopyWrapper<trait, quantPre>( |
| 165 | - tailParam, tuple_sequence<decltype(tailParam)>{}); | 165 | + dst(dstCoord), src(srcCoord), tailParam, tuple_sequence<decltype(tailParam)>{}); |
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> | 169 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> |
| 170 | - __aicore__ inline static void DataCopyWrapper(const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | 170 | + __aicore__ inline static void DataCopyWrapper( |
| 171 | + const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | ||
| 171 | { | 172 | { |
| 172 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 173 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 173 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); | 174 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); |
| @@ -227,10 +228,10 @@ private: | |||
| 227 | SetRegister3510::SetRegister(dnNum, dstDNMatrixStride, srcNZMatrixStride, srcNZC0Stride); | 228 | SetRegister3510::SetRegister(dnNum, dstDNMatrixStride, srcNZMatrixStride, srcNZC0Stride); |
| 228 | } | 229 | } |
| 229 | }; | 230 | }; |
| 230 | -} // namespace Te | 231 | +} // namespace Te |
| 231 | -} // namespace AscendC | 232 | +} // namespace AscendC |
| 232 | 233 | ||
| 233 | -#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_NZ2DN_H | 234 | +#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_NZ2DN_H |
| 234 | 235 | ||
| 235 | 236 | ||
| 236 | 237 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nd.h+38-35
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nd.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -37,7 +37,6 @@ public: | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | - | ||
| 41 | template <const FixpipeTrait& trait, typename T, typename U> | 40 | template <const FixpipeTrait& trait, typename T, typename U> |
| 42 | __aicore__ inline static constexpr void CheckTemplate() | 41 | __aicore__ inline static constexpr void CheckTemplate() |
| 43 | { | 42 | { |
| @@ -60,16 +59,17 @@ private: | |||
| 60 | CheckTemplate<trait, T, U>(); | 59 | CheckTemplate<trait, T, U>(); |
| 61 | const auto& dstLayout = dst.Layout(); | 60 | const auto& dstLayout = dst.Layout(); |
| 62 | const auto& srcLayout = src.Layout(); | 61 | const auto& srcLayout = src.Layout(); |
| 63 | - uint32_t mSize = Std::min(GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * | 62 | + uint32_t mSize = Std::min( |
| 64 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 63 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 64 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | ||
| 65 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 65 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 66 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); | 66 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 67 | uint32_t nSize = Std::min( | 67 | uint32_t nSize = Std::min( |
| 68 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * | 68 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 69 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 69 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), |
| 70 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 70 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 71 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); | 71 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 72 | - | 72 | + |
| 73 | uint32_t srcStride = | 73 | uint32_t srcStride = |
| 74 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 74 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 75 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout); | 75 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout); |
| @@ -80,15 +80,15 @@ private: | |||
| 80 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 80 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 81 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 81 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 82 | bool isChannelSplit = trait.enableChannelSplit; | 82 | bool isChannelSplit = trait.enableChannelSplit; |
| 83 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 83 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 84 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 84 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 85 | - nz2dnEn); | 85 | + nz2dnEn); |
| 86 | } else { | 86 | } else { |
| 87 | uint8_t dualDstCtl = trait.dualDstCtl; | 87 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 88 | bool subBlockId = false; | 88 | bool subBlockId = false; |
| 89 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 89 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 90 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 90 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 91 | - nz2dnEn); | 91 | + nz2dnEn); |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | }; | 94 | }; |
| @@ -96,7 +96,8 @@ private: | |||
| 96 | class Fixpipe2OutNZ2NDVector3510 { | 96 | class Fixpipe2OutNZ2NDVector3510 { |
| 97 | public: | 97 | public: |
| 98 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 98 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 99 | - __aicore__ inline static void FixpipeNZ2NDVectorEntrance(const T& dst, const U& src, const V& quant, const Params& ...params) | 99 | + __aicore__ inline static void FixpipeNZ2NDVectorEntrance( |
| 100 | + const T& dst, const U& src, const V& quant, const Params&... params) | ||
| 100 | { | 101 | { |
| 101 | FixpipeNZ2NDVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); | 102 | FixpipeNZ2NDVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); |
| 102 | } | 103 | } |
| @@ -144,8 +145,9 @@ private: | |||
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 147 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 147 | - __aicore__ inline static void FixpipeNZ2NDVectorCompute(const T& dst, const U& src, const V& quant, uint32_t nIterNum, | 148 | + __aicore__ inline static void FixpipeNZ2NDVectorCompute( |
| 148 | - uint32_t calNSize, uint32_t tailNSize, const Params&... params) | 149 | + const T& dst, const U& src, const V& quant, uint32_t nIterNum, uint32_t calNSize, uint32_t tailNSize, |
| 150 | + const Params&... params) | ||
| 149 | { | 151 | { |
| 150 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); | 152 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); |
| 151 | for (uint16_t i = 0; i < nIterNum; ++i) { | 153 | for (uint16_t i = 0; i < nIterNum; ++i) { |
| @@ -153,8 +155,8 @@ private: | |||
| 153 | InsertSync(); | 155 | InsertSync(); |
| 154 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); | 156 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); |
| 155 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * MAIN_LOOP_N_SIZE_3510)); | 157 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * MAIN_LOOP_N_SIZE_3510)); |
| 156 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 158 | + DataCopyWrapper<trait, quantPre>( |
| 157 | - mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); | 159 | + dst(dstCoord), src(srcCoord), mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); |
| 158 | } | 160 | } |
| 159 | if (tailNSize) { | 161 | if (tailNSize) { |
| 160 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); | 162 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); |
| @@ -162,13 +164,14 @@ private: | |||
| 162 | InsertSync(); | 164 | InsertSync(); |
| 163 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); | 165 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); |
| 164 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * MAIN_LOOP_N_SIZE_3510)); | 166 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * MAIN_LOOP_N_SIZE_3510)); |
| 165 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 167 | + DataCopyWrapper<trait, quantPre>( |
| 166 | - tailParam, tuple_sequence<decltype(tailParam)>{}); | 168 | + dst(dstCoord), src(srcCoord), tailParam, tuple_sequence<decltype(tailParam)>{}); |
| 167 | } | 169 | } |
| 168 | } | 170 | } |
| 169 | 171 | ||
| 170 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> | 172 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> |
| 171 | - __aicore__ inline static void DataCopyWrapper(const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | 173 | + __aicore__ inline static void DataCopyWrapper( |
| 174 | + const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | ||
| 172 | { | 175 | { |
| 173 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 176 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 174 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); | 177 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); |
| @@ -203,9 +206,9 @@ private: | |||
| 203 | const auto& srcLayout = src.Layout(); | 206 | const auto& srcLayout = src.Layout(); |
| 204 | uint32_t nSize = Std::min( | 207 | uint32_t nSize = Std::min( |
| 205 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * | 208 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 206 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 209 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), |
| 207 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 210 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 208 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); | 211 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 209 | uint32_t srcStride = | 212 | uint32_t srcStride = |
| 210 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 213 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 211 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 214 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| @@ -231,10 +234,10 @@ private: | |||
| 231 | } | 234 | } |
| 232 | }; | 235 | }; |
| 233 | 236 | ||
| 234 | -} // namespace Te | 237 | +} // namespace Te |
| 235 | -} // namespace AscendC | 238 | +} // namespace AscendC |
| 236 | 239 | ||
| 237 | -#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_NZ2ND_H | 240 | +#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_NZ2ND_H |
| 238 | 241 | ||
| 239 | 242 | ||
| 240 | 243 | ||
Mimpl/experimental/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nz.h+34-34
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/fixpipe_quant_l0c2out/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -61,17 +61,15 @@ private: | |||
| 61 | const auto& dstLayout = dst.Layout(); | 61 | const auto& dstLayout = dst.Layout(); |
| 62 | uint32_t mSize = Std::min( | 62 | uint32_t mSize = Std::min( |
| 63 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * | 63 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) * |
| 64 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), | 64 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout), |
| 65 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * | 65 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) * |
| 66 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) | 66 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout)); |
| 67 | - ); | ||
| 68 | uint32_t nSize = Std::min( | 67 | uint32_t nSize = Std::min( |
| 69 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * | 68 | GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) * |
| 70 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), | 69 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout), |
| 71 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * | 70 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) * |
| 72 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) | 71 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout)); |
| 73 | - ); | 72 | + |
| 74 | - | ||
| 75 | uint32_t srcStride = | 73 | uint32_t srcStride = |
| 76 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; | 74 | GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / FRACTAL_FIXED; |
| 77 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); | 75 | uint32_t dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout); |
| @@ -82,16 +80,16 @@ private: | |||
| 82 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 80 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 83 | uint8_t cacheMode = GetCacheModeFromTensor(dst); | 81 | uint8_t cacheMode = GetCacheModeFromTensor(dst); |
| 84 | bool isChannelSplit = trait.enableChannelSplit; | 82 | bool isChannelSplit = trait.enableChannelSplit; |
| 85 | - CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 83 | + CopyMatrixCcToGm3510::DataCopy<quantPre, T, U>( |
| 86 | - cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, | 84 | + dst, src, nSize, mSize, srcStride, dstStride, cacheMode, reluEn, unitFlag, isChannelSplit, nz2ndEn, |
| 87 | - nz2dnEn); | 85 | + nz2dnEn); |
| 88 | } else { | 86 | } else { |
| 89 | static_assert(trait.dualDstCtl != DUAL_DST_SPLIT_N, "If split N when fixpipe, NZ is not supported"); | 87 | static_assert(trait.dualDstCtl != DUAL_DST_SPLIT_N, "If split N when fixpipe, NZ is not supported"); |
| 90 | uint8_t dualDstCtl = trait.dualDstCtl; | 88 | uint8_t dualDstCtl = trait.dualDstCtl; |
| 91 | bool subBlockId = false; | 89 | bool subBlockId = false; |
| 92 | - CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>(dst, src, nSize, mSize, srcStride, dstStride, | 90 | + CopyMatrixCcToUb3510::DataCopy<quantPre, T, U>( |
| 93 | - dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, | 91 | + dst, src, nSize, mSize, srcStride, dstStride, dualDstCtl, reluEn, unitFlag, subBlockId, nz2ndEn, |
| 94 | - nz2dnEn); | 92 | + nz2dnEn); |
| 95 | } | 93 | } |
| 96 | } | 94 | } |
| 97 | }; | 95 | }; |
| @@ -99,7 +97,8 @@ private: | |||
| 99 | class Fixpipe2OutNZ2NZVector3510 { | 97 | class Fixpipe2OutNZ2NZVector3510 { |
| 100 | public: | 98 | public: |
| 101 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 99 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 102 | - __aicore__ inline static void FixpipeNZ2NZVectorEntrance(const T& dst, const U& src, const V& quant, const Params& ...params) | 100 | + __aicore__ inline static void FixpipeNZ2NZVectorEntrance( |
| 101 | + const T& dst, const U& src, const V& quant, const Params&... params) | ||
| 103 | { | 102 | { |
| 104 | FixpipeNZ2NZVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); | 103 | FixpipeNZ2NZVectorCompute<trait, quantPre, T, U, V>(dst, src, quant, params...); |
| 105 | } | 104 | } |
| @@ -146,8 +145,9 @@ private: | |||
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> | 147 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, typename... Params> |
| 149 | - __aicore__ inline static void FixpipeNZ2NZVectorCompute(const T& dst, const U& src, const V& quant, uint32_t nIterNum, | 148 | + __aicore__ inline static void FixpipeNZ2NZVectorCompute( |
| 150 | - uint32_t calNSize, uint32_t tailNSize, const Params&... params) | 149 | + const T& dst, const U& src, const V& quant, uint32_t nIterNum, uint32_t calNSize, uint32_t tailNSize, |
| 150 | + const Params&... params) | ||
| 151 | { | 151 | { |
| 152 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); | 152 | auto mainLoopParam = GenParams<trait, T, U, false>(dst, src, params...); |
| 153 | for (uint16_t i = 0; i < nIterNum; ++i) { | 153 | for (uint16_t i = 0; i < nIterNum; ++i) { |
| @@ -155,8 +155,8 @@ private: | |||
| 155 | InsertSync(); | 155 | InsertSync(); |
| 156 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); | 156 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); |
| 157 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); | 157 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, i * CBURST_NUM_3510)); |
| 158 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 158 | + DataCopyWrapper<trait, quantPre>( |
| 159 | - mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); | 159 | + dst(dstCoord), src(srcCoord), mainLoopParam, tuple_sequence<decltype(mainLoopParam)>{}); |
| 160 | } | 160 | } |
| 161 | if (tailNSize) { | 161 | if (tailNSize) { |
| 162 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); | 162 | auto tailParam = GenParams<trait, T, U, true>(dst, src, params...); |
| @@ -164,13 +164,14 @@ private: | |||
| 164 | InsertSync(); | 164 | InsertSync(); |
| 165 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); | 165 | auto srcCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); |
| 166 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); | 166 | auto dstCoord = MakeCoord(MakeCoord(0, 0), MakeCoord(0, nIterNum * CBURST_NUM_3510)); |
| 167 | - DataCopyWrapper<trait, quantPre>(dst(dstCoord), src(srcCoord), | 167 | + DataCopyWrapper<trait, quantPre>( |
| 168 | - tailParam, tuple_sequence<decltype(tailParam)>{}); | 168 | + dst(dstCoord), src(srcCoord), tailParam, tuple_sequence<decltype(tailParam)>{}); |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> | 172 | template <const FixpipeTrait& trait, QuantMode_t quantPre, typename T, typename U, typename V, size_t... Is> |
| 173 | - __aicore__ inline static void DataCopyWrapper(const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | 173 | + __aicore__ inline static void DataCopyWrapper( |
| 174 | + const T& dst, const U& src, const V& tupleParams, Std::index_sequence<Is...>) | ||
| 174 | { | 175 | { |
| 175 | if constexpr (GetHardPos<T>() == Hardware::GM) { | 176 | if constexpr (GetHardPos<T>() == Hardware::GM) { |
| 176 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); | 177 | CopyMatrixCcToGm3510::DataCopy<quantPre>(dst, src, Std::get<Is>(tupleParams)...); |
| @@ -230,11 +231,10 @@ private: | |||
| 230 | } | 231 | } |
| 231 | }; | 232 | }; |
| 232 | 233 | ||
| 234 | +} // namespace Te | ||
| 235 | +} // namespace AscendC | ||
| 233 | 236 | ||
| 234 | -} // namespace Te | 237 | +#endif // IMPL_TENSOR_API_ARCH_CUBE_DATAMOVE_FIXPIPE_NPU_ARCH_3510_FIXPIPE_QUANT_L0C2OUT_NZ2NZ_H |
| 235 | -} // namespace AscendC | ||
| 236 | - | ||
| 237 | - | ||
| 238 | 238 | ||
| 239 | 239 | ||
| 240 | 240 | ||
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/fixpipe/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -31,66 +31,67 @@ namespace Te { | |||
| 31 | class CopyMatrixCcToGm3510 { | 31 | class CopyMatrixCcToGm3510 { |
| 32 | public: | 32 | public: |
| 33 | template <QuantMode_t quantPre, typename T, typename U, typename... Params> | 33 | template <QuantMode_t quantPre, typename T, typename U, typename... Params> |
| 34 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) | 34 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 35 | { | 35 | { |
| 36 | CopyMatrixCcToGm<quantPre>(dst.Data().Get(), src.Data().Get(), params...); | 36 | CopyMatrixCcToGm<quantPre>(dst.Data().Get(), src.Data().Get(), params...); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | template <QuantMode_t quantPre, typename T, typename U> | 40 | template <QuantMode_t quantPre, typename T, typename U> |
| 41 | - __aicore__ inline static void CopyMatrixCcToGm(__gm__ T *dst, __cc__ U *src, uint32_t nSize, uint32_t mSize, | 41 | + __aicore__ inline static void CopyMatrixCcToGm( |
| 42 | - uint32_t srcStride, uint32_t dstStride, uint8_t cacheMode, bool reluEn, uint8_t unitFlag, bool isChannelSplit, | 42 | + __gm__ T* dst, __cc__ U* src, uint32_t nSize, uint32_t mSize, uint32_t srcStride, uint32_t dstStride, |
| 43 | - bool nz2ndEn, bool nz2dnEn) | 43 | + uint8_t cacheMode, bool reluEn, uint8_t unitFlag, bool isChannelSplit, bool nz2ndEn, bool nz2dnEn) |
| 44 | { | 44 | { |
| 45 | if ASCEND_IS_AIV { | 45 | if ASCEND_IS_AIV { |
| 46 | return; | 46 | return; |
| 47 | } | 47 | } |
| 48 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { | 48 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { |
| 49 | - copy_matrix_cc_to_gm(dst, src, 0, nSize, mSize, dstStride, srcStride, cacheMode, 0, unitFlag, static_cast<uint64_t>(quantPre), | 49 | + copy_matrix_cc_to_gm( |
| 50 | - reluEn, isChannelSplit, nz2ndEn, static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false, false, false, | 50 | + dst, src, 0, nSize, mSize, dstStride, srcStride, cacheMode, 0, unitFlag, |
| 51 | - nz2dnEn); | 51 | + static_cast<uint64_t>(quantPre), reluEn, isChannelSplit, nz2ndEn, |
| 52 | + static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false, false, false, | ||
| 53 | + nz2dnEn); | ||
| 52 | } | 54 | } |
| 53 | } | 55 | } |
| 54 | }; | 56 | }; |
| 55 | 57 | ||
| 56 | class CopyMatrixCcToUb3510 { | 58 | class CopyMatrixCcToUb3510 { |
| 57 | public: | 59 | public: |
| 58 | -template <QuantMode_t quantPre, typename T, typename U, typename... Params> | 60 | + template <QuantMode_t quantPre, typename T, typename U, typename... Params> |
| 59 | - __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params& ...params) | 61 | + __aicore__ inline static void DataCopy(const T& dst, const U& src, const Params&... params) |
| 60 | { | 62 | { |
| 61 | CopyMatrixCcToUb<quantPre>(dst.Data().Get(), src.Data().Get(), params...); | 63 | CopyMatrixCcToUb<quantPre>(dst.Data().Get(), src.Data().Get(), params...); |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | private: | 66 | private: |
| 65 | - | ||
| 66 | template <QuantMode_t quantPre, typename T, typename U> | 67 | template <QuantMode_t quantPre, typename T, typename U> |
| 67 | - __aicore__ inline static void CopyMatrixCcToUb(__ubuf__ T *dst, __cc__ U *src, uint32_t nSize, uint32_t mSize, | 68 | + __aicore__ inline static void CopyMatrixCcToUb( |
| 68 | - uint32_t srcStride, uint32_t dstStride, uint8_t dualDstCtl, bool reluEn, uint8_t unitFlag, bool subBlockId, | 69 | + __ubuf__ T* dst, __cc__ U* src, uint32_t nSize, uint32_t mSize, uint32_t srcStride, uint32_t dstStride, |
| 69 | - bool nz2ndEn, bool nz2dnEn) | 70 | + uint8_t dualDstCtl, bool reluEn, uint8_t unitFlag, bool subBlockId, bool nz2ndEn, bool nz2dnEn) |
| 70 | { | 71 | { |
| 71 | if ASCEND_IS_AIV { | 72 | if ASCEND_IS_AIV { |
| 72 | return; | 73 | return; |
| 73 | } | 74 | } |
| 74 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { | 75 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { |
| 75 | - copy_matrix_cc_to_ub(dst, src, 0, nSize, mSize, dstStride, srcStride, dualDstCtl, subBlockId, 0, unitFlag, static_cast<uint64_t>(quantPre), | 76 | + copy_matrix_cc_to_ub( |
| 76 | - reluEn, false, nz2ndEn, static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false, false, false, | 77 | + dst, src, 0, nSize, mSize, dstStride, srcStride, dualDstCtl, subBlockId, 0, unitFlag, |
| 77 | - nz2dnEn); | 78 | + static_cast<uint64_t>(quantPre), reluEn, false, nz2ndEn, static_cast<uint64_t>(QuantMode_post::NoConv), |
| 79 | + 0, false, false, 0, false, false, false, false, false, nz2dnEn); | ||
| 78 | } | 80 | } |
| 79 | } | 81 | } |
| 80 | }; | 82 | }; |
| 81 | 83 | ||
| 82 | - | ||
| 83 | class SetRegister3510 { | 84 | class SetRegister3510 { |
| 84 | public: | 85 | public: |
| 85 | template <typename... Params> | 86 | template <typename... Params> |
| 86 | - __aicore__ inline static void SetRegister(const uint64_t& quant, const Params& ...params) | 87 | + __aicore__ inline static void SetRegister(const uint64_t& quant, const Params&... params) |
| 87 | { | 88 | { |
| 88 | SetQuantPre(quant); | 89 | SetQuantPre(quant); |
| 89 | SetParamsToRegister<uint64_t>(params...); | 90 | SetParamsToRegister<uint64_t>(params...); |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 92 | template <typename... Params> | 93 | template <typename... Params> |
| 93 | - __aicore__ inline static void SetRegister(const Params& ...params) | 94 | + __aicore__ inline static void SetRegister(const Params&... params) |
| 94 | { | 95 | { |
| 95 | SetParamsToRegister<uint64_t>(params...); | 96 | SetParamsToRegister<uint64_t>(params...); |
| 96 | } | 97 | } |
| @@ -122,7 +123,8 @@ private: | |||
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | template <typename T> | 125 | template <typename T> |
| 125 | - __aicore__ inline static void SetParamsToRegister(uint32_t dnNum, uint32_t dstDNStride, uint32_t srcNZMatrixStride, uint32_t srcNZC0Stride) | 126 | + __aicore__ inline static void SetParamsToRegister( |
| 127 | + uint32_t dnNum, uint32_t dstDNStride, uint32_t srcNZMatrixStride, uint32_t srcNZC0Stride) | ||
| 126 | { | 128 | { |
| 127 | if ASCEND_IS_AIV { | 129 | if ASCEND_IS_AIV { |
| 128 | return; | 130 | return; |
| @@ -138,8 +140,8 @@ private: | |||
| 138 | } | 140 | } |
| 139 | }; | 141 | }; |
| 140 | 142 | ||
| 141 | -} | 143 | +} // namespace Te |
| 142 | -} | 144 | +} // namespace AscendC |
| 143 | 145 | ||
| 144 | 146 | ||
| 145 | 147 | ||
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/load_data_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/load_data_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -35,9 +35,9 @@ constexpr bool VerifyingLoadDataTemplate = IsTileTensorV<U> && IsTileTensorV<T>; | |||
| 35 | template <typename T, typename U, typename Coord> | 35 | template <typename T, typename U, typename Coord> |
| 36 | constexpr bool VerifyingLoadDataTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingLoadDataTemplate<T, U>; | 36 | constexpr bool VerifyingLoadDataTemplateWithCoord = Std::is_tuple_v<Coord> && VerifyingLoadDataTemplate<T, U>; |
| 37 | 37 | ||
| 38 | -template<const LoadDataTrait& trait = DEFAULT_LOAD_DATA_TRAIT, typename T, typename U> | 38 | +template <const LoadDataTrait& trait = DEFAULT_LOAD_DATA_TRAIT, typename T, typename U> |
| 39 | -__aicore__ inline typename Std::enable_if<VerifyingLoadDataTemplate<T, U>, void>::type | 39 | +__aicore__ inline typename Std::enable_if<VerifyingLoadDataTemplate<T, U>, void>::type LoadData( |
| 40 | -LoadData(const T& dst, const U& src) | 40 | + const T& dst, const U& src) |
| 41 | { | 41 | { |
| 42 | constexpr Hardware dstPos = GetHardPos<T>(); | 42 | constexpr Hardware dstPos = GetHardPos<T>(); |
| 43 | constexpr Hardware srcPos = GetHardPos<U>(); | 43 | constexpr Hardware srcPos = GetHardPos<U>(); |
| @@ -45,9 +45,9 @@ LoadData(const T& dst, const U& src) | |||
| 45 | Tensor2Tensor{}.template Run<trait, T, U>(dst, src); | 45 | Tensor2Tensor{}.template Run<trait, T, U>(dst, src); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | -template<const LoadDataTrait& trait = DEFAULT_LOAD_DATA_TRAIT, typename T, typename U, class Coord> | 48 | +template <const LoadDataTrait& trait = DEFAULT_LOAD_DATA_TRAIT, typename T, typename U, class Coord> |
| 49 | -__aicore__ inline typename Std::enable_if<VerifyingLoadDataTemplateWithCoord<T, U, Coord>, void>::type | 49 | +__aicore__ inline typename Std::enable_if<VerifyingLoadDataTemplateWithCoord<T, U, Coord>, void>::type LoadData( |
| 50 | -LoadData(const T& dst, const U& src, const Coord& coord) | 50 | + const T& dst, const U& src, const Coord& coord) |
| 51 | { | 51 | { |
| 52 | constexpr Hardware dstPos = GetHardPos<T>(); | 52 | constexpr Hardware dstPos = GetHardPos<T>(); |
| 53 | constexpr Hardware srcPos = GetHardPos<U>(); | 53 | constexpr Hardware srcPos = GetHardPos<U>(); |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/load_data_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/load_data_routing.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -31,8 +31,9 @@ namespace Te { | |||
| 31 | 31 | ||
| 32 | class LoadDataIgnore { | 32 | class LoadDataIgnore { |
| 33 | public: | 33 | public: |
| 34 | - template <const LoadDataTrait& trait, typename ...Args> | 34 | + template <const LoadDataTrait& trait, typename... Args> |
| 35 | - __aicore__ inline void Run(const Args&... args) {} | 35 | + __aicore__ inline void Run(const Args&... args) |
| 36 | + {} | ||
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | template <Hardware dstPos, Hardware srcPos, uint32_t Version> | 39 | template <Hardware dstPos, Hardware srcPos, uint32_t Version> |
| @@ -46,26 +47,22 @@ struct LoadDataTensor2TensorNoCoord { | |||
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| 48 | template <> | 49 | template <> |
| 49 | -struct LoadDataTensor2TensorNoCoord<Hardware::L0A, Hardware::L1, ArchVersion::V3510> | 50 | +struct LoadDataTensor2TensorNoCoord<Hardware::L0A, Hardware::L1, ArchVersion::V3510> { |
| 50 | -{ | ||
| 51 | using type = LoadDataL12L0A3510; | 51 | using type = LoadDataL12L0A3510; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | template <> | 54 | template <> |
| 55 | -struct LoadDataTensor2TensorNoCoord<Hardware::L0B, Hardware::L1, ArchVersion::V3510> | 55 | +struct LoadDataTensor2TensorNoCoord<Hardware::L0B, Hardware::L1, ArchVersion::V3510> { |
| 56 | -{ | ||
| 57 | using type = LoadDataL12L0B3510; | 56 | using type = LoadDataL12L0B3510; |
| 58 | }; | 57 | }; |
| 59 | 58 | ||
| 60 | template <> | 59 | template <> |
| 61 | -struct LoadDataTensor2Tensor<Hardware::L0A, Hardware::L1, ArchVersion::V3510> | 60 | +struct LoadDataTensor2Tensor<Hardware::L0A, Hardware::L1, ArchVersion::V3510> { |
| 62 | -{ | ||
| 63 | using type = LoadDataL12L0AWithCoord3510; | 61 | using type = LoadDataL12L0AWithCoord3510; |
| 64 | }; | 62 | }; |
| 65 | 63 | ||
| 66 | template <> | 64 | template <> |
| 67 | -struct LoadDataTensor2Tensor<Hardware::L0B, Hardware::L1, ArchVersion::V3510> | 65 | +struct LoadDataTensor2Tensor<Hardware::L0B, Hardware::L1, ArchVersion::V3510> { |
| 68 | -{ | ||
| 69 | using type = LoadDataL12L0BWithCoord3510; | 66 | using type = LoadDataL12L0BWithCoord3510; |
| 70 | }; | 67 | }; |
| 71 | } // namespace Te | 68 | } // namespace Te |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/instruction.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -31,15 +31,16 @@ namespace Te { | |||
| 31 | class LoadCbufToCa3510 { | 31 | class LoadCbufToCa3510 { |
| 32 | public: | 32 | public: |
| 33 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> | 33 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> |
| 34 | - __aicore__ inline static void LoadData(const T& dst, const U& src, const Params& ...params) | 34 | + __aicore__ inline static void LoadData(const T& dst, const U& src, const Params&... params) |
| 35 | { | 35 | { |
| 36 | LoadCbufToCa<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); | 36 | LoadCbufToCa<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | template <bool transpose, typename T> | 40 | template <bool transpose, typename T> |
| 41 | - __aicore__ inline static void LoadCbufToCa(__ca__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, | 41 | + __aicore__ inline static void LoadCbufToCa( |
| 42 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 42 | + __ca__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 43 | + int16_t srcStride, uint16_t dstStride) | ||
| 43 | { | 44 | { |
| 44 | if ASCEND_IS_AIV { | 45 | if ASCEND_IS_AIV { |
| 45 | return; | 46 | return; |
| @@ -53,15 +54,16 @@ private: | |||
| 53 | class LoadCbufToCaS43510 { | 54 | class LoadCbufToCaS43510 { |
| 54 | public: | 55 | public: |
| 55 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> | 56 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> |
| 56 | - __aicore__ inline static void LoadData(const T& dst, const U& src, const Params& ...params) | 57 | + __aicore__ inline static void LoadData(const T& dst, const U& src, const Params&... params) |
| 57 | { | 58 | { |
| 58 | LoadCbufToCa<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); | 59 | LoadCbufToCa<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | private: | 62 | private: |
| 62 | template <bool transpose, typename T> | 63 | template <bool transpose, typename T> |
| 63 | - __aicore__ inline static void LoadCbufToCa(__ca__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, | 64 | + __aicore__ inline static void LoadCbufToCa( |
| 64 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 65 | + __ca__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 66 | + int16_t srcStride, uint16_t dstStride) | ||
| 65 | { | 67 | { |
| 66 | if ASCEND_IS_AIV { | 68 | if ASCEND_IS_AIV { |
| 67 | return; | 69 | return; |
| @@ -75,15 +77,16 @@ private: | |||
| 75 | class LoadCbufToCb3510 { | 77 | class LoadCbufToCb3510 { |
| 76 | public: | 78 | public: |
| 77 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> | 79 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> |
| 78 | - __aicore__ inline static void LoadData(const T& dst, const U& src, const Params& ...params) | 80 | + __aicore__ inline static void LoadData(const T& dst, const U& src, const Params&... params) |
| 79 | { | 81 | { |
| 80 | LoadCbufToCb<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); | 82 | LoadCbufToCb<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | private: | 85 | private: |
| 84 | template <bool transpose, typename T> | 86 | template <bool transpose, typename T> |
| 85 | - __aicore__ inline static void LoadCbufToCb(__cb__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, | 87 | + __aicore__ inline static void LoadCbufToCb( |
| 86 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 88 | + __cb__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 89 | + int16_t srcStride, uint16_t dstStride) | ||
| 87 | { | 90 | { |
| 88 | if ASCEND_IS_AIV { | 91 | if ASCEND_IS_AIV { |
| 89 | return; | 92 | return; |
| @@ -97,15 +100,16 @@ private: | |||
| 97 | class LoadCbufToCbS43510 { | 100 | class LoadCbufToCbS43510 { |
| 98 | public: | 101 | public: |
| 99 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> | 102 | template <const LoadDataTrait& trait, typename T, typename U, typename... Params> |
| 100 | - __aicore__ inline static void LoadData(const T& dst, const U& src, const Params& ...params) | 103 | + __aicore__ inline static void LoadData(const T& dst, const U& src, const Params&... params) |
| 101 | { | 104 | { |
| 102 | LoadCbufToCb<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); | 105 | LoadCbufToCb<trait.transposed>(dst.Data().Get(), src.Data().Get(), params...); |
| 103 | } | 106 | } |
| 104 | 107 | ||
| 105 | private: | 108 | private: |
| 106 | template <bool transpose, typename T> | 109 | template <bool transpose, typename T> |
| 107 | - __aicore__ inline static void LoadCbufToCb(__cb__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, | 110 | + __aicore__ inline static void LoadCbufToCb( |
| 108 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 111 | + __cb__ T* dst, __cbuf__ T* src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 112 | + int16_t srcStride, uint16_t dstStride) | ||
| 109 | { | 113 | { |
| 110 | if ASCEND_IS_AIV { | 114 | if ASCEND_IS_AIV { |
| 111 | return; | 115 | return; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -34,13 +34,15 @@ namespace Te { | |||
| 34 | class LoadDataL12L0A3510 { | 34 | class LoadDataL12L0A3510 { |
| 35 | public: | 35 | public: |
| 36 | template <const LoadDataTrait& trait, typename T, typename U> | 36 | template <const LoadDataTrait& trait, typename T, typename U> |
| 37 | - __aicore__ inline void Run(const T& dst, const U& src) { | 37 | + __aicore__ inline void Run(const T& dst, const U& src) |
| 38 | + { | ||
| 38 | Execute<trait>(dst, src); | 39 | Execute<trait>(dst, src); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | private: | 42 | private: |
| 42 | template <const LoadDataTrait& trait, typename T, typename U> | 43 | template <const LoadDataTrait& trait, typename T, typename U> |
| 43 | - __aicore__ inline void Execute(const T& dst, const U& src) { | 44 | + __aicore__ inline void Execute(const T& dst, const U& src) |
| 45 | + { | ||
| 44 | if constexpr (IsNZFormat<U>::value && IsNZFormat<T>::value) { | 46 | if constexpr (IsNZFormat<U>::value && IsNZFormat<T>::value) { |
| 45 | LoadDataL12L0ANZ2NZ3510::Run<trait, T, U>(dst, src); | 47 | LoadDataL12L0ANZ2NZ3510::Run<trait, T, U>(dst, src); |
| 46 | } else if constexpr (IsZNFormat<U>::value && IsNZFormat<T>::value && (sizeof(typename U::elementType) == 1)) { | 48 | } else if constexpr (IsZNFormat<U>::value && IsNZFormat<T>::value && (sizeof(typename U::elementType) == 1)) { |
| @@ -54,13 +56,15 @@ private: | |||
| 54 | class LoadDataL12L0AWithCoord3510 { | 56 | class LoadDataL12L0AWithCoord3510 { |
| 55 | public: | 57 | public: |
| 56 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> | 58 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> |
| 57 | - __aicore__ inline void Run(const T& dst, const U& src, const Coord& coord) { | 59 | + __aicore__ inline void Run(const T& dst, const U& src, const Coord& coord) |
| 60 | + { | ||
| 58 | Execute<trait>(dst, src, coord); | 61 | Execute<trait>(dst, src, coord); |
| 59 | } | 62 | } |
| 60 | 63 | ||
| 61 | private: | 64 | private: |
| 62 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> | 65 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> |
| 63 | - __aicore__ inline void Execute(const T& dst, const U& src, const Coord& coord) { | 66 | + __aicore__ inline void Execute(const T& dst, const U& src, const Coord& coord) |
| 67 | + { | ||
| 64 | if constexpr (IsNZFormat<U>::value && IsNZFormat<T>::value) { | 68 | if constexpr (IsNZFormat<U>::value && IsNZFormat<T>::value) { |
| 65 | LoadDataL12L0ANZ2NZWithCoord3510::Run<trait, T, U, Coord>(dst, src, coord); | 69 | LoadDataL12L0ANZ2NZWithCoord3510::Run<trait, T, U, Coord>(dst, src, coord); |
| 66 | } else if constexpr (IsZNFormat<U>::value && IsNZFormat<T>::value && (sizeof(typename U::elementType) == 1)) { | 70 | } else if constexpr (IsZNFormat<U>::value && IsNZFormat<T>::value && (sizeof(typename U::elementType) == 1)) { |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/nz2nz.h+20-15
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/nz2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -30,11 +30,12 @@ namespace Te { | |||
| 30 | class LoadDataL12L0ANZ2NZ3510 { | 30 | class LoadDataL12L0ANZ2NZ3510 { |
| 31 | public: | 31 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 32 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 33 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 34 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, false>, T, U>(dst, src); | 35 | LoadDataImpl<TransTrait<trait, false>, T, U>(dst, src); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | -private: | 38 | +private: |
| 38 | template <const LoadDataTrait& trait, typename T, typename U> | 39 | template <const LoadDataTrait& trait, typename T, typename U> |
| 39 | __aicore__ inline static constexpr void CheckTemplate() | 40 | __aicore__ inline static constexpr void CheckTemplate() |
| 40 | { | 41 | { |
| @@ -57,12 +58,16 @@ private: | |||
| 57 | // Nz -> Nz | 58 | // Nz -> Nz |
| 58 | constexpr uint32_t KHALF = 2; | 59 | constexpr uint32_t KHALF = 2; |
| 59 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 60 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 60 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 61 | + auto srcStride = |
| 61 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 62 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 63 | + auto dstStride = | ||
| 64 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 62 | if constexpr (is_b4_type<DstType>) { | 65 | if constexpr (is_b4_type<DstType>) { |
| 63 | - LoadCbufToCaS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 66 | + LoadCbufToCaS43510::LoadData<trait>( |
| 67 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 64 | } else { | 68 | } else { |
| 65 | - LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 69 | + LoadCbufToCa3510::LoadData<trait>( |
| 70 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 66 | } | 71 | } |
| 67 | } | 72 | } |
| 68 | }; | 73 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/nz2nz_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/nz2nz_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0ANZ2NZWithCoord3510 { | 29 | class LoadDataL12L0ANZ2NZWithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, false>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, false>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -58,12 +58,16 @@ private: | |||
| 58 | // Nz -> Nz | 58 | // Nz -> Nz |
| 59 | constexpr uint32_t KHALF = 2; | 59 | constexpr uint32_t KHALF = 2; |
| 60 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 60 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 61 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 61 | + auto srcStride = |
| 62 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 62 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 63 | + auto dstStride = | ||
| 64 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 63 | if constexpr (is_b4_type<DstType>) { | 65 | if constexpr (is_b4_type<DstType>) { |
| 64 | - LoadCbufToCaS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition / KHALF, mStep, kStep, srcStride, dstStride); | 66 | + LoadCbufToCaS43510::LoadData<trait>( |
| 67 | + dst, src, mStartPosition, kStartPosition / KHALF, mStep, kStep, srcStride, dstStride); | ||
| 65 | } else { | 68 | } else { |
| 66 | - LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 69 | + LoadCbufToCa3510::LoadData<trait>( |
| 70 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 67 | } | 71 | } |
| 68 | } | 72 | } |
| 69 | }; | 73 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nz.h+20-16
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nz.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0AZN2NZ3510 { | 29 | class LoadDataL12L0AZN2NZ3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 31 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -39,7 +39,7 @@ private: | |||
| 39 | __aicore__ inline static constexpr void CheckTemplate() | 39 | __aicore__ inline static constexpr void CheckTemplate() |
| 40 | { | 40 | { |
| 41 | CheckFormat::CheckNZTemplate<T>(); | 41 | CheckFormat::CheckNZTemplate<T>(); |
| 42 | - CheckFormat::CheckZNTemplate<U>(); | 42 | + CheckFormat::CheckZNTemplate<U>(); |
| 43 | CheckDataTypeFor3510::CheckL12L0ADataType<T, U>(); | 43 | CheckDataTypeFor3510::CheckL12L0ADataType<T, U>(); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -53,13 +53,17 @@ private: | |||
| 53 | uint16_t mStartPosition = 0; | 53 | uint16_t mStartPosition = 0; |
| 54 | uint16_t kStartPosition = 0; | 54 | uint16_t kStartPosition = 0; |
| 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 56 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / FRACTAL_FIXED; | 56 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 57 | + FRACTAL_FIXED; | ||
| 57 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * | 58 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * |
| 58 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) / C0_ELEMENT<DstType>; | 59 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) / |
| 60 | + C0_ELEMENT<DstType>; | ||
| 59 | // Zn -> Nz | 61 | // Zn -> Nz |
| 60 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 62 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 61 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 63 | + auto srcStride = |
| 62 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 64 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 65 | + auto dstStride = | ||
| 66 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 63 | LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 67 | LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | } | 68 | } |
| 65 | }; | 69 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nz_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nz_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0AZN2NZWithCoord3510 { | 29 | class LoadDataL12L0AZN2NZWithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -53,13 +53,18 @@ private: | |||
| 53 | uint16_t mStartPosition = Std::get<1>(coord) / FRACTAL_FIXED; | 53 | uint16_t mStartPosition = Std::get<1>(coord) / FRACTAL_FIXED; |
| 54 | uint16_t kStartPosition = Std::get<0>(coord) / C0_ELEMENT<typename U::elementType>; | 54 | uint16_t kStartPosition = Std::get<0>(coord) / C0_ELEMENT<typename U::elementType>; |
| 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 56 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / FRACTAL_FIXED - mStartPosition; | 56 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 57 | + FRACTAL_FIXED - | ||
| 58 | + mStartPosition; | ||
| 57 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * | 59 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * |
| 58 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) / C0_ELEMENT<DstType>; | 60 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) / |
| 61 | + C0_ELEMENT<DstType>; | ||
| 59 | // Zn -> Nz | 62 | // Zn -> Nz |
| 60 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 63 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 61 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 64 | + auto srcStride = |
| 62 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 65 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 66 | + auto dstStride = | ||
| 67 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 63 | LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 68 | LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | } | 69 | } |
| 65 | }; | 70 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nzb8b4.h+40-28
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nzb8b4.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nzb8b4.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0AZN2NZB8B43510 { | 29 | class LoadDataL12L0AZN2NZB8B43510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 31 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -43,9 +43,10 @@ private: | |||
| 43 | CheckDataTypeFor3510::CheckL12L0ADataType<T, U>(); | 43 | CheckDataTypeFor3510::CheckL12L0ADataType<T, U>(); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | - template <const LoadDataTrait& trait, typename T, typename U> | 46 | + template <const LoadDataTrait& trait, typename T, typename U> |
| 47 | - __aicore__ inline static void LoadDataImplB4(const T& dst, const U& src, uint16_t mStartPosition, | 47 | + __aicore__ inline static void LoadDataImplB4( |
| 48 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 48 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 49 | + int16_t srcStride, uint16_t dstStride) | ||
| 49 | { | 50 | { |
| 50 | using DstType = typename T::elementType; | 51 | using DstType = typename T::elementType; |
| 51 | auto dstLayout = dst.Layout(); | 52 | auto dstLayout = dst.Layout(); |
| @@ -55,14 +56,16 @@ private: | |||
| 55 | mStep = M_STEP_MIN_VAL_B4; | 56 | mStep = M_STEP_MIN_VAL_B4; |
| 56 | for (uint16_t idx = 0; idx < mLoop; ++idx) { | 57 | for (uint16_t idx = 0; idx < mLoop; ++idx) { |
| 57 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); | 58 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); |
| 58 | - LoadCbufToCaS43510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 59 | + LoadCbufToCaS43510::LoadData<trait>( |
| 60 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 59 | mStartPosition += M_STEP_MIN_VAL_B4; | 61 | mStartPosition += M_STEP_MIN_VAL_B4; |
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | template <const LoadDataTrait& trait, typename T, typename U> | 65 | template <const LoadDataTrait& trait, typename T, typename U> |
| 64 | - __aicore__ inline static void LoadDataImplB8(const T& dst, const U& src, uint16_t mStartPosition, | 66 | + __aicore__ inline static void LoadDataImplB8( |
| 65 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 67 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 68 | + int16_t srcStride, uint16_t dstStride) | ||
| 66 | { | 69 | { |
| 67 | using DstType = typename T::elementType; | 70 | using DstType = typename T::elementType; |
| 68 | auto dstLayout = dst.Layout(); | 71 | auto dstLayout = dst.Layout(); |
| @@ -72,7 +75,8 @@ private: | |||
| 72 | mStep = M_STEP_MIN_VAL_B8; | 75 | mStep = M_STEP_MIN_VAL_B8; |
| 73 | for (uint16_t idx = 0; idx < mLoop; ++idx) { | 76 | for (uint16_t idx = 0; idx < mLoop; ++idx) { |
| 74 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); | 77 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); |
| 75 | - LoadCbufToCa3510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 78 | + LoadCbufToCa3510::LoadData<trait>( |
| 79 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 76 | mStartPosition += M_STEP_MIN_VAL_B8; | 80 | mStartPosition += M_STEP_MIN_VAL_B8; |
| 77 | } | 81 | } |
| 78 | } | 82 | } |
| @@ -87,28 +91,36 @@ private: | |||
| 87 | uint16_t mStartPosition = 0; | 91 | uint16_t mStartPosition = 0; |
| 88 | uint16_t kStartPosition = 0; | 92 | uint16_t kStartPosition = 0; |
| 89 | auto m1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 93 | auto m1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 90 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) - | 94 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) - |
| 91 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * | 95 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * |
| 92 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout); | 96 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout); |
| 93 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 97 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 94 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / FRACTAL_FIXED; | 98 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 99 | + FRACTAL_FIXED; | ||
| 95 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 100 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 96 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / C0_ELEMENT<DstType>; | 101 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 102 | + C0_ELEMENT<DstType>; | ||
| 97 | // Zn -> Nz | 103 | // Zn -> Nz |
| 98 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 104 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 99 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 105 | + auto srcStride = |
| 100 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 106 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 107 | + auto dstStride = | ||
| 108 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 101 | if constexpr (is_b4_type<DstType>) { | 109 | if constexpr (is_b4_type<DstType>) { |
| 102 | if (m1 < FRACTAL_FIXED) { | 110 | if (m1 < FRACTAL_FIXED) { |
| 103 | - LoadCbufToCaS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 111 | + LoadCbufToCaS43510::LoadData<trait>( |
| 112 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 104 | } else { | 113 | } else { |
| 105 | - LoadDataImplB4<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 114 | + LoadDataImplB4<trait, T, U>( |
| 115 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 106 | } | 116 | } |
| 107 | } else { | 117 | } else { |
| 108 | if (m1 < FRACTAL_FIXED) { | 118 | if (m1 < FRACTAL_FIXED) { |
| 109 | - LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 119 | + LoadCbufToCa3510::LoadData<trait>( |
| 120 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 110 | } else { | 121 | } else { |
| 111 | - LoadDataImplB8<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 122 | + LoadDataImplB8<trait, T, U>( |
| 123 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 112 | } | 124 | } |
| 113 | } | 125 | } |
| 114 | } | 126 | } |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nzb8b4_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0a/zn2nzb8b4_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0AZN2NZB8B4WithCoord3510 { | 29 | class LoadDataL12L0AZN2NZB8B4WithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -44,8 +44,9 @@ private: | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <const LoadDataTrait& trait, typename T, typename U> | 46 | template <const LoadDataTrait& trait, typename T, typename U> |
| 47 | - __aicore__ inline static void LoadDataImplB4(const T& dst, const U& src, uint16_t mStartPosition, | 47 | + __aicore__ inline static void LoadDataImplB4( |
| 48 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 48 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 49 | + int16_t srcStride, uint16_t dstStride) | ||
| 49 | { | 50 | { |
| 50 | using DstType = typename T::elementType; | 51 | using DstType = typename T::elementType; |
| 51 | auto dstLayout = dst.Layout(); | 52 | auto dstLayout = dst.Layout(); |
| @@ -55,14 +56,16 @@ private: | |||
| 55 | mStep = M_STEP_MIN_VAL_B4; | 56 | mStep = M_STEP_MIN_VAL_B4; |
| 56 | for (uint16_t idx = 0; idx < mLoop; ++idx) { | 57 | for (uint16_t idx = 0; idx < mLoop; ++idx) { |
| 57 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); | 58 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); |
| 58 | - LoadCbufToCaS43510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 59 | + LoadCbufToCaS43510::LoadData<trait>( |
| 60 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 59 | mStartPosition += M_STEP_MIN_VAL_B4; | 61 | mStartPosition += M_STEP_MIN_VAL_B4; |
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | template <const LoadDataTrait& trait, typename T, typename U> | 65 | template <const LoadDataTrait& trait, typename T, typename U> |
| 64 | - __aicore__ inline static void LoadDataImplB8(const T& dst, const U& src, uint16_t mStartPosition, | 66 | + __aicore__ inline static void LoadDataImplB8( |
| 65 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 67 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 68 | + int16_t srcStride, uint16_t dstStride) | ||
| 66 | { | 69 | { |
| 67 | using DstType = typename T::elementType; | 70 | using DstType = typename T::elementType; |
| 68 | auto dstLayout = dst.Layout(); | 71 | auto dstLayout = dst.Layout(); |
| @@ -72,7 +75,8 @@ private: | |||
| 72 | mStep = M_STEP_MIN_VAL_B8; | 75 | mStep = M_STEP_MIN_VAL_B8; |
| 73 | for (uint16_t idx = 0; idx < mLoop; ++idx) { | 76 | for (uint16_t idx = 0; idx < mLoop; ++idx) { |
| 74 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); | 77 | auto sliceDst = dst(MakeCoord(MakeCoord(0, 0), MakeCoord(0, idx))); |
| 75 | - LoadCbufToCa3510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 78 | + LoadCbufToCa3510::LoadData<trait>( |
| 79 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 76 | mStartPosition += M_STEP_MIN_VAL_B8; | 80 | mStartPosition += M_STEP_MIN_VAL_B8; |
| 77 | } | 81 | } |
| 78 | } | 82 | } |
| @@ -87,28 +91,39 @@ private: | |||
| 87 | uint16_t mStartPosition = Std::get<1>(coord) / FRACTAL_FIXED; | 91 | uint16_t mStartPosition = Std::get<1>(coord) / FRACTAL_FIXED; |
| 88 | uint16_t kStartPosition = Std::get<0>(coord) / C0_ELEMENT<DstType>; | 92 | uint16_t kStartPosition = Std::get<0>(coord) / C0_ELEMENT<DstType>; |
| 89 | auto m1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 93 | auto m1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 90 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) - | 94 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) - |
| 91 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * | 95 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout) * |
| 92 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) - Std::get<0>(coord); | 96 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(dstLayout) - |
| 97 | + Std::get<0>(coord); | ||
| 93 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 98 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 94 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / FRACTAL_FIXED - mStartPosition; | 99 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 100 | + FRACTAL_FIXED - | ||
| 101 | + mStartPosition; | ||
| 95 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 102 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 96 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / C0_ELEMENT<DstType> - kStartPosition; | 103 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 104 | + C0_ELEMENT<DstType> - | ||
| 105 | + kStartPosition; | ||
| 97 | // Zn -> Nz | 106 | // Zn -> Nz |
| 98 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 107 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 99 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 108 | + auto srcStride = |
| 100 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | 109 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 110 | + auto dstStride = | ||
| 111 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(dstLayout) / STRIDE_UNIT; | ||
| 101 | if constexpr (is_b4_type<DstType>) { | 112 | if constexpr (is_b4_type<DstType>) { |
| 102 | if (m1 < FRACTAL_FIXED) { | 113 | if (m1 < FRACTAL_FIXED) { |
| 103 | - LoadCbufToCaS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 114 | + LoadCbufToCaS43510::LoadData<trait>( |
| 115 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 104 | } else { | 116 | } else { |
| 105 | - LoadDataImplB4<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 117 | + LoadDataImplB4<trait, T, U>( |
| 118 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 106 | } | 119 | } |
| 107 | } else { | 120 | } else { |
| 108 | if (m1 < FRACTAL_FIXED) { | 121 | if (m1 < FRACTAL_FIXED) { |
| 109 | - LoadCbufToCa3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 122 | + LoadCbufToCa3510::LoadData<trait>( |
| 123 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 110 | } else { | 124 | } else { |
| 111 | - LoadDataImplB8<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 125 | + LoadDataImplB8<trait, T, U>( |
| 126 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 112 | } | 127 | } |
| 113 | } | 128 | } |
| 114 | } | 129 | } |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -34,13 +34,15 @@ namespace Te { | |||
| 34 | class LoadDataL12L0B3510 { | 34 | class LoadDataL12L0B3510 { |
| 35 | public: | 35 | public: |
| 36 | template <const LoadDataTrait& trait, typename T, typename U> | 36 | template <const LoadDataTrait& trait, typename T, typename U> |
| 37 | - __aicore__ inline void Run(const T& dst, const U& src) { | 37 | + __aicore__ inline void Run(const T& dst, const U& src) |
| 38 | + { | ||
| 38 | Execute<trait>(dst, src); | 39 | Execute<trait>(dst, src); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | private: | 42 | private: |
| 42 | template <const LoadDataTrait& trait, typename T, typename U> | 43 | template <const LoadDataTrait& trait, typename T, typename U> |
| 43 | - __aicore__ inline void Execute(const T& dst, const U& src) { | 44 | + __aicore__ inline void Execute(const T& dst, const U& src) |
| 45 | + { | ||
| 44 | if constexpr (IsZNFormat<U>::value && IsZNFormat<T>::value) { | 46 | if constexpr (IsZNFormat<U>::value && IsZNFormat<T>::value) { |
| 45 | LoadDataL12L0BZN2ZN3510::Run<trait, T, U>(dst, src); | 47 | LoadDataL12L0BZN2ZN3510::Run<trait, T, U>(dst, src); |
| 46 | } else if constexpr (IsNZFormat<U>::value && IsZNFormat<T>::value && (sizeof(typename U::elementType) == 1)) { | 48 | } else if constexpr (IsNZFormat<U>::value && IsZNFormat<T>::value && (sizeof(typename U::elementType) == 1)) { |
| @@ -54,13 +56,15 @@ private: | |||
| 54 | class LoadDataL12L0BWithCoord3510 { | 56 | class LoadDataL12L0BWithCoord3510 { |
| 55 | public: | 57 | public: |
| 56 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> | 58 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> |
| 57 | - __aicore__ inline void Run(const T& dst, const U& src, const Coord& coord) { | 59 | + __aicore__ inline void Run(const T& dst, const U& src, const Coord& coord) |
| 60 | + { | ||
| 58 | Execute<trait>(dst, src, coord); | 61 | Execute<trait>(dst, src, coord); |
| 59 | } | 62 | } |
| 60 | 63 | ||
| 61 | private: | 64 | private: |
| 62 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> | 65 | template <const LoadDataTrait& trait, typename T, typename U, class Coord> |
| 63 | - __aicore__ inline void Execute(const T& dst, const U& src, const Coord& coord) { | 66 | + __aicore__ inline void Execute(const T& dst, const U& src, const Coord& coord) |
| 67 | + { | ||
| 64 | if constexpr (IsZNFormat<U>::value && IsZNFormat<T>::value) { | 68 | if constexpr (IsZNFormat<U>::value && IsZNFormat<T>::value) { |
| 65 | LoadDataL12L0BZN2ZNWithCoord3510::Run<trait, T, U, Coord>(dst, src, coord); | 69 | LoadDataL12L0BZN2ZNWithCoord3510::Run<trait, T, U, Coord>(dst, src, coord); |
| 66 | } else if constexpr (IsNZFormat<U>::value && IsZNFormat<T>::value && (sizeof(typename U::elementType) == 1)) { | 70 | } else if constexpr (IsNZFormat<U>::value && IsZNFormat<T>::value && (sizeof(typename U::elementType) == 1)) { |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2zn.h+19-15
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BNZ2ZN3510 { | 29 | class LoadDataL12L0BNZ2ZN3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 31 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -53,13 +53,17 @@ private: | |||
| 53 | auto mStartPosition = 0; | 53 | auto mStartPosition = 0; |
| 54 | auto kStartPosition = 0; | 54 | auto kStartPosition = 0; |
| 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 56 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / FRACTAL_FIXED; | 56 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 57 | + FRACTAL_FIXED; | ||
| 57 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * | 58 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * |
| 58 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) / C0_ELEMENT<DstType>; | 59 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) / |
| 60 | + C0_ELEMENT<DstType>; | ||
| 59 | // Nz -> Zn | 61 | // Nz -> Zn |
| 60 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 62 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 61 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 63 | + auto srcStride = |
| 62 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 64 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 65 | + auto dstStride = | ||
| 66 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 63 | LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 67 | LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | } | 68 | } |
| 65 | }; | 69 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2zn_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2zn_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BNZ2ZNWithCoord3510 { | 29 | class LoadDataL12L0BNZ2ZNWithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -53,13 +53,18 @@ private: | |||
| 53 | auto mStartPosition = Std::get<0>(coord) / FRACTAL_FIXED; | 53 | auto mStartPosition = Std::get<0>(coord) / FRACTAL_FIXED; |
| 54 | auto kStartPosition = Std::get<1>(coord) / C0_ELEMENT<DstType>; | 54 | auto kStartPosition = Std::get<1>(coord) / C0_ELEMENT<DstType>; |
| 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 55 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 56 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / FRACTAL_FIXED - mStartPosition; | 56 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 57 | + FRACTAL_FIXED - | ||
| 58 | + mStartPosition; | ||
| 57 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * | 59 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * |
| 58 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) / C0_ELEMENT<DstType>; | 60 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) / |
| 61 | + C0_ELEMENT<DstType>; | ||
| 59 | // Nz -> Zn | 62 | // Nz -> Zn |
| 60 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 63 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 61 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 64 | + auto srcStride = |
| 62 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 65 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 66 | + auto dstStride = | ||
| 67 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 63 | LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 68 | LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | } | 69 | } |
| 65 | }; | 70 | }; |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2znb8b4.h+39-27
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2znb8b4.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2znb8b4.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BNZ2ZNB8B43510 { | 29 | class LoadDataL12L0BNZ2ZNB8B43510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 31 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U>(dst, src); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -44,8 +44,9 @@ private: | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <const LoadDataTrait& trait, typename T, typename U> | 46 | template <const LoadDataTrait& trait, typename T, typename U> |
| 47 | - __aicore__ inline static void LoadDataImplB4(const T& dst, const U& src, uint16_t mStartPosition, | 47 | + __aicore__ inline static void LoadDataImplB4( |
| 48 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 48 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 49 | + int16_t srcStride, uint16_t dstStride) | ||
| 49 | { | 50 | { |
| 50 | using DstType = typename T::elementType; | 51 | using DstType = typename T::elementType; |
| 51 | auto dstLayout = dst.Layout(); | 52 | auto dstLayout = dst.Layout(); |
| @@ -55,14 +56,16 @@ private: | |||
| 55 | mStep = M_STEP_MIN_VAL_B4; | 56 | mStep = M_STEP_MIN_VAL_B4; |
| 56 | for (uint16_t idx = 0; idx < nLoop; ++idx) { | 57 | for (uint16_t idx = 0; idx < nLoop; ++idx) { |
| 57 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); | 58 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); |
| 58 | - LoadCbufToCbS43510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 59 | + LoadCbufToCbS43510::LoadData<trait>( |
| 60 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 59 | mStartPosition += M_STEP_MIN_VAL_B4; | 61 | mStartPosition += M_STEP_MIN_VAL_B4; |
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | template <const LoadDataTrait& trait, typename T, typename U> | 65 | template <const LoadDataTrait& trait, typename T, typename U> |
| 64 | - __aicore__ inline static void LoadDataImplB8(const T& dst, const U& src, uint16_t mStartPosition, | 66 | + __aicore__ inline static void LoadDataImplB8( |
| 65 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 67 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 68 | + int16_t srcStride, uint16_t dstStride) | ||
| 66 | { | 69 | { |
| 67 | using DstType = typename T::elementType; | 70 | using DstType = typename T::elementType; |
| 68 | auto dstLayout = dst.Layout(); | 71 | auto dstLayout = dst.Layout(); |
| @@ -72,7 +75,8 @@ private: | |||
| 72 | mStep = M_STEP_MIN_VAL_B8; | 75 | mStep = M_STEP_MIN_VAL_B8; |
| 73 | for (uint16_t idx = 0; idx < nLoop; ++idx) { | 76 | for (uint16_t idx = 0; idx < nLoop; ++idx) { |
| 74 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); | 77 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); |
| 75 | - LoadCbufToCb3510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 78 | + LoadCbufToCb3510::LoadData<trait>( |
| 79 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 76 | mStartPosition += M_STEP_MIN_VAL_B8; | 80 | mStartPosition += M_STEP_MIN_VAL_B8; |
| 77 | } | 81 | } |
| 78 | } | 82 | } |
| @@ -87,28 +91,36 @@ private: | |||
| 87 | auto mStartPosition = 0; | 91 | auto mStartPosition = 0; |
| 88 | auto kStartPosition = 0; | 92 | auto kStartPosition = 0; |
| 89 | auto n1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 93 | auto n1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 90 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) - | 94 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) - |
| 91 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * | 95 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * |
| 92 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout); | 96 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout); |
| 93 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 97 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 94 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / FRACTAL_FIXED; | 98 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 99 | + FRACTAL_FIXED; | ||
| 95 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 100 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 96 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / C0_ELEMENT<DstType>; | 101 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 102 | + C0_ELEMENT<DstType>; | ||
| 97 | // Nz -> Zn | 103 | // Nz -> Zn |
| 98 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 104 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 99 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 105 | + auto srcStride = |
| 100 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 106 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 107 | + auto dstStride = | ||
| 108 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 101 | if constexpr (is_b4_type<DstType>) { | 109 | if constexpr (is_b4_type<DstType>) { |
| 102 | if (n1 < FRACTAL_FIXED) { | 110 | if (n1 < FRACTAL_FIXED) { |
| 103 | - LoadCbufToCbS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 111 | + LoadCbufToCbS43510::LoadData<trait>( |
| 112 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 104 | } else { | 113 | } else { |
| 105 | - LoadDataImplB4<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 114 | + LoadDataImplB4<trait, T, U>( |
| 115 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 106 | } | 116 | } |
| 107 | } else { | 117 | } else { |
| 108 | if (n1 < FRACTAL_FIXED) { | 118 | if (n1 < FRACTAL_FIXED) { |
| 109 | - LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 119 | + LoadCbufToCb3510::LoadData<trait>( |
| 120 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 110 | } else { | 121 | } else { |
| 111 | - LoadDataImplB8<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 122 | + LoadDataImplB8<trait, T, U>( |
| 123 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 112 | } | 124 | } |
| 113 | } | 125 | } |
| 114 | } | 126 | } |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2znb8b4_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/nz2znb8b4_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BNZ2ZNB8B4WithCoord3510 { | 29 | class LoadDataL12L0BNZ2ZNB8B4WithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, true>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -44,8 +44,9 @@ private: | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <const LoadDataTrait& trait, typename T, typename U> | 46 | template <const LoadDataTrait& trait, typename T, typename U> |
| 47 | - __aicore__ inline static void LoadDataImplB4(const T& dst, const U& src, uint16_t mStartPosition, | 47 | + __aicore__ inline static void LoadDataImplB4( |
| 48 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 48 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 49 | + int16_t srcStride, uint16_t dstStride) | ||
| 49 | { | 50 | { |
| 50 | using DstType = typename T::elementType; | 51 | using DstType = typename T::elementType; |
| 51 | auto dstLayout = dst.Layout(); | 52 | auto dstLayout = dst.Layout(); |
| @@ -55,14 +56,16 @@ private: | |||
| 55 | mStep = M_STEP_MIN_VAL_B4; | 56 | mStep = M_STEP_MIN_VAL_B4; |
| 56 | for (uint16_t idx = 0; idx < nLoop; ++idx) { | 57 | for (uint16_t idx = 0; idx < nLoop; ++idx) { |
| 57 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); | 58 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); |
| 58 | - LoadCbufToCbS43510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 59 | + LoadCbufToCbS43510::LoadData<trait>( |
| 60 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 59 | mStartPosition += M_STEP_MIN_VAL_B4; | 61 | mStartPosition += M_STEP_MIN_VAL_B4; |
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | template <const LoadDataTrait& trait, typename T, typename U> | 65 | template <const LoadDataTrait& trait, typename T, typename U> |
| 64 | - __aicore__ inline static void LoadDataImplB8(const T& dst, const U& src, uint16_t mStartPosition, | 66 | + __aicore__ inline static void LoadDataImplB8( |
| 65 | - uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, int16_t srcStride, uint16_t dstStride) | 67 | + const T& dst, const U& src, uint16_t mStartPosition, uint16_t kStartPosition, uint8_t mStep, uint8_t kStep, |
| 68 | + int16_t srcStride, uint16_t dstStride) | ||
| 66 | { | 69 | { |
| 67 | using DstType = typename T::elementType; | 70 | using DstType = typename T::elementType; |
| 68 | auto dstLayout = dst.Layout(); | 71 | auto dstLayout = dst.Layout(); |
| @@ -72,7 +75,8 @@ private: | |||
| 72 | mStep = M_STEP_MIN_VAL_B8; | 75 | mStep = M_STEP_MIN_VAL_B8; |
| 73 | for (uint16_t idx = 0; idx < nLoop; ++idx) { | 76 | for (uint16_t idx = 0; idx < nLoop; ++idx) { |
| 74 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); | 77 | auto sliceDst = dst(MakeCoord(MakeCoord(0, idx), MakeCoord(0, 0))); |
| 75 | - LoadCbufToCb3510::LoadData<trait>(sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 78 | + LoadCbufToCb3510::LoadData<trait>( |
| 79 | + sliceDst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 76 | mStartPosition += M_STEP_MIN_VAL_B8; | 80 | mStartPosition += M_STEP_MIN_VAL_B8; |
| 77 | } | 81 | } |
| 78 | } | 82 | } |
| @@ -87,28 +91,39 @@ private: | |||
| 87 | auto mStartPosition = Std::get<0>(coord) / FRACTAL_FIXED; | 91 | auto mStartPosition = Std::get<0>(coord) / FRACTAL_FIXED; |
| 88 | auto kStartPosition = Std::get<1>(coord) / C0_ELEMENT<DstType>; | 92 | auto kStartPosition = Std::get<1>(coord) / C0_ELEMENT<DstType>; |
| 89 | auto n1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 93 | auto n1 = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 90 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) - | 94 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) - |
| 91 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * | 95 | GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(dstLayout) * |
| 92 | - GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) - Std::get<1>(coord); | 96 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(dstLayout) - |
| 97 | + Std::get<1>(coord); | ||
| 93 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * | 98 | auto mStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(srcLayout) * |
| 94 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / FRACTAL_FIXED - mStartPosition; | 99 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::ROW, 0>(srcLayout) / |
| 100 | + FRACTAL_FIXED - | ||
| 101 | + mStartPosition; | ||
| 95 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * | 102 | auto kStep = GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 1>(srcLayout) * |
| 96 | - GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / C0_ELEMENT<DstType> - kStartPosition; | 103 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::SHAPE, AttrInfo::COLUMN, 0>(srcLayout) / |
| 104 | + C0_ELEMENT<DstType> - | ||
| 105 | + kStartPosition; | ||
| 97 | // Nz -> Zn | 106 | // Nz -> Zn |
| 98 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 107 | constexpr uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 99 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; | 108 | + auto srcStride = |
| 100 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 109 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::COLUMN, 1>(srcLayout) / STRIDE_UNIT; |
| 110 | + auto dstStride = | ||
| 111 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 101 | if constexpr (is_b4_type<DstType>) { | 112 | if constexpr (is_b4_type<DstType>) { |
| 102 | if (n1 < FRACTAL_FIXED) { | 113 | if (n1 < FRACTAL_FIXED) { |
| 103 | - LoadCbufToCbS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 114 | + LoadCbufToCbS43510::LoadData<trait>( |
| 115 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 104 | } else { | 116 | } else { |
| 105 | - LoadDataImplB4<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 117 | + LoadDataImplB4<trait, T, U>( |
| 118 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 106 | } | 119 | } |
| 107 | } else { | 120 | } else { |
| 108 | if (n1 < FRACTAL_FIXED) { | 121 | if (n1 < FRACTAL_FIXED) { |
| 109 | - LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 122 | + LoadCbufToCb3510::LoadData<trait>( |
| 123 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 110 | } else { | 124 | } else { |
| 111 | - LoadDataImplB8<trait, T, U>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 125 | + LoadDataImplB8<trait, T, U>( |
| 126 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 112 | } | 127 | } |
| 113 | } | 128 | } |
| 114 | } | 129 | } |
Mimpl/experimental/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/zn2zn.h+20-17
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/zn2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/zn2zn.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BZN2ZN3510 { | 29 | class LoadDataL12L0BZN2ZN3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U> | 31 | template <const LoadDataTrait& trait, typename T, typename U> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, false>, T, U>(dst, src); | 34 | LoadDataImpl<TransTrait<trait, false>, T, U>(dst, src); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -56,13 +56,16 @@ private: | |||
| 56 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout); | 56 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout); |
| 57 | // Zn -> Zn | 57 | // Zn -> Zn |
| 58 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 58 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 59 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 59 | + auto srcStride = |
| 60 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 60 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 61 | + auto dstStride = | ||
| 62 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 61 | if constexpr (is_b4_type<DstType>) { | 63 | if constexpr (is_b4_type<DstType>) { |
| 62 | - LoadCbufToCbS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 64 | + LoadCbufToCbS43510::LoadData<trait>( |
| 63 | - } | 65 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | - else { | 66 | + } else { |
| 65 | - LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 67 | + LoadCbufToCb3510::LoadData<trait>( |
| 68 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 66 | } | 69 | } |
| 67 | } | 70 | } |
| 68 | }; | 71 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/zn2zn_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/cube_datamove/load_data/npu_arch_3510/load_data_l12l0b/zn2zn_with_coord.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -27,10 +27,10 @@ | |||
| 27 | namespace AscendC { | 27 | namespace AscendC { |
| 28 | namespace Te { | 28 | namespace Te { |
| 29 | class LoadDataL12L0BZN2ZNWithCoord3510 { | 29 | class LoadDataL12L0BZN2ZNWithCoord3510 { |
| 30 | - | ||
| 31 | public: | 30 | public: |
| 32 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> | 31 | template <const LoadDataTrait& trait, typename T, typename U, typename Coord> |
| 33 | - __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) { | 32 | + __aicore__ inline static void Run(const T& dst, const U& src, const Coord& coord) |
| 33 | + { | ||
| 34 | LoadDataImpl<TransTrait<trait, false>, T, U, Coord>(dst, src, coord); | 34 | LoadDataImpl<TransTrait<trait, false>, T, U, Coord>(dst, src, coord); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -56,13 +56,16 @@ private: | |||
| 56 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout); | 56 | auto kStep = GetEleFromLayout<decltype(dstLayout), AttrInfo::SHAPE, AttrInfo::ROW, 1>(dstLayout); |
| 57 | // Zn -> Zn | 57 | // Zn -> Zn |
| 58 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; | 58 | uint32_t STRIDE_UNIT = C0_ELEMENT<DstType> * FRACTAL_FIXED; |
| 59 | - auto srcStride = GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; | 59 | + auto srcStride = |
| 60 | - auto dstStride = GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | 60 | + GetEleFromLayout<decltype(srcLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(srcLayout) / STRIDE_UNIT; |
| 61 | + auto dstStride = | ||
| 62 | + GetEleFromLayout<decltype(dstLayout), AttrInfo::STRIDE, AttrInfo::ROW, 1>(dstLayout) / STRIDE_UNIT; | ||
| 61 | if constexpr (is_b4_type<DstType>) { | 63 | if constexpr (is_b4_type<DstType>) { |
| 62 | - LoadCbufToCbS43510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 64 | + LoadCbufToCbS43510::LoadData<trait>( |
| 63 | - } | 65 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); |
| 64 | - else { | 66 | + } else { |
| 65 | - LoadCbufToCb3510::LoadData<trait>(dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | 67 | + LoadCbufToCb3510::LoadData<trait>( |
| 68 | + dst, src, mStartPosition, kStartPosition, mStep, kStep, srcStride, dstStride); | ||
| 66 | } | 69 | } |
| 67 | } | 70 | } |
| 68 | }; | 71 | }; |
| @@ -1,15 +1,15 @@ | |||
| 1 | /** | 1 | /** |
| 2 | -* Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | -* See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -*/ | 9 | + */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/utils/arch_utils.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/utils/arch_utils.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -29,11 +29,12 @@ | |||
| 29 | namespace AscendC { | 29 | namespace AscendC { |
| 30 | namespace Te { | 30 | namespace Te { |
| 31 | 31 | ||
| 32 | -template<const LoadDataTrait& trait, bool transpose> | 32 | +template <const LoadDataTrait& trait, bool transpose> |
| 33 | -constexpr LoadDataTrait TransTrait = LoadDataTrait(trait, transpose); | 33 | +constexpr LoadDataTrait TransTrait = LoadDataTrait(trait, transpose); |
| 34 | 34 | ||
| 35 | template <typename T> | 35 | template <typename T> |
| 36 | -__aicore__ inline uint8_t GetCacheModeFromTensor(const T& tensor) { | 36 | +__aicore__ inline uint8_t GetCacheModeFromTensor(const T& tensor) |
| 37 | +{ | ||
| 37 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { | 38 | if constexpr (CURRENT_ARCH_VERSION == ArchVersion::V3510) { |
| 38 | return static_cast<uint8_t>((reinterpret_cast<uint64_t>(tensor.Data().Get())) >> L2_CACHE_OFFSET); | 39 | return static_cast<uint8_t>((reinterpret_cast<uint64_t>(tensor.Data().Get())) >> L2_CACHE_OFFSET); |
| 39 | } else { | 40 | } else { |
| @@ -42,9 +43,10 @@ __aicore__ inline uint8_t GetCacheModeFromTensor(const T& tensor) { | |||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | 45 | ||
| 45 | -#define SCALAR_QUANT_MODE QuantMode_t::DEQF16, QuantMode_t::QF322B8_PRE, QuantMode_t::REQ8,\ | 46 | +#define SCALAR_QUANT_MODE \ |
| 46 | - QuantMode_t::QS322BF16_PRE, QuantMode_t::QF322F16_PRE, QuantMode_t::QF322BF16_PRE, QuantMode_t::QF322FP8_PRE,\ | 47 | + QuantMode_t::DEQF16, QuantMode_t::QF322B8_PRE, QuantMode_t::REQ8, QuantMode_t::QS322BF16_PRE, \ |
| 47 | - QuantMode_t::QF322HIF8_PRE, QuantMode_t::QF322HIF8_PRE_HYBRID, QuantMode_t::QF322F32_PRE | 48 | + QuantMode_t::QF322F16_PRE, QuantMode_t::QF322BF16_PRE, QuantMode_t::QF322FP8_PRE, QuantMode_t::QF322HIF8_PRE, \ |
| 49 | + QuantMode_t::QF322HIF8_PRE_HYBRID, QuantMode_t::QF322F32_PRE | ||
| 48 | 50 | ||
| 49 | 51 | ||
| 50 | 52 | ||
| @@ -55,9 +57,10 @@ template <QuantMode_t quantPre> | |||
| 55 | using IsScalarQuantMode = Std::is_one_of_value<QuantMode_t, quantPre, SCALAR_QUANT_MODE>; | 57 | using IsScalarQuantMode = Std::is_one_of_value<QuantMode_t, quantPre, SCALAR_QUANT_MODE>; |
| 56 | 58 | ||
| 57 | 59 | ||
| 58 | -#define TILE_OP_INTERNAL_TENSOR_QUANT_MODE QuantMode_t::VDEQF16, QuantMode_t::VQF322B8_PRE, QuantMode_t::VREQ8,\ | 60 | +#define TILE_OP_INTERNAL_TENSOR_QUANT_MODE \ |
| 59 | - QuantMode_t::VQS322BF16_PRE, QuantMode_t::VQF322F16_PRE, QuantMode_t::VQF322BF16_PRE, QuantMode_t::VQF322FP8_PRE,\ | 61 | + QuantMode_t::VDEQF16, QuantMode_t::VQF322B8_PRE, QuantMode_t::VREQ8, QuantMode_t::VQS322BF16_PRE, \ |
| 60 | - QuantMode_t::VQF322HIF8_PRE, QuantMode_t::VQF322HIF8_PRE_HYBRID, QuantMode_t::VQF322F32_PRE | 62 | + QuantMode_t::VQF322F16_PRE, QuantMode_t::VQF322BF16_PRE, QuantMode_t::VQF322FP8_PRE, \ |
| 63 | + QuantMode_t::VQF322HIF8_PRE, QuantMode_t::VQF322HIF8_PRE_HYBRID, QuantMode_t::VQF322F32_PRE | ||
| 61 | 64 | ||
| 62 | 65 | ||
| 63 | 66 | ||
| @@ -79,7 +82,8 @@ template <QuantMode_t quantPre> | |||
| 79 | using IsDirectQuantMode = Std::is_one_of_value<QuantMode_t, quantPre, TILE_OP_INTERNAL_DIRECT_QUANT_MODE>; | 82 | using IsDirectQuantMode = Std::is_one_of_value<QuantMode_t, quantPre, TILE_OP_INTERNAL_DIRECT_QUANT_MODE>; |
| 80 | 83 | ||
| 81 | template <typename T, AttrInfo info1, AttrInfo info2, size_t dim> | 84 | template <typename T, AttrInfo info1, AttrInfo info2, size_t dim> |
| 82 | -__aicore__ inline constexpr decltype(auto) GetEleFromLayout(const T& layout) { | 85 | +__aicore__ inline constexpr decltype(auto) GetEleFromLayout(const T& layout) |
| 86 | +{ | ||
| 83 | if constexpr (info1 == AttrInfo::SHAPE && info2 == AttrInfo::ROW) { | 87 | if constexpr (info1 == AttrInfo::SHAPE && info2 == AttrInfo::ROW) { |
| 84 | return Std::get<dim>(Std::get<0>(layout.Shape())); | 88 | return Std::get<dim>(Std::get<0>(layout.Shape())); |
| 85 | } else if constexpr (info1 == AttrInfo::SHAPE && info2 == AttrInfo::COLUMN) { | 89 | } else if constexpr (info1 == AttrInfo::SHAPE && info2 == AttrInfo::COLUMN) { |
| @@ -88,10 +92,9 @@ __aicore__ inline constexpr decltype(auto) GetEleFromLayout(const T& layout) { | |||
| 88 | return Std::get<dim>(Std::get<0>(layout.Stride())); | 92 | return Std::get<dim>(Std::get<0>(layout.Stride())); |
| 89 | } else if constexpr (info1 == AttrInfo::STRIDE && info2 == AttrInfo::COLUMN) { | 93 | } else if constexpr (info1 == AttrInfo::STRIDE && info2 == AttrInfo::COLUMN) { |
| 90 | return Std::get<dim>(Std::get<1>(layout.Stride())); | 94 | return Std::get<dim>(Std::get<1>(layout.Stride())); |
| 91 | - } | 95 | + } |
| 92 | } | 96 | } |
| 93 | 97 | ||
| 94 | - | ||
| 95 | } // namespace Te | 98 | } // namespace Te |
| 96 | } // namespace AscendC | 99 | } // namespace AscendC |
| 97 | 100 | ||
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/utils/check_data_type_3510.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/utils/check_data_type_3510.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -38,16 +38,18 @@ public: | |||
| 38 | using filterDataType = typename S::elementType; | 38 | using filterDataType = typename S::elementType; |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | - static_assert(Std::is_one_of_v<Std::tuple<dstDataType, fmDataType, filterDataType>, | 41 | + static_assert( |
| 42 | - Std::tuple<__cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, | 42 | + Std::is_one_of_v< |
| 43 | - Std::tuple<__cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, | 43 | + Std::tuple<dstDataType, fmDataType, filterDataType>, |
| 44 | - Std::tuple<__cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, | 44 | + Std::tuple<__cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, |
| 45 | - Std::tuple<__cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, | 45 | + Std::tuple<__cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, |
| 46 | - Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 46 | + Std::tuple<__cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, |
| 47 | - Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 47 | + Std::tuple<__cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, |
| 48 | - Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 48 | + Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 49 | - Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | 49 | + Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 50 | - "The data type is not supported for L0C position."); | 50 | + Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 51 | + Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | ||
| 52 | + "The data type is not supported for L0C position."); | ||
| 51 | 53 | ||
| 52 | } | 54 | } |
| 53 | 55 | ||
| @@ -62,27 +64,29 @@ public: | |||
| 62 | 64 | ||
| 63 | if constexpr (biasPos == Hardware::BIAS) { | 65 | if constexpr (biasPos == Hardware::BIAS) { |
| 64 | static_assert( | 66 | static_assert( |
| 65 | - Std::is_one_of_v<Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, | 67 | + Std::is_one_of_v< |
| 66 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, | 68 | + Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, |
| 67 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, | 69 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, |
| 68 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, | 70 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, |
| 69 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, | 71 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, |
| 70 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 72 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, |
| 71 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 73 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 72 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 74 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 73 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | 75 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 76 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | ||
| 74 | "The data type is not supported for BIAS position."); | 77 | "The data type is not supported for BIAS position."); |
| 75 | } else if constexpr (biasPos == Hardware::L0C) { | 78 | } else if constexpr (biasPos == Hardware::L0C) { |
| 76 | static_assert( | 79 | static_assert( |
| 77 | - Std::is_one_of_v<Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, | 80 | + Std::is_one_of_v< |
| 78 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, | 81 | + Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, |
| 79 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, | 82 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e2m1_t>, |
| 80 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, | 83 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e2m1_t, __cb__ fp4x2_e1m2_t>, |
| 81 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, | 84 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e2m1_t>, |
| 82 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 85 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp4x2_e1m2_t, __cb__ fp4x2_e1m2_t>, |
| 83 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 86 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 84 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 87 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 85 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | 88 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 89 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>>, | ||
| 86 | "The data type is not supported for L0C position."); | 90 | "The data type is not supported for L0C position."); |
| 87 | } | 91 | } |
| 88 | 92 | ||
| @@ -96,17 +100,19 @@ public: | |||
| 96 | using filterDataType = typename S::elementType; | 100 | using filterDataType = typename S::elementType; |
| 97 | 101 | ||
| 98 | 102 | ||
| 99 | - static_assert(Std::is_one_of_v<Std::tuple<dstDataType, fmDataType, filterDataType>, | 103 | + static_assert( |
| 100 | - Std::tuple<__cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, | 104 | + Std::is_one_of_v< |
| 101 | - Std::tuple<__cc__ float, __ca__ half, __cb__ half>, | 105 | + Std::tuple<dstDataType, fmDataType, filterDataType>, |
| 102 | - Std::tuple<__cc__ float, __ca__ float, __cb__ float>, | 106 | + Std::tuple<__cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, |
| 103 | - Std::tuple<__cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, | 107 | + Std::tuple<__cc__ float, __ca__ half, __cb__ half>, |
| 104 | - Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 108 | + Std::tuple<__cc__ float, __ca__ float, __cb__ float>, |
| 105 | - Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 109 | + Std::tuple<__cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, |
| 106 | - Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 110 | + Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 107 | - Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, | 111 | + Std::tuple<__cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 108 | - Std::tuple< __cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | 112 | + Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 109 | - "The data type is not supported for L0C position."); | 113 | + Std::tuple<__cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, |
| 114 | + Std::tuple<__cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | ||
| 115 | + "The data type is not supported for L0C position."); | ||
| 110 | 116 | ||
| 111 | } | 117 | } |
| 112 | 118 | ||
| @@ -122,29 +128,31 @@ public: | |||
| 122 | 128 | ||
| 123 | if constexpr (biasPos == Hardware::BIAS) { | 129 | if constexpr (biasPos == Hardware::BIAS) { |
| 124 | static_assert( | 130 | static_assert( |
| 125 | - Std::is_one_of_v<Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, | 131 | + Std::is_one_of_v< |
| 126 | - Std::tuple<__biasbuf__ int32_t, __cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, | 132 | + Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, |
| 127 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ half, __cb__ half>, | 133 | + Std::tuple<__biasbuf__ int32_t, __cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, |
| 128 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ float, __cb__ float>, | 134 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ half, __cb__ half>, |
| 129 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, | 135 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ float, __cb__ float>, |
| 130 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 136 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, |
| 131 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 137 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 132 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 138 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 133 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, | 139 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 134 | - Std::tuple<__biasbuf__ float, __cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | 140 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, |
| 141 | + Std::tuple<__biasbuf__ float, __cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | ||
| 135 | "The data type is not supported for BIAS position."); | 142 | "The data type is not supported for BIAS position."); |
| 136 | } else if constexpr (biasPos == Hardware::L0C) { | 143 | } else if constexpr (biasPos == Hardware::L0C) { |
| 137 | static_assert( | 144 | static_assert( |
| 138 | - Std::is_one_of_v<Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, | 145 | + Std::is_one_of_v< |
| 139 | - Std::tuple<__cc__ int32_t, __cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, | 146 | + Std::tuple<biasDataType, dstDataType, fmDataType, filterDataType>, |
| 140 | - Std::tuple<__cc__ float, __cc__ float, __ca__ half, __cb__ half>, | 147 | + Std::tuple<__cc__ int32_t, __cc__ int32_t, __ca__ int8_t, __cb__ int8_t>, |
| 141 | - Std::tuple<__cc__ float, __cc__ float, __ca__ float, __cb__ float>, | 148 | + Std::tuple<__cc__ float, __cc__ float, __ca__ half, __cb__ half>, |
| 142 | - Std::tuple<__cc__ float, __cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, | 149 | + Std::tuple<__cc__ float, __cc__ float, __ca__ float, __cb__ float>, |
| 143 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, | 150 | + Std::tuple<__cc__ float, __cc__ float, __ca__ bfloat16_t, __cb__ bfloat16_t>, |
| 144 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, | 151 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e4m3fn_t>, |
| 145 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, | 152 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e4m3fn_t, __cb__ fp8_e5m2_t>, |
| 146 | - Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, | 153 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e4m3fn_t>, |
| 147 | - Std::tuple<__cc__ float, __cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | 154 | + Std::tuple<__cc__ float, __cc__ float, __ca__ fp8_e5m2_t, __cb__ fp8_e5m2_t>, |
| 155 | + Std::tuple<__cc__ float, __cc__ float, __ca__ hifloat8_t, __cb__ hifloat8_t>>, | ||
| 148 | "The data type is not supported for L0C position."); | 156 | "The data type is not supported for L0C position."); |
| 149 | } | 157 | } |
| 150 | 158 | ||
| @@ -157,16 +165,17 @@ public: | |||
| 157 | using srcDataType = typename U::elementType; | 165 | using srcDataType = typename U::elementType; |
| 158 | 166 | ||
| 159 | 167 | ||
| 160 | - static_assert(Std::is_one_of_v< | 168 | + static_assert( |
| 161 | - Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, | 169 | + Std::is_one_of_v< |
| 162 | - Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, | 170 | + Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, |
| 163 | - Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, | 171 | + Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, |
| 164 | - Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, | 172 | + Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, |
| 165 | - Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, | 173 | + Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, |
| 166 | - Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, | 174 | + Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, |
| 167 | - Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, | 175 | + Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, |
| 168 | - Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, | 176 | + Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, |
| 169 | - "The data type is not supported."); | 177 | + Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, |
| 178 | + "The data type is not supported."); | ||
| 170 | 179 | ||
| 171 | } | 180 | } |
| 172 | 181 | ||
| @@ -177,18 +186,19 @@ public: | |||
| 177 | using dstDataType = typename T::elementType; | 186 | using dstDataType = typename T::elementType; |
| 178 | 187 | ||
| 179 | 188 | ||
| 180 | - static_assert(Std::is_one_of_v< | 189 | + static_assert( |
| 181 | - Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, | 190 | + Std::is_one_of_v< |
| 182 | - Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, | 191 | + Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, |
| 183 | - Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, | 192 | + Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, |
| 184 | - Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, | 193 | + Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, |
| 185 | - Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, | 194 | + Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, |
| 186 | - Std::tuple<__cbuf__ fp4x2_e1m2_t, __gm__ fp4x2_e1m2_t>, | 195 | + Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, |
| 187 | - Std::tuple<__cbuf__ fp4x2_e2m1_t, __gm__ fp4x2_e2m1_t>, | 196 | + Std::tuple<__cbuf__ fp4x2_e1m2_t, __gm__ fp4x2_e1m2_t>, |
| 188 | - Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, | 197 | + Std::tuple<__cbuf__ fp4x2_e2m1_t, __gm__ fp4x2_e2m1_t>, |
| 189 | - Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, | 198 | + Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, |
| 190 | - Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, | 199 | + Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, |
| 191 | - "The data type is not supported."); | 200 | + Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, |
| 201 | + "The data type is not supported."); | ||
| 192 | 202 | ||
| 193 | } | 203 | } |
| 194 | 204 | ||
| @@ -212,17 +222,18 @@ public: | |||
| 212 | using dstDataType = typename T::elementType; | 222 | using dstDataType = typename T::elementType; |
| 213 | 223 | ||
| 214 | 224 | ||
| 215 | - static_assert(Std::is_one_of_v< | 225 | + static_assert( |
| 216 | - Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, | 226 | + Std::is_one_of_v< |
| 217 | - Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, | 227 | + Std::tuple<dstDataType, srcDataType>, Std::tuple<__cbuf__ half, __gm__ half>, |
| 218 | - Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, | 228 | + Std::tuple<__cbuf__ bfloat16_t, __gm__ bfloat16_t>, Std::tuple<__cbuf__ float, __gm__ float>, |
| 219 | - Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, | 229 | + Std::tuple<__cbuf__ int8_t, __gm__ int8_t>, Std::tuple<__cbuf__ uint8_t, __gm__ uint8_t>, |
| 220 | - Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, | 230 | + Std::tuple<__cbuf__ int16_t, __gm__ int16_t>, Std::tuple<__cbuf__ uint16_t, __gm__ uint16_t>, |
| 221 | - Std::tuple<__cbuf__ int64_t, __gm__ int64_t>, Std::tuple<__cbuf__ uint64_t, __gm__ uint64_t>, | 231 | + Std::tuple<__cbuf__ int32_t, __gm__ int32_t>, Std::tuple<__cbuf__ uint32_t, __gm__ uint32_t>, |
| 222 | - Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, | 232 | + Std::tuple<__cbuf__ int64_t, __gm__ int64_t>, Std::tuple<__cbuf__ uint64_t, __gm__ uint64_t>, |
| 223 | - Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, | 233 | + Std::tuple<__cbuf__ fp8_e5m2_t, __gm__ fp8_e5m2_t>, |
| 224 | - Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, | 234 | + Std::tuple<__cbuf__ fp8_e4m3fn_t, __gm__ fp8_e4m3fn_t>, |
| 225 | - "The data type is not supported."); | 235 | + Std::tuple<__cbuf__ hifloat8_t, __gm__ hifloat8_t>>, |
| 236 | + "The data type is not supported."); | ||
| 226 | 237 | ||
| 227 | } | 238 | } |
| 228 | 239 | ||
| @@ -231,8 +242,9 @@ public: | |||
| 231 | { | 242 | { |
| 232 | using ShapeRow1 = typename GetFourDimType<U, AttrInfo::SHAPE, AttrInfo::ROW, 1>::type; | 243 | using ShapeRow1 = typename GetFourDimType<U, AttrInfo::SHAPE, AttrInfo::ROW, 1>::type; |
| 233 | using ShapeCol1 = typename GetFourDimType<U, AttrInfo::SHAPE, AttrInfo::COLUMN, 1>::type; | 244 | using ShapeCol1 = typename GetFourDimType<U, AttrInfo::SHAPE, AttrInfo::COLUMN, 1>::type; |
| 234 | - static_assert(Std::is_constant<1, ShapeRow1>::value || Std::is_constant<1, ShapeCol1>::value, | 245 | + static_assert( |
| 235 | - "The src only support 1D tensor"); | 246 | + Std::is_constant<1, ShapeRow1>::value || Std::is_constant<1, ShapeCol1>::value, |
| 247 | + "The src only support 1D tensor"); | ||
| 236 | } | 248 | } |
| 237 | 249 | ||
| 238 | template <typename T, typename U> | 250 | template <typename T, typename U> |
| @@ -243,12 +255,11 @@ public: | |||
| 243 | 255 | ||
| 244 | 256 | ||
| 245 | static_assert( | 257 | static_assert( |
| 246 | - Std::is_one_of_v<Std::tuple<dstDataType, srcDataType>, | 258 | + Std::is_one_of_v< |
| 247 | - Std::tuple<__biasbuf__ float, __cbuf__ bfloat16_t>, | 259 | + Std::tuple<dstDataType, srcDataType>, Std::tuple<__biasbuf__ float, __cbuf__ bfloat16_t>, |
| 248 | - Std::tuple<__biasbuf__ float, __cbuf__ half>, | 260 | + Std::tuple<__biasbuf__ float, __cbuf__ half>, Std::tuple<__biasbuf__ float, __cbuf__ float>, |
| 249 | - Std::tuple<__biasbuf__ float, __cbuf__ float>, | 261 | + Std::tuple<__biasbuf__ int32_t, __cbuf__ int32_t>>, |
| 250 | - Std::tuple<__biasbuf__ int32_t, __cbuf__ int32_t>>, | 262 | + "The data type is not supported."); |
| 251 | - "The data type is not supported."); | ||
| 252 | 263 | ||
| 253 | } | 264 | } |
| 254 | 265 | ||
| @@ -260,9 +271,7 @@ public: | |||
| 260 | 271 | ||
| 261 | 272 | ||
| 262 | static_assert( | 273 | static_assert( |
| 263 | - Std::is_same_v< | 274 | + Std::is_same_v<Std::tuple<dstDataType, srcDataType>, Std::tuple<__fbuf__ uint64_t, __cbuf__ uint64_t>>, |
| 264 | - Std::tuple<dstDataType, srcDataType>, | ||
| 265 | - Std::tuple<__fbuf__ uint64_t, __cbuf__ uint64_t>>, | ||
| 266 | "The data type is not supported."); | 275 | "The data type is not supported."); |
| 267 | 276 | ||
| 268 | } | 277 | } |
| @@ -274,13 +283,14 @@ public: | |||
| 274 | using dstType = typename T::elementType; | 283 | using dstType = typename T::elementType; |
| 275 | 284 | ||
| 276 | static_assert( | 285 | static_assert( |
| 277 | - (quantPre == QuantMode_t::NoQuant | 286 | + (quantPre == QuantMode_t::NoQuant && |
| 278 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__gm__ float, __cc__ float>, | 287 | + Std::is_one_of_v< |
| 279 | - Std::tuple<__gm__ int32_t, __cc__ int32_t>>) | 288 | + Std::tuple<dstType, srcType>, Std::tuple<__gm__ float, __cc__ float>, |
| 280 | - || (quantPre == QuantMode_t::F322F16 | 289 | + Std::tuple<__gm__ int32_t, __cc__ int32_t>>) || |
| 281 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__gm__ half, __cc__ float>>) | 290 | + (quantPre == QuantMode_t::F322F16 && |
| 282 | - || (quantPre == QuantMode_t::F322BF16 | 291 | + Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__gm__ half, __cc__ float>>) || |
| 283 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__gm__ bfloat16_t, __cc__ float>>), | 292 | + (quantPre == QuantMode_t::F322BF16 && |
| 293 | + Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__gm__ bfloat16_t, __cc__ float>>), | ||
| 284 | "The data type is not supported."); | 294 | "The data type is not supported."); |
| 285 | 295 | ||
| 286 | } | 296 | } |
| @@ -292,13 +302,14 @@ public: | |||
| 292 | using dstType = typename T::elementType; | 302 | using dstType = typename T::elementType; |
| 293 | 303 | ||
| 294 | static_assert( | 304 | static_assert( |
| 295 | - (quantPre == QuantMode_t::NoQuant | 305 | + (quantPre == QuantMode_t::NoQuant && |
| 296 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ float, __cc__ float>, | 306 | + Std::is_one_of_v< |
| 297 | - Std::tuple<__ubuf__ int32_t, __cc__ int32_t>>) | 307 | + Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ float, __cc__ float>, |
| 298 | - || (quantPre == QuantMode_t::F322F16 | 308 | + Std::tuple<__ubuf__ int32_t, __cc__ int32_t>>) || |
| 299 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ half, __cc__ float>>) | 309 | + (quantPre == QuantMode_t::F322F16 && |
| 300 | - || (quantPre == QuantMode_t::F322BF16 | 310 | + Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ half, __cc__ float>>) || |
| 301 | - && Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ bfloat16_t, __cc__ float>>), | 311 | + (quantPre == QuantMode_t::F322BF16 && |
| 312 | + Std::is_one_of_v<Std::tuple<dstType, srcType>, Std::tuple<__ubuf__ bfloat16_t, __cc__ float>>), | ||
| 302 | "The data type is not supported."); | 313 | "The data type is not supported."); |
| 303 | 314 | ||
| 304 | } | 315 | } |
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#warning \ | 12 | +#warning \ |
| 13 | "impl/tensor_api/arch/utils/check_format.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | 13 | "impl/tensor_api/arch/utils/check_format.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " |
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -38,16 +38,17 @@ public: | |||
| 38 | using dataType = typename T::elementType; | 38 | using dataType = typename T::elementType; |
| 39 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; | 39 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; |
| 40 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; | 40 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; |
| 41 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<dataType>>>, | 41 | + static_assert( |
| 42 | - "Layout->Shape->Column->ZeroDim must be 32/sizeof(dataType)!"); | 42 | + Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<dataType>>>, |
| 43 | - static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, | 43 | + "Layout->Shape->Column->ZeroDim must be 32/sizeof(dataType)!"); |
| 44 | - "Layout->Shape->Row->ZeroDim must be 16!"); | 44 | + static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Row->ZeroDim must be 16!"); |
| 45 | 45 | ||
| 46 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; | 46 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; |
| 47 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; | 47 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; |
| 48 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column-ZeroDim must be 1!"); | 48 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column-ZeroDim must be 1!"); |
| 49 | - static_assert(Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<dataType>>>, | 49 | + static_assert( |
| 50 | - "Layout->Stride->Row->ZeroDim must be 32/sizeof(dataType)!"); | 50 | + Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<dataType>>>, |
| 51 | + "Layout->Stride->Row->ZeroDim must be 32/sizeof(dataType)!"); | ||
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | template <typename T> | 54 | template <typename T> |
| @@ -56,17 +57,18 @@ public: | |||
| 56 | using dataType = typename T::elementType; | 57 | using dataType = typename T::elementType; |
| 57 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; | 58 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; |
| 58 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; | 59 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; |
| 59 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<FRACTAL_FIXED>>, | 60 | + static_assert( |
| 60 | - "Filter Layout->Shape->Column->ZeroDim must be 16!"); | 61 | + Std::is_same_v<ShapeColumn0, Std::Int<FRACTAL_FIXED>>, "Filter Layout->Shape->Column->ZeroDim must be 16!"); |
| 61 | - static_assert(Std::is_same_v<ShapeRow0, Std::Int<C0_ELEMENT<dataType>>>, | 62 | + static_assert( |
| 62 | - "Filter Layout->Shape->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 63 | + Std::is_same_v<ShapeRow0, Std::Int<C0_ELEMENT<dataType>>>, |
| 64 | + "Filter Layout->Shape->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | ||
| 63 | 65 | ||
| 64 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; | 66 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; |
| 65 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; | 67 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; |
| 66 | - static_assert(Std::is_same_v<StrideColumn0, Std::Int<C0_ELEMENT<dataType>>>, | 68 | + static_assert( |
| 67 | - "Filter Layout->Stride->Column-ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 69 | + Std::is_same_v<StrideColumn0, Std::Int<C0_ELEMENT<dataType>>>, |
| 68 | - static_assert(Std::is_same_v<StrideRow0, Std::Int<1>>, | 70 | + "Filter Layout->Stride->Column-ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); |
| 69 | - "Filter Layout->Stride->Row->ZeroDim must be 1!"); | 71 | + static_assert(Std::is_same_v<StrideRow0, Std::Int<1>>, "Filter Layout->Stride->Row->ZeroDim must be 1!"); |
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | template <typename T> | 74 | template <typename T> |
| @@ -75,18 +77,18 @@ public: | |||
| 75 | using type = typename T::elementType; | 77 | using type = typename T::elementType; |
| 76 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; | 78 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; |
| 77 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; | 79 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; |
| 78 | - static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, | 80 | + static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Row->ZeroDim must be 16!"); |
| 79 | - "Layout->Shape->Row->ZeroDim must be 16!"); | 81 | + static_assert( |
| 80 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<type>>>, | 82 | + Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<type>>>, |
| 81 | - "Layout->Shape->Column->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 83 | + "Layout->Shape->Column->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); |
| 82 | 84 | ||
| 83 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; | 85 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; |
| 84 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; | 86 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; |
| 85 | using StrideRow1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 1>::type; | 87 | using StrideRow1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 1>::type; |
| 86 | - static_assert(Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<type>>>, | 88 | + static_assert( |
| 87 | - "Layout->Stride->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 89 | + Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<type>>>, |
| 88 | - static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, | 90 | + "Layout->Stride->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); |
| 89 | - "Layout->Stride->Column->ZeroDim must be 1!"); | 91 | + static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column->ZeroDim must be 1!"); |
| 90 | static_assert( | 92 | static_assert( |
| 91 | Std::is_same_v<StrideRow1, Std::Int<C0_ELEMENT<type> * FRACTAL_FIXED>>, | 93 | Std::is_same_v<StrideRow1, Std::Int<C0_ELEMENT<type> * FRACTAL_FIXED>>, |
| 92 | "Layout->Stride->Column->ZeroDimmust be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType) * 16)!"); | 94 | "Layout->Stride->Column->ZeroDimmust be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType) * 16)!"); |
| @@ -111,11 +113,13 @@ public: | |||
| 111 | using StrideRow1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 1>::type; | 113 | using StrideRow1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 1>::type; |
| 112 | 114 | ||
| 113 | static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Row->ZeroDim must be 16!"); | 115 | static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Row->ZeroDim must be 16!"); |
| 114 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<type>>>, | 116 | + static_assert( |
| 115 | - "Layout->Shape->Column->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 117 | + Std::is_same_v<ShapeColumn0, Std::Int<C0_ELEMENT<type>>>, |
| 118 | + "Layout->Shape->Column->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | ||
| 116 | 119 | ||
| 117 | - static_assert(Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<type>>>, | 120 | + static_assert( |
| 118 | - "Layout->Stride->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | 121 | + Std::is_same_v<StrideRow0, Std::Int<C0_ELEMENT<type>>>, |
| 122 | + "Layout->Stride->Row->ZeroDim must be (is_b4_type<dataType> ? 64 : 32 / sizeof(dataType))!"); | ||
| 119 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column->ZeroDim must be 1!"); | 123 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column->ZeroDim must be 1!"); |
| 120 | static_assert( | 124 | static_assert( |
| 121 | Std::is_same_v<StrideRow1, Std::Int<C0_ELEMENT<type> * FRACTAL_FIXED>>, | 125 | Std::is_same_v<StrideRow1, Std::Int<C0_ELEMENT<type> * FRACTAL_FIXED>>, |
| @@ -144,17 +148,18 @@ public: | |||
| 144 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; | 148 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; |
| 145 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; | 149 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; |
| 146 | static_assert(Std::is_same_v<ShapeRow0, Std::Int<2>>, "CopyCbufToFB Layout->Shape->Row->ZeroDim must be 2!"); | 150 | static_assert(Std::is_same_v<ShapeRow0, Std::Int<2>>, "CopyCbufToFB Layout->Shape->Row->ZeroDim must be 2!"); |
| 147 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<1>>, | 151 | + static_assert( |
| 148 | - "CopyCbufToFB Layout->Shape->Column->ZeroDim must be 1!"); | 152 | + Std::is_same_v<ShapeColumn0, Std::Int<1>>, "CopyCbufToFB Layout->Shape->Column->ZeroDim must be 1!"); |
| 149 | 153 | ||
| 150 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; | 154 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; |
| 151 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; | 155 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; |
| 152 | using StrideColumn1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 1>::type; | 156 | using StrideColumn1 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 1>::type; |
| 153 | static_assert(Std::is_same_v<StrideRow0, Std::Int<1>>, "CopyCbufToFB Layout->Stride->Row->ZeroDim must be 1!"); | 157 | static_assert(Std::is_same_v<StrideRow0, Std::Int<1>>, "CopyCbufToFB Layout->Stride->Row->ZeroDim must be 1!"); |
| 154 | - static_assert(Std::is_same_v<StrideColumn0, Std::Int<0>>, | 158 | + static_assert( |
| 155 | - "CopyCbufToFB Layout->Stride->Column->ZeroDim must be 0!"); | 159 | + Std::is_same_v<StrideColumn0, Std::Int<0>>, "CopyCbufToFB Layout->Stride->Column->ZeroDim must be 0!"); |
| 156 | - static_assert(Std::is_same_v<StrideColumn1, Std::Int<MX_SCALE_K0>>, | 160 | + static_assert( |
| 157 | - "CopyCbufToFB Layout->Stride->Column->OneDim must be 2!"); | 161 | + Std::is_same_v<StrideColumn1, Std::Int<MX_SCALE_K0>>, |
| 162 | + "CopyCbufToFB Layout->Stride->Column->OneDim must be 2!"); | ||
| 158 | } | 163 | } |
| 159 | 164 | ||
| 160 | template <typename T> | 165 | template <typename T> |
| @@ -162,15 +167,13 @@ public: | |||
| 162 | { | 167 | { |
| 163 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; | 168 | using ShapeRow0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::ROW, 0>::type; |
| 164 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; | 169 | using ShapeColumn0 = typename GetFourDimType<T, AttrInfo::SHAPE, AttrInfo::COLUMN, 0>::type; |
| 165 | - static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, | 170 | + static_assert(Std::is_same_v<ShapeRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Row->ZeroDim must be 16!"); |
| 166 | - "Layout->Shape->Row->ZeroDim must be 16!"); | 171 | + static_assert( |
| 167 | - static_assert(Std::is_same_v<ShapeColumn0, Std::Int<FRACTAL_FIXED>>, | 172 | + Std::is_same_v<ShapeColumn0, Std::Int<FRACTAL_FIXED>>, "Layout->Shape->Column->ZeroDim must be 16!"); |
| 168 | - "Layout->Shape->Column->ZeroDim must be 16!"); | ||
| 169 | 173 | ||
| 170 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; | 174 | using StrideRow0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::ROW, 0>::type; |
| 171 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; | 175 | using StrideColumn0 = typename GetFourDimType<T, AttrInfo::STRIDE, AttrInfo::COLUMN, 0>::type; |
| 172 | - static_assert(Std::is_same_v<StrideRow0, Std::Int<FRACTAL_FIXED>>, | 176 | + static_assert(Std::is_same_v<StrideRow0, Std::Int<FRACTAL_FIXED>>, "Layout->Stride->Row->ZeroDim must be 16!"); |
| 173 | - "Layout->Stride->Row->ZeroDim must be 16!"); | ||
| 174 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column->ZeroDim must be 1!"); | 177 | static_assert(Std::is_same_v<StrideColumn0, Std::Int<1>>, "Layout->Stride->Column->ZeroDim must be 1!"); |
| 175 | } | 178 | } |
| 176 | 179 | ||