news 2026/6/6 5:17:42

CANN/sip插值算子文档

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
CANN/sip插值算子文档

asdInterpWithCoeff

【免费下载链接】sip本项目是CANN提供的一款高效、可靠的高性能信号处理算子加速库,基于华为Ascend AI处理器,专门为信号处理领域而设计。项目地址: https://gitcode.com/cann/sip

产品支持情况

产品是否支持
Atlas 200I/500 A2 推理产品×
Atlas 推理系列产品×
Atlas 训练系列产品×
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品
Ascend 950PR/Ascend 950DT×

功能说明

  • 接口功能:
    asdInterpWithCoeffGetWorkspaceSize:计算asdInterpWithCoeff算子所需的workspace大小。
    asdInterpWithCoeff:支持向量插值操作,主要用于数据符号的信道估计,或者均衡系数插值。

  • 计算公式:

    $$ result=A \odot\ B =(A){ij}(B){ij} $$

    示例:

    输入“A”为:
    [ [ 1+1i, 1+1i ],
    [ 2+2i, 2+2i ] ]
    输入“B”为:
    [ [ 1+1i, 1+1i ],
    [ 2+2i, 2+2i ] ]
    调用asdInterpWithCoeff算子后,输出“result”为:
    [ [ 0+2i, 0+2i ],
    [ 0+8i, 0+8i ] ]

函数原型

AspbStatus asdInterpWithCoeffGetWorkspaceSize( size_t & workspaceSize)
AspbStatus asdInterpWithCoeff( const aclTensor * x, const aclTensor * coefficient, aclTensor * y, void * stream, void * workSpace = nullptr)

asdInterpWithCoeffGetWorkspaceSize

  • 参数说明:

    参数名输入/输出描述
    workspaceSize(size_t &)输出算子所需要的workspace。
  • 返回值

    返回状态码,具体参见SiP返回码。

asdInterpWithCoeff

  • 参数说明:

    参数名输入/输出描述
    x(aclTensor *)输入
    • 对应公式中的'B'。
    • 数据类型支持COMPLEX32、COMPLEX64
    • 数据格式支持ND。
    • shape为[batch,nRs, totalSubcarrier]。
      • batch:波束数量,取值范围是1~1024 (6G时最大取值为16(终端的流数)*64(基站接收的波束数)=1024)。
      • nRs:参考信号数,取值是2、4。
      • totalSubcarrier = nRB*12。
      • nRB:资源块数,取值范围是1~2730 (每RB包含12个子载波,5G时取值范围是1~273,6G时取值是5G的4倍到10倍)。
    coefficient(aclTensor *)输入
    • 对应公式中的'A'。
    • 数据类型支持COMPLEX32、COMPLEX64
    • 数据格式支持ND。
    • shape为[batch, 14-nRs, nRs]。
      • batch:波束数量,取值范围是1~1024 (6G时最大取值为16(终端的流数)*64(基站接收的波束数)=1024)。
      • nRs:参考信号数,取值是2、4。
    y(aclTensor *)输出
    • 对应公式中的'result'。
    • 数据类型支持COMPLEX32、COMPLEX64
    • 数据格式支持ND。
    • shape为[batch,14-nRs, totalSubcarrier]。
      • batch:波束数量,取值范围是1~1024 (6G时最大取值为16(终端的流数)*64(基站接收的波束数)=1024)。
      • nRs:参考信号数,取值是2、4。
      • totalSubcarrier = nRB*12。
      • nRB:资源块数,取值范围是1~2730 (每RB包含12个子载波,5G时取值范围是1~273, 6G时取值是5G的4倍到10倍)。
    stream(void *)输入npu执行流。
    workspace(void *)输入asdInterpWithCoeff算子所需要的workspace。
  • 返回值

    返回状态码,具体参见SiP返回码。

约束说明

调用示例

示例代码如下,该样例旨在提供快速上手、开发和调试算子的最小化实现,其核心目标是使用最精简的代码展示算子的核心功能,而非提供生产级的安全保障。不推荐用户直接将示例代码作为业务代码,若用户将示例代码应用在自身的真实业务场景中且发生了安全问题,则需用户自行承担。

#include <iostream> #include <complex> #include <vector> #include "interp_api.h" #include "acl/acl.h" #include "acl_meta.h" using namespace AsdSip; int64_t GetShapeSize(const std::vector<int64_t> &shape) { int64_t shapeSize = 1; for (auto i : shape) { shapeSize *= i; } return shapeSize; } int Init(int32_t deviceId, aclrtStream *stream) { // 固定写法,acl初始化 aclInit(nullptr); aclrtSetDevice(deviceId); aclrtCreateStream(stream); return 0; } template <typename T> int CreateAclTensor(const std::vector<T> &hostData, const std::vector<int64_t> &shape, void **deviceAddr, aclDataType dataType, aclTensor **tensor) { auto size = GetShapeSize(shape) * sizeof(T) * 2; // 2 : complex // 调用aclrtMalloc申请device侧内存 aclrtMalloc(deviceAddr, size, ACL_MEM_MALLOC_HUGE_FIRST); // 调用aclrtMemcpy将host侧数据复制到device侧内存上 aclrtMemcpy(*deviceAddr, size, hostData.data(), size, ACL_MEMCPY_HOST_TO_DEVICE); // 计算连续tensor的strides std::vector<int64_t> strides(shape.size(), 1); for (int64_t i = shape.size() - 2; i >= 0; i--) { strides[i] = shape[i + 1] * strides[i + 1]; } // 调用aclCreateTensor接口创建aclTensor *tensor = aclCreateTensor(shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), *deviceAddr); return 0; } int main(int argc, char **argv) { // 设置算子使用的device id int deviceId = 0; //(固定写法)创造执行流 aclrtStream stream; Init(deviceId, &stream); // 创造tensor的Host侧数据 int64_t batch = 1; int64_t nRs = 2; int64_t totalSubcarrier = 32; int64_t nSignal = 14; int64_t xSize = batch * nRs * totalSubcarrier * 2; std::vector<float> tensorInXData; tensorInXData.reserve(xSize); for (int64_t i = 0; i < xSize; i++) { tensorInXData[i] = 1.0 + i; } int64_t coeffSize = batch * (nSignal - nRs) * nRs * 2; std::vector<float> coeffData; coeffData.reserve(xSize); for (int64_t i = 0; i < coeffSize; i++) { coeffData[i] = 1; } int64_t resultSize = batch * (nSignal - nRs) * totalSubcarrier * 2; std::vector<float> resultData; resultData.reserve(resultSize); for (int64_t i = 0; i < resultSize; i++) { resultData[i] = 2; } // int64_t xSize = batch * nRs * totalSubcarrier; // std::vector<std::complex<float>> tensorInXData(xSize, std::complex<float>(0, 0)); // for (int i = 0; i < xSize; i++) { // tensorInXData[i] = std::complex<float>(i * 2, i * 2 + 1); // } // int64_t coeffSize = batch * (nSignal - nRs) * nRs; // std::vector<std::complex<float>> coeffData(xSize, std::complex<float>(0, 0)); // for (int i = 0; i < coeffSize; i++) { // coeffData[i] = std::complex<float>(1, 1); // } // int64_t resultSize = batch * (nSignal - nRs) * totalSubcarrier; // std::vector<std::complex<float>> resultData(xSize, std::complex<float>(0, 0)); // for (int i = 0; i < resultSize; i++) { // resultData[i] = std::complex<float>(2, 2); // } std::cout << "------- input x -------" << std::endl; for (int64_t i = 0; i < xSize; i++) { std::cout << tensorInXData[i] << " "; } std::cout << std::endl; std::cout << "------- input coeff -------" << std::endl; for (int64_t i = 0; i < coeffSize; i++) { std::cout << coeffData[i] << " "; } std::cout << std::endl; // 创造输入/输出tensor aclTensor *inputX = nullptr; aclTensor *inputCoeff = nullptr; aclTensor *result = nullptr; void *inputXDeviceAddr = nullptr; void *inputYDeviceAddr = nullptr; void *resultDeviceAddr = nullptr; CreateAclTensor(tensorInXData, {batch, nRs, totalSubcarrier}, &inputXDeviceAddr, aclDataType::ACL_COMPLEX64, &inputX); CreateAclTensor(coeffData, {batch, nSignal-nRs, nRs}, &inputYDeviceAddr, aclDataType::ACL_COMPLEX64, &inputCoeff); CreateAclTensor(resultData, {batch, nSignal-nRs, totalSubcarrier}, &resultDeviceAddr, aclDataType::ACL_COMPLEX64, &result); size_t lwork = 0; void *buffer = nullptr; AsdSip::asdInterpWithCoeffGetWorkspaceSize(lwork); if (lwork > 0) { aclrtMalloc(&buffer, static_cast<int64_t>(lwork), ACL_MEM_MALLOC_HUGE_FIRST); } asdInterpWithCoeff(inputX, inputCoeff, result, stream, buffer); aclrtSynchronizeStream(stream); // 将输出tensor的Device侧数据复制到Host侧内存上 aclrtMemcpy(resultData.data(), resultSize * sizeof(float), resultDeviceAddr, resultSize * sizeof(float), ACL_MEMCPY_DEVICE_TO_HOST); std::cout << "------- result -------" << std::endl; for (int64_t i = 0; i < nSignal - nRs; i++) { for (int64_t j = 0; j < totalSubcarrier * 2; j++) { std::cout << resultData[i * totalSubcarrier * 2 + j] << " "; } std::cout << std::endl; } // 资源释放 aclDestroyTensor(inputX); aclDestroyTensor(inputCoeff); aclDestroyTensor(result); aclrtFree(inputXDeviceAddr); aclrtFree(inputYDeviceAddr); aclrtFree(resultDeviceAddr); if (lwork > 0) { aclrtFree(buffer); } // 调度算子后重置算子使用的deviceId aclrtDestroyStream(stream); aclrtResetDevice(deviceId); aclFinalize(); return 0; }

【免费下载链接】sip本项目是CANN提供的一款高效、可靠的高性能信号处理算子加速库,基于华为Ascend AI处理器,专门为信号处理领域而设计。项目地址: https://gitcode.com/cann/sip

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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/6 5:17:39

jQuery Visible插件最佳实践:企业级应用中的可见性检测方案

jQuery Visible插件最佳实践&#xff1a;企业级应用中的可见性检测方案 【免费下载链接】jquery-visible A jquery plugin which allows us to quickly check if an element is within the browsers visual viewport regardless of the window scroll position 项目地址: htt…

作者头像 李华
网站建设 2026/6/6 5:17:39

Holo-3.1-4B模型架构解析:从Qwen 3.5到多模态AI的演进之路

Holo-3.1-4B模型架构解析&#xff1a;从Qwen 3.5到多模态AI的演进之路 【免费下载链接】Holo-3.1-4B 项目地址: https://ai.gitcode.com/hf_mirrors/Hcompany/Holo-3.1-4B Holo-3.1-4B是基于Qwen 3.5架构开发的多模态AI模型&#xff0c;融合了文本、图像和视频理解能力…

作者头像 李华
网站建设 2026/6/6 5:16:30

Amazfit 推出 Balance 3 与 Balance Ultra,开启混合训练新时代

全新 Balance 系列搭载 Amazfit 混合训练系统&#xff0c;将先进智能手表硬件与 Zepp App 智能分析能力深度融合&#xff0c;帮助运动员在力量训练、耐力提升、恢复管理及日常生活等多个维度实现科学规划与系统化训练全球领先智能穿戴品牌 Amazfit&#xff08;隶属于 Zepp Heal…

作者头像 李华
网站建设 2026/6/6 5:15:44

ARMv8与MTK8766隔离区固件架构解析

ARM V8与 MTK8766各隔离区运行的实体固件详解ARMv8架构通过异常等级和安全状态将系统划分为多个隔离区&#xff0c;每个隔离区运行着不同的实体固件&#xff0c;负责不同的功能。理解每个隔离区运行的实体固件&#xff0c;是掌握整个系统架构的关键。1.1 标准ARMv8隔离区实体1.…

作者头像 李华
网站建设 2026/6/6 5:14:41

51单片机搭配ADC0832实测100V直流电压的完整软硬件方案

本文还有配套的精品资源&#xff0c;点击获取 简介&#xff1a;用STC89C52或AT89C51这类经典51单片机&#xff0c;配合ADC0832模数转换芯片&#xff0c;实现对100V左右直流电压的安全、稳定采样。硬件采用分压加隔离设计&#xff0c;兼顾抗干扰与电气安全&#xff0c;可直接…

作者头像 李华
网站建设 2026/6/6 5:11:02

sass-resources-loader源码解析:深入理解Webpack Loader的工作原理

sass-resources-loader源码解析&#xff1a;深入理解Webpack Loader的工作原理 【免费下载链接】sass-resources-loader SASS resources (e.g. variables, mixins etc.) loader for Webpack. Also works with less, post-css, etc. 项目地址: https://gitcode.com/gh_mirrors…

作者头像 李华