文件最后提交记录最后更新时间
3 天前
10 个月前
1 个月前
12 天前
4 天前
2 个月前
2 个月前
4 天前
12 天前
10 天前
README

ViewCopy

产品支持情况

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

功能说明

  • 算子功能:将src张量按src_size、src_stride、src_storage_offset描述的视图复制到dst张量按dst_size、dst_stride、dst_storage_offset描述的视图,并返回dst。

  • 计算公式:

    dst[dst_storage_offset+∑i=0n−1dst_indexi⋅dst_stridei]=src[src_storage_offset+∑i=0n−1src_indexi⋅src_stridei]\text{dst}\left[\text{dst\_storage\_offset} + \sum_{i=0}^{n-1} \text{dst\_index}_i \cdot \text{dst\_stride}_i\right] = \text{src}\left[\text{src\_storage\_offset} + \sum_{i=0}^{n-1} \text{src\_index}_i \cdot \text{src\_stride}_i\right]

    其中,nn为视图维度数;dst_indexi\text{dst\_index}_i、src_indexi\text{src\_index}_i分别为dst、src视图在第ii维的索引,取值范围为0≤dst_indexi<dst_sizei0 \le \text{dst\_index}_i < \text{dst\_size}_i、0≤src_indexi<src_sizei0 \le \text{src\_index}_i < \text{src\_size}_i,且因dst_size与src_size形状一致,对应维度的索引逐元素相等;dst_storage_offset\text{dst\_storage\_offset}、src_storage_offset\text{src\_storage\_offset}为视图起始偏移量;dst_stridei\text{dst\_stride}_i、src_stridei\text{src\_stride}_i为第ii维步长。方括号内为张量存储区中的元素下标。

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
dst 输入 待写入的目标张量,按dst_size、dst_stride、dst_storage_offset描述其视图。 BFLOAT16、FLOAT16、FLOAT、UINT8、INT8、UINT16、INT16、UINT32、INT32、UINT64、INT64、BOOL、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN ND
dst_size 输入 dst张量的视图shape,1D tensor,元素非负,元素个数与dst_stride一致。 INT32、INT64 ND
dst_stride 输入 dst张量的视图stride,1D tensor,元素非负,元素个数与dst_size一致。 INT32、INT64 ND
dst_storage_offset 输入 dst张量的视图起始偏移量,1D tensor,元素非负且不超出dst张量元素范围。 INT32、INT64 ND
src 输入 待读取的源张量,按src_size、src_stride、src_storage_offset描述其视图。 BFLOAT16、FLOAT16、FLOAT、UINT8、INT8、UINT16、INT16、UINT32、INT32、UINT64、INT64、BOOL、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN ND
src_size 输入 src张量的视图shape,1D tensor,元素非负,元素个数与src_stride一致。 INT32、INT64 ND
src_stride 输入 src张量的视图stride,1D tensor,元素非负,元素个数与src_size一致。 INT32、INT64 ND
src_storage_offset 输入 src张量的视图起始偏移量,1D tensor,元素非负且不超出src张量元素范围。 INT32、INT64 ND
dst 输出 复制结果,与输入dst为同一块内存(原地写入)。 BFLOAT16、FLOAT16、FLOAT、UINT8、INT8、UINT16、INT16、UINT32、INT32、UINT64、INT64、BOOL、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN ND

约束说明

  • dst_size与src_size形状一致。
  • dst_size与dst_stride维度数一致;src_size与src_stride维度数一致。
  • dst_size、src_size的元素非负。
  • dst_stride、src_stride的元素非负。
  • dst_storage_offset、src_storage_offset非负,且不超出对应张量的元素范围。
  • 对每个轴i,dst_storage_offset + (dst_size[i] - 1) * dst_stride[i]不超过dst张量元素数;src同理。
  • aclnn接口层的dtype、类型转换和确定性约束见aclnnInplaceCopy。

调用说明

调用方式 样例代码 说明
aclnn调用 test_aclnn_view_copy 通过aclnnInplaceCopy接口方式调用ViewCopy算子。
图模式调用 - 通过算子IR构图方式调用ViewCopy算子。