FilesLast commitLast update
12 days ago
10 months ago
1 month ago
7 days ago
7 days ago
2 months ago
2 months ago
24 days ago
7 days ago
5 days ago
README

ViewCopy

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function Description

  • Operator function: copies the src tensor as the view described by src_size, src_stride, and src_storage_offset to the dst tensor as the view described by dst_size, dst_stride, and dst_storage_offset, and returns dst.

  • Computation formula:

    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]

    where nn is the number of view dimensions; dst_indexi\text{dst\_index}_i and src_indexi\text{src\_index}_i are the indices of the dst and src views in the ii-th dimension respectively, with the value ranges 0≤dst_indexi<dst_sizei0 \le \text{dst\_index}_i < \text{dst\_size}_i and 0≤src_indexi<src_sizei0 \le \text{src\_index}_i < \text{src\_size}_i. Since dst_size and src_size have the same shape, the indices of corresponding dimensions are element-wise equal; dst_storage_offset\text{dst\_storage\_offset} and src_storage_offset\text{src\_storage\_offset} are the view start offsets; dst_stridei\text{dst\_stride}_i and src_stridei\text{src\_stride}_i are the strides of the ii-th dimension. The content in square brackets is the element subscript in the tensor storage area.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
dst Input Destination tensor to be written to. Its view is described by dst_size, dst_stride, and dst_storage_offset. BFLOAT16, FLOAT16, FLOAT, UINT8, INT8, UINT16, INT16, UINT32, INT32, UINT64, INT64, BOOL, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN ND
dst_size Input View shape of the dst tensor, a 1D tensor, whose elements are non-negative and whose number of elements is the same as that of dst_stride. INT32, INT64 ND
dst_stride Input View stride of the dst tensor, a 1D tensor, whose elements are non-negative and whose number of elements is the same as that of dst_size. INT32, INT64 ND
dst_storage_offset Input View start offset of the dst tensor, a 1D tensor, whose elements are non-negative and do not exceed the element range of the dst tensor. INT32, INT64 ND
src Input Source tensor to be read. Its view is described by src_size, src_stride, and src_storage_offset. BFLOAT16, FLOAT16, FLOAT, UINT8, INT8, UINT16, INT16, UINT32, INT32, UINT64, INT64, BOOL, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN ND
src_size Input View shape of the src tensor, a 1D tensor, whose elements are non-negative and whose number of elements is the same as that of src_stride. INT32, INT64 ND
src_stride Input View stride of the src tensor, a 1D tensor, whose elements are non-negative and whose number of elements is the same as that of src_size. INT32, INT64 ND
src_storage_offset Input View start offset of the src tensor, a 1D tensor, whose elements are non-negative and do not exceed the element range of the src tensor. INT32, INT64 ND
dst Output Copy result, which shares the same memory as the input dst (in-place write). BFLOAT16, FLOAT16, FLOAT, UINT8, INT8, UINT16, INT16, UINT32, INT32, UINT64, INT64, BOOL, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN ND

Constraint Description

  • dst_size and src_size have the same shape.
  • The number of dimensions of dst_size is the same as that of dst_stride; the number of dimensions of src_size is the same as that of src_stride.
  • The elements of dst_size and src_size are non-negative.
  • The elements of dst_stride and src_stride are non-negative.
  • dst_storage_offset and src_storage_offset are non-negative and do not exceed the element range of the corresponding tensors.
  • For each axis i, dst_storage_offset + (dst_size[i] - 1) * dst_stride[i] does not exceed the number of elements of the dst tensor. The same applies to src.
  • For the dtype, type conversion, and determinism constraints at the aclnn API layer, see aclnnInplaceCopy.

Invocation Description

Invocation Method Sample Code Description
aclnn invocation test_aclnn_view_copy Invokes the ViewCopy operator through the aclnnInplaceCopy API.
Graph-mode invocation - Invokes the ViewCopy operator by building a graph through the operator IR.