已合并
修改aclnnAddV3等接口资料 #3761
xiu_ling_wang创建于 7月3日
修改aclnnAddV3等接口资料 #3761
已合并
共 4 个文件变更+9-423
| @@ -1,411 +0,0 @@ | |||
| 1 | -# aclnnCoalesceSparse | ||
| 2 | - | ||
| 3 | -[📄 查看源码](https://gitcode.com/cann/ops-math/tree/master/conversion/coalesce_sparse) | ||
| 4 | - | ||
| 5 | -## 产品支持情况 | ||
| 6 | - | ||
| 7 | -| 产品 | 是否支持 | | ||
| 8 | -| :----------------------------------------------------------- | :------: | | ||
| 9 | -| <term>Ascend 950PR/Ascend 950DT</term> | × | | ||
| 10 | -| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ | | ||
| 11 | -| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | ||
| 12 | -| <term>Atlas 200I/500 A2 推理产品</term> | × | | ||
| 13 | -| <term>Atlas 推理系列产品</term> | × | | ||
| 14 | -| <term>Atlas 训练系列产品</term> | × | | ||
| 15 | - | ||
| 16 | -## 功能说明 | ||
| 17 | - | ||
| 18 | -将相同坐标点的value进行累加求和,进而减少Coo_Tensor的内存大小。 | ||
| 19 | - | ||
| 20 | -## 函数原型 | ||
| 21 | - | ||
| 22 | -每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnCoalesceSparseGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnCoalesceSparse”接口执行计算。 | ||
| 23 | - | ||
| 24 | -```Cpp | ||
| 25 | -aclnnStatus aclnnCoalesceSparseGetWorkspaceSize( | ||
| 26 | - const aclTensor *uniqueLen, | ||
| 27 | - const aclTensor *uniqueIndices, | ||
| 28 | - const aclTensor *indices, | ||
| 29 | - const aclTensor *values, | ||
| 30 | - const aclTensor *newIndicesOut, | ||
| 31 | - const aclTensor *newValuesOut, | ||
| 32 | - uint64_t *workspaceSize, | ||
| 33 | - aclOpExecutor **executor); | ||
| 34 | -``` | ||
| 35 | - | ||
| 36 | -```Cpp | ||
| 37 | -aclnnStatus aclnnCoalesceSparse( | ||
| 38 | - void *workspace, | ||
| 39 | - uint64_t workspaceSize, | ||
| 40 | - aclOpExecutor *executor, | ||
| 41 | - aclrtStream stream); | ||
| 42 | -``` | ||
| 43 | - | ||
| 44 | -## aclnnCoalesceSparseGetWorkspaceSize | ||
| 45 | - | ||
| 46 | -- **参数说明:** | ||
| 47 | - | ||
| 48 | - <table style="undefined;table-layout: fixed; width: 1519px"><colgroup> | ||
| 49 | - <col style="width: 217px"> | ||
| 50 | - <col style="width: 120px"> | ||
| 51 | - <col style="width: 247px"> | ||
| 52 | - <col style="width: 317px"> | ||
| 53 | - <col style="width: 233px"> | ||
| 54 | - <col style="width: 120px"> | ||
| 55 | - <col style="width: 120px"> | ||
| 56 | - <col style="width: 145px"> | ||
| 57 | - </colgroup> | ||
| 58 | - <thead> | ||
| 59 | - <tr> | ||
| 60 | - <th>参数名</th> | ||
| 61 | - <th>输入/输出</th> | ||
| 62 | - <th>描述</th> | ||
| 63 | - <th>使用说明</th> | ||
| 64 | - <th>数据类型</th> | ||
| 65 | - <th>数据格式</th> | ||
| 66 | - <th>维度(shape)</th> | ||
| 67 | - <th>非连续Tensor</th> | ||
| 68 | - </tr></thead> | ||
| 69 | - <tbody> | ||
| 70 | - <tr> | ||
| 71 | - <td>uniqueLen(aclTensor*)</td> | ||
| 72 | - <td>输入</td> | ||
| 73 | - <td>去重后的索引数。</td> | ||
| 74 | - <td>不支持空Tensor。</td> | ||
| 75 | - <td>INT32、INT64</td> | ||
| 76 | - <td>ND</td> | ||
| 77 | - <td>1</td> | ||
| 78 | - <td>√</td> | ||
| 79 | - </tr> | ||
| 80 | - <tr> | ||
| 81 | - <td>uniqueIndices(aclTensor*)</td> | ||
| 82 | - <td>输入</td> | ||
| 83 | - <td>去重后的索引数组。</td> | ||
| 84 | - <td>不支持空Tensor。</td> | ||
| 85 | - <td>INT32、INT64</td> | ||
| 86 | - <td>ND</td> | ||
| 87 | - <td>1</td> | ||
| 88 | - <td>√</td> | ||
| 89 | - </tr> | ||
| 90 | - <tr> | ||
| 91 | - <td>indices(aclTensor*)</td> | ||
| 92 | - <td>输入</td> | ||
| 93 | - <td>索引数组。</td> | ||
| 94 | - <td><ul><li>不支持空Tensor。</li><li>重索引后的indices值不能超过int32上限。</li></ul></td> | ||
| 95 | - <td>INT32、INT64</td> | ||
| 96 | - <td>ND</td> | ||
| 97 | - <td>2</td> | ||
| 98 | - <td>√</td> | ||
| 99 | - </tr> | ||
| 100 | - <tr> | ||
| 101 | - <td>values(aclTensor*)</td> | ||
| 102 | - <td>输入</td> | ||
| 103 | - <td>每个坐标对应的元素值。</td> | ||
| 104 | - <td>不支持空Tensor。</td> | ||
| 105 | - <td>INT32、FLOAT16、FLOAT32</td> | ||
| 106 | - <td>ND</td> | ||
| 107 | - <td>1-8</td> | ||
| 108 | - <td>√</td> | ||
| 109 | - </tr> | ||
| 110 | - <tr> | ||
| 111 | - <td>newIndicesOut(aclTensor*)</td> | ||
| 112 | - <td>输出</td> | ||
| 113 | - <td>合并后的索引数组。</td> | ||
| 114 | - <td>不支持空Tensor。</td> | ||
| 115 | - <td>INT32、INT64</td> | ||
| 116 | - <td>ND</td> | ||
| 117 | - <td>2</td> | ||
| 118 | - <td>√</td> | ||
| 119 | - </tr> | ||
| 120 | - <tr> | ||
| 121 | - <td>newValuesOut(aclTensor*)</td> | ||
| 122 | - <td>输出</td> | ||
| 123 | - <td>合并后的元素值。</td> | ||
| 124 | - <td>不支持空Tensor。</td> | ||
| 125 | - <td>INT32、FLOAT16、FLOAT32</td> | ||
| 126 | - <td>ND</td> | ||
| 127 | - <td>1-8</td> | ||
| 128 | - <td>√</td> | ||
| 129 | - </tr> | ||
| 130 | - <tr> | ||
| 131 | - <td>workspaceSize(uint64_t*)</td> | ||
| 132 | - <td>输出</td> | ||
| 133 | - <td>返回需要在Device侧申请的workspace大小。</td> | ||
| 134 | - <td>-</td> | ||
| 135 | - <td>-</td> | ||
| 136 | - <td>-</td> | ||
| 137 | - <td>-</td> | ||
| 138 | - <td>-</td> | ||
| 139 | - </tr> | ||
| 140 | - <tr> | ||
| 141 | - <td>executor(aclOpExecutor**)</td> | ||
| 142 | - <td>输出</td> | ||
| 143 | - <td>返回op执行器,包含了算子计算流程。</td> | ||
| 144 | - <td>-</td> | ||
| 145 | - <td>-</td> | ||
| 146 | - <td>-</td> | ||
| 147 | - <td>-</td> | ||
| 148 | - <td>-</td> | ||
| 149 | - </tr> | ||
| 150 | - </tbody></table> | ||
| 151 | - | ||
| 152 | -- **返回值:** | ||
| 153 | - | ||
| 154 | - aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | ||
| 155 | - | ||
| 156 | - 第一段接口完成入参校验,出现以下场景时报错: | ||
| 157 | - | ||
| 158 | - <table style="undefined;table-layout: fixed; width: 1150px"><colgroup> | ||
| 159 | - <col style="width: 300px"> | ||
| 160 | - <col style="width: 134px"> | ||
| 161 | - <col style="width: 716px"> | ||
| 162 | - </colgroup> | ||
| 163 | - <thead> | ||
| 164 | - <tr> | ||
| 165 | - <th>返回码</th> | ||
| 166 | - <th>错误码</th> | ||
| 167 | - <th>描述</th> | ||
| 168 | - </tr></thead> | ||
| 169 | - <tbody> | ||
| 170 | - <tr> | ||
| 171 | - <td>ACLNN_ERR_PARAM_NULLPTR</td> | ||
| 172 | - <td>161001</td> | ||
| 173 | - <td>传入的uniqueLen、uniqueIndices、indices、values、newIndicesOut或newValuesOut是空指针。</td> | ||
| 174 | - </tr> | ||
| 175 | - <tr> | ||
| 176 | - <td rowspan="3">ACLNN_ERR_PARAM_INVALID</td> | ||
| 177 | - <td rowspan="3">161002</td> | ||
| 178 | - <td>uniqueLen、uniqueIndices、indices、values、newIndicesOut或newValuesOut的数据类型不在支持范围之内。</td> | ||
| 179 | - </tr> | ||
| 180 | - <tr> | ||
| 181 | - <td>values或newValuesOut的维度超过8维。</td> | ||
| 182 | - </tr> | ||
| 183 | - <tr> | ||
| 184 | - <td>重索引后的indices值不能超过int32上限。</td> | ||
| 185 | - </tr> | ||
| 186 | - </tbody></table> | ||
| 187 | - | ||
| 188 | -## aclnnCoalesceSparse | ||
| 189 | - | ||
| 190 | -- **参数说明:** | ||
| 191 | - | ||
| 192 | - <table style="undefined;table-layout: fixed; width: 1151px"><colgroup> | ||
| 193 | - <col style="width: 184px"> | ||
| 194 | - <col style="width: 134px"> | ||
| 195 | - <col style="width: 833px"> | ||
| 196 | - </colgroup> | ||
| 197 | - <thead> | ||
| 198 | - <tr> | ||
| 199 | - <th>参数名</th> | ||
| 200 | - <th>输入/输出</th> | ||
| 201 | - <th>描述</th> | ||
| 202 | - </tr></thead> | ||
| 203 | - <tbody> | ||
| 204 | - <tr> | ||
| 205 | - <td>workspace</td> | ||
| 206 | - <td>输入</td> | ||
| 207 | - <td>在Device侧申请的workspace内存地址。</td> | ||
| 208 | - </tr> | ||
| 209 | - <tr> | ||
| 210 | - <td>workspaceSize</td> | ||
| 211 | - <td>输入</td> | ||
| 212 | - <td>在Device侧申请的workspace大小,由第一段接口aclnnCoalesceSparseGetWorkspaceSize获取。</td> | ||
| 213 | - </tr> | ||
| 214 | - <tr> | ||
| 215 | - <td>executor</td> | ||
| 216 | - <td>输入</td> | ||
| 217 | - <td>op执行器,包含了算子计算流程。</td> | ||
| 218 | - </tr> | ||
| 219 | - <tr> | ||
| 220 | - <td>stream</td> | ||
| 221 | - <td>输入</td> | ||
| 222 | - <td>指定执行任务的Stream。</td> | ||
| 223 | - </tr> | ||
| 224 | - </tbody></table> | ||
| 225 | - | ||
| 226 | -- **返回值:** | ||
| 227 | - | ||
| 228 | - aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | ||
| 229 | - | ||
| 230 | -## 约束说明 | ||
| 231 | - | ||
| 232 | -无 | ||
| 233 | - | ||
| 234 | -## 调用示例 | ||
| 235 | - | ||
| 236 | -示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | ||
| 237 | - | ||
| 238 | -```Cpp | ||
| 239 | -#include <iostream> | ||
| 240 | -#include <vector> | ||
| 241 | -#include "acl/acl.h" | ||
| 242 | -#include "aclnnop/aclnn_coalesce_sparse.h" | ||
| 243 | - | ||
| 244 | -#define CHECK_RET(cond, return_expr) \ | ||
| 245 | - do { \ | ||
| 246 | - if (!(cond)) { \ | ||
| 247 | - return_expr; \ | ||
| 248 | - } \ | ||
| 249 | - } while (0) | ||
| 250 | - | ||
| 251 | -#define LOG_PRINT(message, ...) \ | ||
| 252 | - do { \ | ||
| 253 | - printf(message, ##__VA_ARGS__); \ | ||
| 254 | - } while (0) | ||
| 255 | - | ||
| 256 | -int64_t GetShapeSize(const std::vector<int64_t>& shape) | ||
| 257 | -{ | ||
| 258 | - int64_t shapeSize = 1; | ||
| 259 | - for (auto i : shape) { | ||
| 260 | - shapeSize *= i; | ||
| 261 | - } | ||
| 262 | - return shapeSize; | ||
| 263 | -} | ||
| 264 | - | ||
| 265 | -int Init(int32_t deviceId, aclrtStream* stream) | ||
| 266 | -{ | ||
| 267 | - // 固定写法,初始化 | ||
| 268 | - auto ret = aclInit(nullptr); | ||
| 269 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret); | ||
| 270 | - ret = aclrtSetDevice(deviceId); | ||
| 271 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret); | ||
| 272 | - ret = aclrtCreateStream(stream); | ||
| 273 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret); | ||
| 274 | - return 0; | ||
| 275 | -} | ||
| 276 | - | ||
| 277 | -template <typename T> | ||
| 278 | -int CreateAclTensor( | ||
| 279 | - const std::vector<T>& hostData, const std::vector<int64_t>& shape, void** deviceAddr, aclDataType dataType, | ||
| 280 | - aclTensor** tensor) | ||
| 281 | -{ | ||
| 282 | - auto size = GetShapeSize(shape) * sizeof(T); | ||
| 283 | - // 调用aclrtMalloc申请device侧内存 | ||
| 284 | - auto ret = aclrtMalloc(deviceAddr, size, ACL_MEM_MALLOC_HUGE_FIRST); | ||
| 285 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtMalloc failed. ERROR: %d\n", ret); return ret); | ||
| 286 | - // 调用aclrtMemcpy将host侧数据拷贝到device侧内存上 | ||
| 287 | - ret = aclrtMemcpy(*deviceAddr, size, hostData.data(), size, ACL_MEMCPY_HOST_TO_DEVICE); | ||
| 288 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtMemcpy failed. ERROR: %d\n", ret); return ret); | ||
| 289 | - | ||
| 290 | - // 计算连续tensor的strides | ||
| 291 | - std::vector<int64_t> strides(shape.size(), 1); | ||
| 292 | - for (int64_t i = shape.size() - 2; i >= 0; i--) { | ||
| 293 | - strides[i] = shape[i + 1] * strides[i + 1]; | ||
| 294 | - } | ||
| 295 | - | ||
| 296 | - // 调用aclCreateTensor接口创建aclTensor | ||
| 297 | - *tensor = aclCreateTensor( | ||
| 298 | - shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), | ||
| 299 | - *deviceAddr); | ||
| 300 | - return 0; | ||
| 301 | -} | ||
| 302 | - | ||
| 303 | -int main() | ||
| 304 | -{ | ||
| 305 | - // 1. (固定写法)device/stream初始化,参考acl API文档 | ||
| 306 | - // 根据自己的实际device填写deviceId | ||
| 307 | - int32_t deviceId = 0; | ||
| 308 | - aclrtStream stream; | ||
| 309 | - auto ret = Init(deviceId, &stream); | ||
| 310 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret); | ||
| 311 | - | ||
| 312 | - // 2. 构造输入与输出,需要根据API的接口自定义构造 | ||
| 313 | - std::vector<int64_t> uniqueLenShape = {1}; | ||
| 314 | - std::vector<int64_t> uniqueIndicesShape = {2,2}; | ||
| 315 | - std::vector<int64_t> indexShape = {2,4}; | ||
| 316 | - std::vector<int64_t> valueShape = {4}; | ||
| 317 | - std::vector<int64_t> newIndexShape = {4}; | ||
| 318 | - std::vector<int64_t> newValueShape = {2}; | ||
| 319 | - void* uniqueLenDeviceAddr = nullptr; | ||
| 320 | - void* uniqueIndicesDeviceAddr = nullptr; | ||
| 321 | - void* indexDeviceAddr = nullptr; | ||
| 322 | - void* valueDeviceAddr = nullptr; | ||
| 323 | - void* newIndexDeviceAddr = nullptr; | ||
| 324 | - void* newValueDeviceAddr = nullptr; | ||
| 325 | - aclTensor* uniqueLen = nullptr; | ||
| 326 | - aclTensor* uniqueIndices = nullptr; | ||
| 327 | - aclTensor* index = nullptr; | ||
| 328 | - aclTensor* value = nullptr; | ||
| 329 | - aclTensor* newIndex = nullptr; | ||
| 330 | - aclTensor* newValue = nullptr; | ||
| 331 | - std::vector<int32_t> uniqueLenData = {2}; | ||
| 332 | - std::vector<int32_t> uniqueIndicesData = {0, 1, 0, 2}; | ||
| 333 | - std::vector<int32_t> indexData = {0, 0, 1, 1, 0, 0, 2, 2}; | ||
| 334 | - std::vector<float> valueData = {1, 2, 3, 4}; | ||
| 335 | - std::vector<int32_t> newIndexData = {0, 0, 0, 0}; | ||
| 336 | - std::vector<float> newValueData = {0, 0}; | ||
| 337 | - | ||
| 338 | - // 创建in aclTensor | ||
| 339 | - ret = CreateAclTensor(uniqueLenData, uniqueLenShape, &uniqueLenDeviceAddr, aclDataType::ACL_INT32, &uniqueLen); | ||
| 340 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 341 | - // 创建in aclTensor | ||
| 342 | - ret = CreateAclTensor(uniqueIndicesData, uniqueIndicesShape, &uniqueIndicesDeviceAddr, aclDataType::ACL_INT32, &uniqueIndices); | ||
| 343 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 344 | - // 创建in aclTensor | ||
| 345 | - ret = CreateAclTensor(indexData, indexShape, &indexDeviceAddr, aclDataType::ACL_INT32, &index); | ||
| 346 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 347 | - // 创建in aclTensor | ||
| 348 | - ret = CreateAclTensor(valueData, valueShape, &valueDeviceAddr, aclDataType::ACL_FLOAT, &value); | ||
| 349 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 350 | - // 创建out aclTensor | ||
| 351 | - ret = CreateAclTensor(newIndexData, newIndexShape, &newIndexDeviceAddr, aclDataType::ACL_INT32, &newIndex); | ||
| 352 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 353 | - // 创建out aclTensor | ||
| 354 | - ret = CreateAclTensor(newValueData, newValueShape, &newValueDeviceAddr, aclDataType::ACL_FLOAT, &newValue); | ||
| 355 | - CHECK_RET(ret == ACL_SUCCESS, return ret); | ||
| 356 | - | ||
| 357 | - // 3. 调用CANN算子库API,需要修改为具体的Api名称 | ||
| 358 | - uint64_t workspaceSize = 0; | ||
| 359 | - aclOpExecutor* executor; | ||
| 360 | - // 调用aclnnCoalesceSparse第一段接口 | ||
| 361 | - ret = aclnnCoalesceSparseGetWorkspaceSize(uniqueLen, uniqueIndices, index, value, newIndex, newValue, &workspaceSize, &executor); | ||
| 362 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnCoalesceSparseGetWorkspaceSize failed. ERROR: %d\n", ret); return ret); | ||
| 363 | - // 根据第一段接口计算出的workspaceSize申请device内存 | ||
| 364 | - void* workspaceAddr = nullptr; | ||
| 365 | - if (workspaceSize > static_cast<uint64_t>(0)) { | ||
| 366 | - ret = aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST); | ||
| 367 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("allocate workspace failed. ERROR: %d\n", ret); return ret); | ||
| 368 | - } | ||
| 369 | - // 调用aclnnCoalesceSparse第二段接口 | ||
| 370 | - ret = aclnnCoalesceSparse(workspaceAddr, workspaceSize, executor, stream); | ||
| 371 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnCoalesceSparse failed. ERROR: %d\n", ret); return ret); | ||
| 372 | - | ||
| 373 | - // 4. (固定写法)同步等待任务执行结束 | ||
| 374 | - ret = aclrtSynchronizeStream(stream); | ||
| 375 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); return ret); | ||
| 376 | - | ||
| 377 | - // 5. 获取输出的值,将device侧内存上的结果拷贝至host侧,需要根据具体API的接口定义修改 | ||
| 378 | - auto size = GetShapeSize(newValueShape); | ||
| 379 | - std::vector<float> resultData(size, 0); | ||
| 380 | - ret = aclrtMemcpy( | ||
| 381 | - resultData.data(), resultData.size() * sizeof(resultData[0]), newValueDeviceAddr, size * sizeof(resultData[0]), | ||
| 382 | - ACL_MEMCPY_DEVICE_TO_HOST); | ||
| 383 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return ret); | ||
| 384 | - for (int64_t i = 0; i < size; i++) { | ||
| 385 | - LOG_PRINT("result[%ld] is: %f\n", i, resultData[i]); | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - // 6. 释放aclTensor,需要根据具体API的接口定义修改 | ||
| 389 | - aclDestroyTensor(uniqueLen); | ||
| 390 | - aclDestroyTensor(uniqueIndices); | ||
| 391 | - aclDestroyTensor(index); | ||
| 392 | - aclDestroyTensor(value); | ||
| 393 | - aclDestroyTensor(newIndex); | ||
| 394 | - aclDestroyTensor(newValue); | ||
| 395 | - | ||
| 396 | - // 7. 释放device资源 | ||
| 397 | - aclrtFree(uniqueLenDeviceAddr); | ||
| 398 | - aclrtFree(uniqueIndicesDeviceAddr); | ||
| 399 | - aclrtFree(indexDeviceAddr); | ||
| 400 | - aclrtFree(valueDeviceAddr); | ||
| 401 | - aclrtFree(newIndexDeviceAddr); | ||
| 402 | - aclrtFree(newValueDeviceAddr); | ||
| 403 | - if (workspaceSize > static_cast<uint64_t>(0)) { | ||
| 404 | - aclrtFree(workspaceAddr); | ||
| 405 | - } | ||
| 406 | - aclrtDestroyStream(stream); | ||
| 407 | - aclrtResetDevice(deviceId); | ||
| 408 | - aclFinalize(); | ||
| 409 | - return 0; | ||
| 410 | -} | ||
| 411 | -``` | ||
| @@ -35,7 +35,7 @@ ${INSTALL_DIR}表示CANN安装后文件路径;\$\{ops\_project\}表示算子 | |||
| 35 | | [aclnnAddLora](../../math/add_lora/docs/aclnnAddLora.md) | 为神经网络添加LoRA(Low-Rank Adaptation)层功能,通过低秩分解减少参数数量。 | 默认确定性实现| - | | 35 | | [aclnnAddLora](../../math/add_lora/docs/aclnnAddLora.md) | 为神经网络添加LoRA(Low-Rank Adaptation)层功能,通过低秩分解减少参数数量。 | 默认确定性实现| - | |
| 36 | | [aclnnAddr&aclnnInplaceAddr](../../math/addr/docs/aclnnAddr&aclnnInplaceAddr.md) | 求一维向量vec1和vec2的外积得到一个二维矩阵,并将外积结果矩阵乘一个系数后和自身乘系数相加后输出。 | 默认确定性实现| 默认确定性实现| | 36 | | [aclnnAddr&aclnnInplaceAddr](../../math/addr/docs/aclnnAddr&aclnnInplaceAddr.md) | 求一维向量vec1和vec2的外积得到一个二维矩阵,并将外积结果矩阵乘一个系数后和自身乘系数相加后输出。 | 默认确定性实现| 默认确定性实现| |
| 37 | | [aclnnAdds](../../math/add/docs/aclnnAdds.md) | 完成加法计算。 | 默认确定性实现| 默认确定性实现 | | 37 | | [aclnnAdds](../../math/add/docs/aclnnAdds.md) | 完成加法计算。 | 默认确定性实现| 默认确定性实现 | |
| 38 | -| [aclnnAddV3&aclnnInplaceAddV3](../../math/add/docs/aclnnAddV3&aclnnInplaceAddV3.md) | 完成加法计算。 | 默认确定性实现| 默认确定性实现 | | 38 | +| [aclnnAddV3&aclnnInplaceAddV3](../../math/add/docs/aclnnAddV3&aclnnInplaceAddV3.md) | 完成加法计算。 | - | 默认确定性实现 | |
| 39 | | [aclnnAffineGrid](../../math/affine_grid/docs/aclnnAffineGrid.md) | 给定一组3维的仿射参数矩阵(theta)以及输出图像的大小(size),生成一个2D或3D的网格,该网格表示仿射后图像的点在原图像上的坐标。 | 默认确定性实现| - | | 39 | | [aclnnAffineGrid](../../math/affine_grid/docs/aclnnAffineGrid.md) | 给定一组3维的仿射参数矩阵(theta)以及输出图像的大小(size),生成一个2D或3D的网格,该网格表示仿射后图像的点在原图像上的坐标。 | 默认确定性实现| - | |
| 40 | | [aclnnAll](../../math/reduce_all/docs/aclnnAll.md) | 对于给定维度dim中的每一维,如果输入Tensor中该维度对应的所有元素计算为True,则返回True,否则返回False。 | 默认确定性实现| 默认确定性实现| | 40 | | [aclnnAll](../../math/reduce_all/docs/aclnnAll.md) | 对于给定维度dim中的每一维,如果输入Tensor中该维度对应的所有元素计算为True,则返回True,否则返回False。 | 默认确定性实现| 默认确定性实现| |
| 41 | | [aclnnAmax](../../math/reduce_max/docs/aclnnAmax.md) | 返回张量在指定维度(dim)上每个切片的最大值。 | 默认确定性实现| 默认确定性实现| | 41 | | [aclnnAmax](../../math/reduce_max/docs/aclnnAmax.md) | 返回张量在指定维度(dim)上每个切片的最大值。 | 默认确定性实现| 默认确定性实现| |
| @@ -60,7 +60,7 @@ ${INSTALL_DIR}表示CANN安装后文件路径;\$\{ops\_project\}表示算子 | |||
| 60 | | [aclnnBitwiseNot](../../math/bitwise_not/docs/aclnnBitwiseNot.md) | 输入为BOOL型tensor时,进行逻辑非运算;输入为INT型时进行按位非运算。 | 默认确定性实现| 默认确定性实现| | 60 | | [aclnnBitwiseNot](../../math/bitwise_not/docs/aclnnBitwiseNot.md) | 输入为BOOL型tensor时,进行逻辑非运算;输入为INT型时进行按位非运算。 | 默认确定性实现| 默认确定性实现| |
| 61 | | [aclnnBitwiseAndScalar](../../math/bitwise_and/docs/aclnnBitwiseAndScalar.md) | 计算输入tensor中每个元素和输入标量的按位与结果。 | 默认确定性实现| 默认确定性实现 | | 61 | | [aclnnBitwiseAndScalar](../../math/bitwise_and/docs/aclnnBitwiseAndScalar.md) | 计算输入tensor中每个元素和输入标量的按位与结果。 | 默认确定性实现| 默认确定性实现 | |
| 62 | | [aclnnBitwiseAndTensor](../../math/bitwise_and/docs/aclnnBitwiseAndTensor.md) | 输入为BOOL型tensor时,进行逻辑与运算;输入为INT型时,进行位与运算。 | 默认确定性实现| 默认确定性实现 | | 62 | | [aclnnBitwiseAndTensor](../../math/bitwise_and/docs/aclnnBitwiseAndTensor.md) | 输入为BOOL型tensor时,进行逻辑与运算;输入为INT型时,进行位与运算。 | 默认确定性实现| 默认确定性实现 | |
| 63 | -| [aclnnBitwiseAndTensorOut&aclnnInplaceBitwiseAndTensorOut](../../math/bitwise_and/docs/aclnnBitwiseAndTensorOut&aclnnInplaceBitwiseAndTensorOut.md) | 输入为BOOL型tensor时,进行逻辑与运算;输入为INT型时,进行位与运算。 | 默认确定性实现| 默认确定性实现 | | 63 | +| [aclnnBitwiseAndTensorOut&aclnnInplaceBitwiseAndTensorOut](../../math/bitwise_and/docs/aclnnBitwiseAndTensorOut&aclnnInplaceBitwiseAndTensorOut.md) | 输入为BOOL型tensor时,进行逻辑与运算;输入为INT型时,进行位与运算。 | - | 默认确定性实现 | |
| 64 | | [aclnnBitwiseOrScalar&aclnnInplaceBitwiseOrScalar](../../math/bitwise_or/docs/aclnnBitwiseOrScalar&aclnnInplaceBitwiseOrScalar.md) | 计算输入张量self中每个元素和输入标量other的按位或。 | 默认确定性实现| 默认确定性实现 | | 64 | | [aclnnBitwiseOrScalar&aclnnInplaceBitwiseOrScalar](../../math/bitwise_or/docs/aclnnBitwiseOrScalar&aclnnInplaceBitwiseOrScalar.md) | 计算输入张量self中每个元素和输入标量other的按位或。 | 默认确定性实现| 默认确定性实现 | |
| 65 | | [aclnnBitwiseOrTensor&aclnnInplaceBitwiseOrTensor](../../math/bitwise_or/docs/aclnnBitwiseOrTensor&aclnnInplaceBitwiseOrTensor.md) | 计算张量self中每个元素与other张量中对应位置的元素的按位或。 | 默认确定性实现| 默认确定性实现 | | 65 | | [aclnnBitwiseOrTensor&aclnnInplaceBitwiseOrTensor](../../math/bitwise_or/docs/aclnnBitwiseOrTensor&aclnnInplaceBitwiseOrTensor.md) | 计算张量self中每个元素与other张量中对应位置的元素的按位或。 | 默认确定性实现| 默认确定性实现 | |
| 66 | | [aclnnBitwiseXorScalar&aclnnInplaceBitwiseXorScalar](../../math/bitwise_xor/docs/aclnnBitwiseXorScalar&aclnnInplaceBitwiseXorScalar.md) | 计算输入张量self中每个元素和输入标量other的按位异或,输入self和other必须是整数或布尔类型,对于布尔类型,计算逻辑异或。 | 默认确定性实现| 默认确定性实现 | | 66 | | [aclnnBitwiseXorScalar&aclnnInplaceBitwiseXorScalar](../../math/bitwise_xor/docs/aclnnBitwiseXorScalar&aclnnInplaceBitwiseXorScalar.md) | 计算输入张量self中每个元素和输入标量other的按位异或,输入self和other必须是整数或布尔类型,对于布尔类型,计算逻辑异或。 | 默认确定性实现| 默认确定性实现 | |
| @@ -84,7 +84,6 @@ ${INSTALL_DIR}表示CANN安装后文件路径;\$\{ops\_project\}表示算子 | |||
| 84 | | [aclnnClampMaxTensor&aclnnInplaceClampMaxTensor](../../conversion/clip_by_value_v2/docs/aclnnClampMaxTensor&aclnnInplaceClampMaxTensor.md) | 将输入的所有元素限制在[-inf, max]范围内。 | 默认确定性实现| 默认确定性实现 | | 84 | | [aclnnClampMaxTensor&aclnnInplaceClampMaxTensor](../../conversion/clip_by_value_v2/docs/aclnnClampMaxTensor&aclnnInplaceClampMaxTensor.md) | 将输入的所有元素限制在[-inf, max]范围内。 | 默认确定性实现| 默认确定性实现 | |
| 85 | | [aclnnClampMin](../../conversion/clip_by_value_v2/docs/aclnnClampMin.md) | 将输入的所有元素限制在[min, inf]范围内。 | 默认确定性实现| 默认确定性实现 | | 85 | | [aclnnClampMin](../../conversion/clip_by_value_v2/docs/aclnnClampMin.md) | 将输入的所有元素限制在[min, inf]范围内。 | 默认确定性实现| 默认确定性实现 | |
| 86 | | [aclnnClampMinTensor&aclnnInplaceClampMinTensor](../../conversion/clip_by_value_v2/docs/aclnnClampMinTensor&aclnnInplaceClampMinTensor.md) | 将输入的所有元素限制在[min, inf]范围内。 | 默认确定性实现| 默认确定性实现 | | 86 | | [aclnnClampMinTensor&aclnnInplaceClampMinTensor](../../conversion/clip_by_value_v2/docs/aclnnClampMinTensor&aclnnInplaceClampMinTensor.md) | 将输入的所有元素限制在[min, inf]范围内。 | 默认确定性实现| 默认确定性实现 | |
| 87 | -| [aclnnCoalesceSparse](../../conversion/coalesce_sparse/docs/aclnnCoalesceSparse.md) | 将相同坐标点的value进行累加求和,进而减少Coo_Tensor的内存大小。 | 默认非确定性实现,不支持配置开启 | - | | ||
| 88 | | [aclnnClampTensor](../../conversion/clip_by_value_v2/docs/aclnnClampTensor.md) | 将输入的所有元素限制在[min, max]范围内,如果min缺省,则无下限,如果max缺省,则无上限。 | 默认确定性实现| 默认确定性实现 | | 87 | | [aclnnClampTensor](../../conversion/clip_by_value_v2/docs/aclnnClampTensor.md) | 将输入的所有元素限制在[min, max]范围内,如果min缺省,则无下限,如果max缺省,则无上限。 | 默认确定性实现| 默认确定性实现 | |
| 89 | | [aclnnComplex](../../math/complex/docs/aclnnComplex.md) | 输入两个Shape和Dtype一致的Tensor:real和imag。 | 默认确定性实现| - | | 88 | | [aclnnComplex](../../math/complex/docs/aclnnComplex.md) | 输入两个Shape和Dtype一致的Tensor:real和imag。 | 默认确定性实现| - | |
| 90 | | [aclnnConfusionTranspose](../../conversion/confusion_transpose_d/docs/aclnnConfusionTranspose.md) | 融合reshape和transpose运算。 | 默认确定性实现| 默认确定性实现 | | 89 | | [aclnnConfusionTranspose](../../conversion/confusion_transpose_d/docs/aclnnConfusionTranspose.md) | 融合reshape和transpose运算。 | 默认确定性实现| 默认确定性实现 | |
| @@ -7,11 +7,11 @@ | |||
| 7 | | 产品 | 是否支持 | | 7 | | 产品 | 是否支持 | |
| 8 | | :----------------------------------------------------------- | :------: | | 8 | | :----------------------------------------------------------- | :------: | |
| 9 | | <term>Ascend 950PR/Ascend 950DT</term> | √ | | 9 | | <term>Ascend 950PR/Ascend 950DT</term> | √ | |
| 10 | -| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ | | 10 | +| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | × | |
| 11 | -| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | 11 | +| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | × | |
| 12 | | <term>Atlas 200I/500 A2 推理产品</term> | × | | 12 | | <term>Atlas 200I/500 A2 推理产品</term> | × | |
| 13 | -| <term>Atlas 推理系列产品</term> | √ | | 13 | +| <term>Atlas 推理系列产品</term> | × | |
| 14 | -| <term>Atlas 训练系列产品</term> | √ | | 14 | +| <term>Atlas 训练系列产品</term> | × | |
| 15 | 15 | ||
| 16 | ## 功能说明 | 16 | ## 功能说明 |
| 17 | 17 | ||
| @@ -165,8 +165,6 @@ | |||
| 165 | </tbody> | 165 | </tbody> |
| 166 | </table> | 166 | </table> |
| 167 | 167 | ||
| 168 | - - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:不支持BFLOAT16数据类型。 | ||
| 169 | - | ||
| 170 | - **返回值:** | 168 | - **返回值:** |
| 171 | 169 | ||
| 172 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 170 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -5,11 +5,11 @@ | |||
| 5 | |产品 | 是否支持 | | 5 | |产品 | 是否支持 | |
| 6 | |:-------------------------|:----------:| | 6 | |:-------------------------|:----------:| |
| 7 | | <term>Ascend 950PR/Ascend 950DT</term> | √ | | 7 | | <term>Ascend 950PR/Ascend 950DT</term> | √ | |
| 8 | -| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ | | 8 | +| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | × | |
| 9 | -| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | 9 | +| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | × | |
| 10 | | <term>Atlas 200I/500 A2 推理产品</term> | × | | 10 | | <term>Atlas 200I/500 A2 推理产品</term> | × | |
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | -| <term>Atlas 训练系列产品</term> | √ | | 12 | +| <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | 15 | ||