Skip to content

LogicalOr

产品支持情况

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

功能说明

按元素进行或操作。当输入的数据类型不是bool时,零被视为False,非零数据被视为True。

函数原型

Text
template <const LogicalOrConfig& config = DEFAULT_LOGICAL_OR_CONFIG, typename T, typename U>
__aicore__ inline void LogicalOr(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, const uint32_t count)

参数说明

表1 模板参数说明

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

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

表2 接口参数说明

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

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

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

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

返回值说明

约束说明

调用示例

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

结果示例如下:

Text
输入数据(src0):
[1, 2, 0, -1, -2, 0, 3, 4, 0, -3, -4, 0, 5, 6, 0, -5, -6, 0, ... 0]
输入数据(src1):
[1, 0, 0, -1, 0, 0, 3, 0, 0, -3, 0, 0, 5, 0, 0, -5, 0, 0, ... 0]
输出数据(dst):
[ True,  True,  False,  True,  True,  False,  True,  True,  False,  True,
  True,  False,  True,  True,  False,  True,  True,  False,  ...  False]

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