aclnnIndexFillTensor&aclnnInplaceIndexFillTensor
支持的产品型号
- Atlas 训练系列产品。
- Atlas A2训练系列产品/Atlas 800I A2推理产品。
接口原型
aclnnIndexFillTensor和aclnnInplaceIndexFillTensor实现相同的功能,使用区别如下,请根据自身实际场景选择合适的算子。
- aclnnIndexFillTensor:需新建一个输出张量对象存储计算结果。
- aclnnInplaceIndexFillTensor:无需新建输出张量对象,直接在输入张量的内存中存储计算结果。
每个算子分为,必须先调用“aclnnIndexFillTensorGetWorkspaceSize”或者“aclnnInplaceIndexFillTensorGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnIndexFillTensor”或者“aclnnInplaceIndexFillTensor”接口执行计算。
aclnnStatus aclnnIndexFillTensorGetWorkspaceSize(const aclTensor *self, int64_t dim, const aclIntArray *index, const aclScalar *value, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)
aclnnStatus aclnnIndexFillTensor(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
aclnnStatus aclnnInplaceIndexFillTensorGetWorkspaceSize(aclTensor *selfRef, int64_t dim, const aclIntArray *index, const aclScalar *value, uint64_t *workspaceSize, aclOpExecutor **executor)
aclnnStatus aclnnInplaceIndexFillTensor(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
功能描述
算子功能:沿输入self的给定轴dim,将index指定位置的值使用value进行替换。
示例: 输入self为:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
若dim = 0,index = [0, 2], value = 0时,算子的计算结果为:
[[0, 0, 0],
[4, 5, 6],
[0, 0, 0]]
若dim = 1,index = [0, 2], value = 0时,算子的计算结果为:
[[0, 2, 0],
[0, 5, 0],
[0, 8, 0]]
aclnnIndexFillTensorGetWorkspaceSize
参数说明:
- self(aclTensor*, 计算输入):Device侧的aclTensor,数据类型支持FLOAT16、FLOAT、INT32、INT64、BOOL、BFLOAT16(仅Atlas A2训练系列产品/Atlas 800I A2推理产品支持)。支持,支持ND。
- dim(int64_t , 计算输入):host侧int64类型,指定了self将要填充的维度。
- index(aclIntArray*, 计算输入):aclIntArray 类型,指定self在dim维度将要填充的下标。数据类型支持INT64、INT32、INT16、INT8、UINT8。其中的元素值小于self对应dim的维度。
- value(aclScalar *, 计算输入):Device侧的aclScalar,指定填充的数据值。数据类型支持FLOAT16、FLOAT、INT32、INT64、BOOL、BFLOAT16(仅Atlas A2训练系列产品/Atlas 800I A2推理产品支持)。
- out(aclTensor*, 计算输出):指定的输出张量,Device侧的aclTensor类型,数据类型支持FLOAT16、FLOAT、INT32、INT64、BOOL、BFLOAT16(仅Atlas A2训练系列产品/Atlas 800I A2推理产品支持),且数据类型需要与self保持一致,支持ND。
- workspaceSize(uint64_t*, 出参):返回用户需要在Device侧申请的workspace大小。
- executor(clOpExecutor**, 出参):返回op执行器,包含了算子计算流程。
返回值:
[object Object]
aclnnIndexFillTensor
参数说明:
- workspace(void*, 入参):在Device侧申请的workspace内存地址。
- workspaceSize(uint64_t, 入参):在Device侧申请的workspace大小,由第一段接口aclnnIndexFillTensorTensor获取。
- executor(aclOpExecutor*, 入参):op执行器,包含了算子计算流程。
- stream(aclrtStream, 入参):AscendCL stream流。
返回值:
aclnnInplaceIndexFillTensorGetWorkspaceSize
参数说明:
- selfRef(aclTensor *,计算输入|计算输出):输入输出tensor,Device侧的aclTensor,数据类型支持FLOAT16、FLOAT、INT32、INT64、BOOL、BFLOAT16(仅Atlas A2训练系列产品/Atlas 800I A2推理产品支持)。支持,支持ND。
- dim(int64_t,计算输入):host侧int64类型,指定了selfRef将要填充的维度。
- index(const aclIntArray,计算输入):aclIntArray类型,指定selfRef在dim维度将要填充的下标。数据类型支持INT64、INT32、INT16、INT8、UINT8。其中的元素值小于selfRef对应的dim维度。
- value(const aclScalar*,计算输入):Device侧的aclScalar,指定填充的数据值。数据类型支持FLOAT16、FLOAT、INT32、INT64、BOOL、BFLOAT16(仅Atlas A2训练系列产品/Atlas 800I A2推理产品支持)。
- workspaceSize(uint64_t*,出参):返回用户需要在Device侧申请的workspace大小。
- executor(aclOpExecutor **,出参):返回op执行器,包含了算子计算流程。
返回值:
[object Object]
aclnnInplaceIndexFillTensor
参数说明:
- workspace(void*, 入参):在Device侧申请的workspace内存地址。
- workspaceSize(uint64_t, 入参):在Device侧申请的workspace大小,由第一段接口aclnnInplaceIndexFillTensorGetWorkspaceSize获取。
- executor(aclOpExecutor*, 入参):op执行器,包含了算子计算流程。
- stream(aclrtStream, 入参):指定执行任务的 AscendCL Stream流。
返回值:
约束与限制
无
调用示例
aclnnIndexFillTensor调用示例:
[object Object]
aclnnInplaceIndexFillTensor调用示例:
[object Object]