Skip to content

BitwiseAnd

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持

功能说明

逐比特对两个输入进行与操作。

函数原型

Text
template <const BitwiseAndConfig& config = DEFAULT_BITWISE_AND_CONFIG, typename T>
__aicore__ inline void BitwiseAnd(const LocalTensor<T>& dst, const LocalTensor<T>& src0, const LocalTensor<T>& src1, const uint32_t count)

参数说明

表1 模板参数说明

参数名描述
configBitwiseAnd算法的相关配置。此参数可选配,BitwiseAndConfig类型,具体定义如下方代码所示,其中参数的含义为:

isReuseSource:该参数预留,传入默认值false即可。
T操作数的数据类型。支持的数据类型为:int8_t、uint8_t、int16_t、uint16_t、int32_t、uint32_t、int64_t、uint64_t。
Text
struct BitwiseAndConfig {
    bool isReuseSource;
};

表2 接口参数说明

参数名输入/输出描述
dst输出目的操作数。

类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。
src0、src1输入源操作数。

类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。

源操作数的数据类型与目的操作数保持一致。
count输入参与计算的元素个数。

返回值说明

约束说明

调用示例

Text
AscendC::LocalTensor<uint16_t> dst, src0, src1;
uint32_t count = 512; // 参与计算的元素个数
AscendC::BitwiseAnd(dst, src0, src1, count);

结果示例如下:

Text
输入数据(src0):
[93, 87, 99, 1, 87, 58, 6, 16, 85, 66, 56, 65, 24, 98, 96, 50, 18, 37, 0, ... 66]
输入数据(src1):
[81, 12, 33, 47, 47, 18, 82, 44, 91, 34, 17, 99, 7, 82, 42, 85, 88, 99, 61, ... 81]
输出数据(dst):
[81, 4, 33, 1, 7, 18, 2, 0, 81, 2, 16, 65, 0, 66, 32, 16, 16, 33, 0, ... 64]

免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区