昇腾社区首页
中文
注册

aclnnNonMaxSuppression

支持的产品型号

  • Atlas 推理系列产品。

接口原型

每个算子分为undefined,必须先调用“aclnnNonMaxSuppressionGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnNonMaxSuppression”接口执行计算。

  • aclnnStatus aclnnNonMaxSuppressionGetWorkspaceSize(const aclTensor *boxes, const aclTensor *scores, aclIntArray *maxOutputBoxesPerClass, aclFloatArray *iouThreshold, aclFloatArray *scoreThreshold, int32_t centerPointBox, aclTensor *selectedIndices, uint64_t *workspaceSize, aclOpExecutor **executor)
  • aclnnStatus aclnnNonMaxSuppression(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)

功能描述

算子功能:删除分数小于 scoreThreshold 的边界框, 筛选出 与之前被选中 重叠较高(IOU较高)的框。

aclnnNonMaxSuppressionGetWorkspaceSize

  • 参数说明:

    • boxes(aclTensor*, 计算输入):Device侧的aclTensor,数据类型支持FLOAT、FLOAT16。支持undefined,支持undefined。3维shape:[num_batches, spatial_dimension, 4]。

    • scores(aclTensor*, 计算输入):Device侧的aclTensor,数据类型支持FLOAT、FLOAT16。支持undefined,支持undefined。3维shape:[num_batches, num_classes, spatial_dimension]。

    • maxOutputBoxesPerClass(aclIntArray*, 计算输入):Host侧的aclIntArray,数据类型支持INT32。支持undefined,支持undefined。数值上限为700。表示每个类别每batch要选择的最大框数。

    • iouThreshold(aclFloatArray*, 计算输入):Host侧的aclFloatArray,数据类型支持FLOAT。支持undefined,支持undefined。取值范围[0, 1]。表示判断框相对于IOU是否重叠过多的阈值。

    • scoreThreshold(aclFloatArray*, 计算输入):Host侧的aclFloatArray,数据类型支持FLOAT。支持undefined,支持undefined。取值范围[0, 1]。表示根据得分决定何时移除框的阈值。

    • centerPointBox(int, 计算输入):Host侧的整数,数据类型支持INT32。取值范围[0, 1]。用于决定边界框格式。等于0时,主要用于TF模型,数据以(y1, x1, y2, x2)形式提供,其中(y1, x1) (y2, x2)是对角线框角坐标,需要用户自行保证x1<x2, y1<y2;等于1时, 主要用于pytorch模型。框数据以(x_center, y_center, width, height)形式提供。

    • selectedIndices(aclTensor*, 计算输出):Device侧的aclTensor,数据类型支持INT32。支持undefined,支持undefined。shape:[num_selected_indices, 3],数据以[batch_index, class_index, box_index]形式提供。

    • workspaceSize(uint64_t*, 出参):返回需要在Device侧申请的workspace大小。

    • executor(aclOpExecutor**, 出参):返回op执行器,包含了算子计算流程。

  • 返回码:

    aclnnStatus:返回状态码,具体参见undefined

[object Object]

aclnnNonMaxSuppression

  • 参数说明:

    • workspace(void*, 入参):在Device侧申请的workspace内存地址。

    • workspaceSize(uint64_t, 入参):在Device侧申请的workspace大小,由第一段接口aclnnNonMaxSuppressionGetWorkspaceSize获取。

    • executor(aclOpExecutor*, 入参):op执行器,包含了算子计算流程。

    • stream(aclrtStream, 入参):指定执行任务的 AscendCL Stream流。

  • 返回码:

    aclnnStatus:返回状态码,具体参见undefined

约束与限制

maxOutputBoxesPerClass 参数上限为700。输入参数boxes和scores的数据类型要求保持一致。

调用示例

示例代码如下,仅供参考,具体编译和执行过程请参考undefined

[object Object]