SetValueOperation
Description
Copies the content of the input source tensor to the specified location of the input target tensor.
Operator Context

Operator Function Implementation
The copy is an in-place copy, and the final result is modified in the input target tensor.
For example, the input target tensor is dst: (a, b, c), and the input source tensor is src: (d, e, f).
dst[starts[0]: ends[0], starts[1]: ends[1], starts[2]: ends[2]] = src
The length of starts[0]: ends[0] is the size of dimension 0 of src. The length of starts[1]: ends[1] is the size of dimension 1 of src. The length of starts[2]: ends[2] is the size of dimension 2 of src.
Definition
struct SetValueParam {
SVector<int64_t> starts;
SVector<int64_t> ends;
SVector<int64_t> strides;
uint8_t rsv[8] = {0};
};
Members
Member |
Type |
Default Value |
Description |
|---|---|---|---|
starts |
SVector<int64_t> |
- |
Start position for copying each dimension. |
ends |
SVector<int64_t> |
- |
One position after the end position of each dimension copy. The copy ends at the previous position of this position. |
strides |
SVector<int64_t> |
- |
Copy step of each dimension. Currently, strides can only be all 1s. |
rsv[8] |
uint8_t |
{0} |
Reserved |
Input
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
src |
[-1,...,-1] The value -1 indicates that the size of the current dimension is not restricted. |
float16/float/int32/int64 |
ND |
Input tensor 1 |
dst |
[-1,...,-1] The value -1 indicates that the size of the current dimension is not restricted. |
float16/float/int32/int64 |
ND |
Input tensor 2 |
Output
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
dst |
[-1,...,-1] The value -1 indicates that the size of the current dimension is not restricted. |
float16/float/int32/int64 |
ND |
Output tensor. Note: The output dst points to the same address as the input with the same name, that is, in-place modification is performed. |
Restrictions
- The number of dimensions of input src must be the same as that of input dst.
- The size of each dimension of input src must be less than or equal to that of the corresponding dimension of input dst.
- One or two dimensions of input src and input dst must be different and meet the following requirements:
- If one dimension is different, this dimension cannot be the highest dimension (dimension 0).
- If two dimensions are different, one of the different dimensions must be the highest dimension (dimension 0).
API Calling Example
Input
starts = {1,3}
ends = {3,6}
strides = {1,1}
dst=[[13, 14, 17, 14, 17, 1, 15, 8, 11, 14, 5, 16, 16, 2, 16, 8],
[17, 4, 0, 7, 15, 1, 8, 15, 2, 11, 10, 1, 19, 15, 3, 2],
[11, 13, 2, 5, 0, 4, 0, 9, 9, 12, 12, 3, 8, 16, 3, 12],
[ 0, 11, 8, 5, 6, 6, 7, 3, 11, 11, 0, 7, 13, 4, 19, 2],
[ 9, 3, 6, 19, 19, 15, 13, 1, 14, 6, 1, 1, 0, 8, 18, 2],
[18, 16, 3, 1, 6, 0, 0, 10, 4, 2, 14, 13, 16, 19, 12, 18],
[10, 2, 9, 9, 8, 19, 2, 18, 12, 19, 10, 5, 2, 7, 3, 9]]
src=[[ 0, 1, 9],
[19, 8, 2]]
Output
dst=[[13, 14, 17, 14, 17, 1, 15, 8, 11, 14, 5, 16, 16, 2, 16, 8],
[17, 4, 0, 0, 1, 9, 8, 15, 2, 11, 10, 1, 19, 15, 3, 2],
[11, 13, 2, 19, 8, 2, 0, 9, 9, 12, 12, 3, 8, 16, 3, 12],
[ 0, 11, 8, 5, 6, 6, 7, 3, 11, 11, 0, 7, 13, 4, 19, 2],
[ 9, 3, 6, 19, 19, 15, 13, 1, 14, 6, 1, 1, 0, 8, 18, 2],
[18, 16, 3, 1, 6, 0, 0, 10, 4, 2, 14, 13, 16, 19, 12, 18],
[10, 2, 9, 9, 8, 19, 2, 18, 12, 19, 10, 5, 2, 7, 3, 9]]