CANN/asc-devkit数学API示例介绍

发布时间:2026/6/13 17:07:31

CANN/asc-devkit数学API示例介绍 Math API Sample Introduction【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkitOverviewThis sample collection demonstrates typical usage of various Math API features and provides corresponding end-to-end implementations.Sample ListDirectory NameDescriptionSupported ProductsacoshThis sample demonstrates an operator implementation based on the Acosh high-level API. The sample computes the inverse hyperbolic cosine function element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series Productsaxpy_half_floatThis sample implements the functionality of multiplying each element in the source operand src by a scalar and adding it to the corresponding element in the destination operand dst using Axpy. The data type combinations for the source and destination operands of the Axpy interface can only be: (half, half), (float, float), or (half, float). In this sample, the input tensor and scalar data types are half, and the output tensor data type is float. This sample implements the Axpy operator using Ascend C and uses the kernel call operator to complete the basic flow of running and verifying the operator kernel function on the NPU side, providing the corresponding end-to-end implementationAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsbitwiseandThis sample demonstrates an operator implementation based on the BitwiseAnd high-level API. The sample performs a bitwise AND operation on two inputsAscend 950PR/Ascend 950DTceilThis sample demonstrates an operator implementation based on the Ceil high-level API. The sample obtains the smallest integer greater than or equal to x, that is, rounding toward positive infinityAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsclampThis sample demonstrates an operator implementation based on the Clamp high-level API. Values in the input that are not nan and fall outside the [min, max] range are clipped to max or min. If min is greater than max, all non-nan values are set to maxAscend 950PR/Ascend 950DTclampminThis sample demonstrates an operator implementation based on the ClampMin high-level API. The sample replaces numbers in srcTensor that are less than scalar with scalar, while numbers greater than or equal to scalar remain unchanged, and outputs as dstTensorAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductscumsumThis sample introduces how to call the CumSum high-level API to implement the cumsum operator, which computes cumulative sums along rows or columns of an input tensorAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductserfThis sample demonstrates an operator implementation based on the Erf high-level API. The sample computes the error function element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsexpThis sample demonstrates an operator implementation based on the Exp high-level API. The sample computes the natural exponential element-wise. Users can choose whether to use the Taylor series expansion formula for computationAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsfmaThis sample demonstrates an operator implementation based on the Fma high-level API. The sample computes the result of multiplying two inputs element-wise and then adding a third inputAscend 950PR/Ascend 950DTfmodThis sample demonstrates an operator implementation based on the Fmod high-level API. The sample computes the remainder of dividing two floating-point numbers a and b element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsfracThis sample demonstrates an operator implementation based on the Frac high-level API. The sample computes the fractional part element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsisfiniteThis sample demonstrates an operator implementation based on the IsFinite high-level API. The sample determines whether input floating-point numbers are neither NAN nor INF element-wise. The output result is either a floating-point number or a boolean valueAscend 950PR/Ascend 950DTlogThis sample demonstrates an operator implementation based on the Log high-level API. The sample computes logarithms with base e, 2, or 10 element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductslogicalandThis sample demonstrates an operator implementation based on the LogicalAnd high-level API. The sample performs a logical AND operation element-wise. When the input data type is not bool, zero is treated as False and non-zero data is treated as TrueAscend 950PR/Ascend 950DTpowerThis sample demonstrates an operator implementation based on the Power high-level API. The sample implements element-wise power operations and supports three modes: tensor-to-tensor, tensor-to-scalar, and scalar-to-tensor power operationsAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series ProductsrintThis sample demonstrates an operator implementation based on the Rint high-level API. The sample obtains the integer closest to the input data. If two integers are equally close, the even number is selectedAscend 950PR/Ascend 950DTwhereThis sample demonstrates an operator implementation based on the Where high-level API. The sample selects elements from two source operands based on specified conditions to generate a destination operand. Both source operands can be either LocalTensor or scalarAscend 950PR/Ascend 950DTxorThis sample demonstrates an operator implementation based on the Xor high-level API. The sample performs XOR operations element-wiseAscend 950PR/Ascend 950DTAtlas A3 Training Series Products/Atlas A3 Inference Series ProductsAtlas A2 Training Series Products/Atlas A2 Inference Series Products【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻