FilesLast commitLast update
13 days ago
8 days ago
8 days ago
13 days ago
13 days ago
13 days ago
13 days ago
14 days ago
README

StridedSliceAssign

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: StridedSliceAssign is a tensor slice assignment operation, which assigns the content of the input tensor inputValue to the slice position of the target tensor var specified by begin, end, and strides. The region outside the slice keeps the original value of var unchanged. The output var has the same name as the input var, which is in-place semantics, and the output shape is the same as the shape of the input var.

  • Computation formula:

out[b0:e0:s0,b1:e1:s1,… ]=inputValueout[b_0:e_0:s_0, b_1:e_1:s_1, \dots] = inputValue

The length of the i-th dimension of the slice is sliceLen[i]=max⁡(0,⌈end[i]−begin[i]strides[i]⌉)sliceLen[i] = \max(0, \lceil\frac{end[i] - begin[i]}{strides[i]}\rceil), where ⌈x⌉\lceil x \rceil denotes the ceiling of xx. beginbegin and endend are values after negative index normalization and boundary truncation: if x<0x < 0, then x=x+dimx = x + dim, and afterwards the value is truncated to the [0,dim][0, dim] interval.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
var Input Target tensor for slice assignment. FLOAT16, FLOAT, BFLOAT16, INT32, INT16 ND
begin Input Start index of the slice position. This parameter is a 1D constant tensor whose length is the number of dimensions of var. INT64 ND
end Input End index of the slice position. This parameter is a 1D constant tensor whose length is the number of dimensions of var. INT64 ND
strides Input Step of the slice. This parameter is a 1D constant tensor whose length is the number of dimensions of var. INT64 ND
input_value Input Tensor that replaces the slice content. Its dtype must be the same as that of var, and its shape must strictly equal the computed slice shape. FLOAT16, FLOAT, BFLOAT16, INT32, INT16 ND
var Output Result tensor after slice assignment. It has the same name as the input var, and its shape and dtype are the same as those of the input var. FLOAT16, FLOAT, BFLOAT16, INT32, INT16 ND
begin_mask Attribute int type. If the i-th bit is 1, begin[i] is ignored, and the start index takes the start point 0 of the interval. The default value is 0. - -
end_mask Attribute int type. If the i-th bit is 1, end[i] is ignored, and the end index takes the end point dim of the interval. The default value is 0. - -
ellipsis_mask Attribute int type. At most one bit can be 1, indicating that the bit is expanded into a slice of full dimensions. The default value is 0. - -
new_axis_mask Attribute int type. If the i-th bit is 1, a new dimension of length 1 is inserted at this position. The default value is 0. - -
shrink_axis_mask Attribute int type. If the i-th bit is 1, end[i]=begin[i]+1 is forced and the stride is 1, shrinking this dimension. The default value is 0. - -

Constraint Description

  • begin, end, and strides are value-dependent inputs, and their concrete values must be obtainable on the host side.
  • The input var supports 1D to 8D, and the lengths of begin, end, and strides must equal the number of dimensions of var.
  • strides[i] must be greater than 0, and the stride of the innermost dimension must be 1.
  • The dtype of input_value must be the same as that of var, and its shape must strictly equal the final shape after slice computation. Broadcasting is not supported.
  • The output var and the input var are in-place semantics, and the output shape equals the shape of the input var.
  • This operator is a pure data movement operator. The result is bit-exact, with no precision loss.

Invocation Description

Invocation Method Invocation Sample Description
Graph-mode invocation test_geir_strided_slice_assign For operator compilation and verification, refer to Operator Invocation.