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

Math API Sample Introduction

【免费下载链接】asc-devkit 本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。 【免费下载链接】asc-devkit 项目地址: https://gitcode.com/cann/asc-devkit

Overview

This sample collection demonstrates typical usage of various Math API features and provides corresponding end-to-end implementations.

Sample List

Directory NameDescriptionSupported Products
acoshThis sample demonstrates an operator implementation based on the Acosh high-level API. The sample computes the inverse hyperbolic cosine function element-wiseAscend 950PR/Ascend 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
axpy_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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
bitwiseandThis sample demonstrates an operator implementation based on the BitwiseAnd high-level API. The sample performs a bitwise AND operation on two inputsAscend 950PR/Ascend 950DT
ceilThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
clampThis 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 950DT
clampminThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
cumsumThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
erfThis sample demonstrates an operator implementation based on the Erf high-level API. The sample computes the error function element-wiseAscend 950PR/Ascend 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
expThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
fmaThis 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 950DT
fmodThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
fracThis sample demonstrates an operator implementation based on the Frac high-level API. The sample computes the fractional part element-wiseAscend 950PR/Ascend 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
isfiniteThis 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 950DT
logThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
logicalandThis 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 950DT
powerThis 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 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products
rintThis 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 950DT
whereThis 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 950DT
xorThis sample demonstrates an operator implementation based on the Xor high-level API. The sample performs XOR operations element-wiseAscend 950PR/Ascend 950DT
Atlas A3 Training Series Products/Atlas A3 Inference Series Products
Atlas A2 Training Series Products/Atlas A2 Inference Series Products

【免费下载链接】asc-devkit 本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。 【免费下载链接】asc-devkit 项目地址: https://gitcode.com/cann/asc-devkit

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值