Skip to content

Commit d7595f3

Browse files
BowenBaowschin
authored andcommitted
Sequence related ops (#2249)
* sequence related ops * refine docs * extend hasInputShape to Sequence * refining naming and error checking * refine descriptions
1 parent 599f3da commit d7595f3

File tree

46 files changed

+2095
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2095
-19
lines changed

docs/Changelog.md

Lines changed: 306 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10497,7 +10497,7 @@ This version of the operator has been available since version 11 of the default
1049710497

1049810498
### <a name="Concat-11"></a>**Concat-11**</a>
1049910499

10500-
Concatenate a list of tensors into a single tensor
10500+
Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on.
1050110501

1050210502
#### Version
1050310503

@@ -10531,6 +10531,49 @@ This version of the operator has been available since version 11 of the default
1053110531
<dd>Constrain output types to any tensor type.</dd>
1053210532
</dl>
1053310533

10534+
### <a name="ConcatFromSequence-11"></a>**ConcatFromSequence-11**</a>
10535+
10536+
Concatenate a sequence of tensors into a single tensor.
10537+
All input tensors must have the same shape, except for the dimension size of the axis to concatenate on.
10538+
By default 'new_axis' is 0, the behavior is similar to numpy.concatenate.
10539+
When 'new_axis' is 1, the behavior is similar to numpy.stack.
10540+
10541+
#### Version
10542+
10543+
This version of the operator has been available since version 11 of the default ONNX operator set.
10544+
10545+
#### Attributes
10546+
10547+
<dl>
10548+
<dt><tt>axis</tt> : int (required)</dt>
10549+
<dd>Which axis to concat on. Accepted range in `[-r, r - 1]`, where `r` is the rank of input tensors. When `new_axis` is 1, accepted range is `[-r - 1, r]`. </dd>
10550+
<dt><tt>new_axis</tt> : int (default is 0)</dt>
10551+
<dd>Insert and concatenate on a new axis or not, default 0 means do not insert new axis.</dd>
10552+
</dl>
10553+
10554+
#### Inputs
10555+
10556+
<dl>
10557+
<dt><tt>input_sequence</tt> : S</dt>
10558+
<dd>Sequence of tensors for concatenation</dd>
10559+
</dl>
10560+
10561+
#### Outputs
10562+
10563+
<dl>
10564+
<dt><tt>concat_result</tt> : T</dt>
10565+
<dd>Concatenated tensor</dd>
10566+
</dl>
10567+
10568+
#### Type Constraints
10569+
10570+
<dl>
10571+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
10572+
<dd>Constrain input types to any tensor type.</dd>
10573+
<dt><tt>T</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)</dt>
10574+
<dd>Constrain output types to any tensor type.</dd>
10575+
</dl>
10576+
1053410577
### <a name="Constant-11"></a>**Constant-11**</a>
1053510578

1053610579
A constant tensor. Exactly one of the two attributes, either value or sparse_value,
@@ -12479,6 +12522,215 @@ This version of the operator has been available since version 11 of the default
1247912522
<dd>Constrain input and output types to any tensor type.</dd>
1248012523
</dl>
1248112524

12525+
### <a name="SequenceAt-11"></a>**SequenceAt-11**</a>
12526+
12527+
Outputs a tensor copy from the tensor at 'position' in 'input_sequence'.
12528+
Accepted range for 'position' is in `[-n, n - 1]`, where `n` is the number of tensors in 'input_sequence'.
12529+
Negative value means counting positions from the back.
12530+
12531+
#### Version
12532+
12533+
This version of the operator has been available since version 11 of the default ONNX operator set.
12534+
12535+
#### Inputs
12536+
12537+
<dl>
12538+
<dt><tt>input_sequence</tt> : S</dt>
12539+
<dd>Input sequence.</dd>
12540+
<dt><tt>position</tt> : I</dt>
12541+
<dd>Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in `[-n, n - 1]`, where `n` is the number of tensors in 'input_sequence'. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).</dd>
12542+
</dl>
12543+
12544+
#### Outputs
12545+
12546+
<dl>
12547+
<dt><tt>tensor</tt> : T</dt>
12548+
<dd>Output tensor at the specified position in the input sequence.</dd>
12549+
</dl>
12550+
12551+
#### Type Constraints
12552+
12553+
<dl>
12554+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12555+
<dd>Constrain to any tensor type.</dd>
12556+
<dt><tt>T</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)</dt>
12557+
<dd>Constrain to any tensor type.</dd>
12558+
<dt><tt>I</tt> : tensor(int32), tensor(int64)</dt>
12559+
<dd>Constrain position to integral tensor. It must be a scalar(tensor of empty shape).</dd>
12560+
</dl>
12561+
12562+
### <a name="SequenceConstruct-11"></a>**SequenceConstruct-11**</a>
12563+
12564+
Construct a tensor sequence containing 'inputs' tensors.
12565+
All tensors in 'inputs' must have the same data type.
12566+
12567+
#### Version
12568+
12569+
This version of the operator has been available since version 11 of the default ONNX operator set.
12570+
12571+
#### Inputs (1 - &#8734;)
12572+
12573+
<dl>
12574+
<dt><tt>inputs</tt> (variadic) : T</dt>
12575+
<dd>Tensors.</dd>
12576+
</dl>
12577+
12578+
#### Outputs
12579+
12580+
<dl>
12581+
<dt><tt>output_sequence</tt> : S</dt>
12582+
<dd>Sequence enclosing the input tensors.</dd>
12583+
</dl>
12584+
12585+
#### Type Constraints
12586+
12587+
<dl>
12588+
<dt><tt>T</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)</dt>
12589+
<dd>Constrain input types to any tensor type.</dd>
12590+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12591+
<dd>Constrain output types to any tensor type.</dd>
12592+
</dl>
12593+
12594+
### <a name="SequenceEmpty-11"></a>**SequenceEmpty-11**</a>
12595+
12596+
Construct an empty tensor sequence, with given data type.
12597+
12598+
#### Version
12599+
12600+
This version of the operator has been available since version 11 of the default ONNX operator set.
12601+
12602+
#### Attributes
12603+
12604+
<dl>
12605+
<dt><tt>dtype</tt> : int</dt>
12606+
<dd>(Optional) The data type of the tensors in the output sequence. The default type is 'float'.</dd>
12607+
</dl>
12608+
12609+
#### Inputs
12610+
12611+
12612+
#### Outputs
12613+
12614+
<dl>
12615+
<dt><tt>output</tt> : S</dt>
12616+
<dd>Empty sequence.</dd>
12617+
</dl>
12618+
12619+
#### Type Constraints
12620+
12621+
<dl>
12622+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12623+
<dd>Constrain output types to any tensor type.</dd>
12624+
</dl>
12625+
12626+
### <a name="SequenceErase-11"></a>**SequenceErase-11**</a>
12627+
12628+
Outputs a tensor sequence that removes the tensor at 'position' from 'input_sequence'.
12629+
Accepted range for 'position' is in `[-n, n - 1]`, where `n` is the number of tensors in 'input_sequence'.
12630+
Negative value means counting positions from the back.
12631+
'position' is optional, by default it erases the last tensor from 'input_sequence'.
12632+
12633+
#### Version
12634+
12635+
This version of the operator has been available since version 11 of the default ONNX operator set.
12636+
12637+
#### Inputs (1 - 2)
12638+
12639+
<dl>
12640+
<dt><tt>input_sequence</tt> : S</dt>
12641+
<dd>Input sequence.</dd>
12642+
<dt><tt>position</tt> (optional) : I</dt>
12643+
<dd>Position of the tensor in the sequence. Negative value means counting positions from the back. Accepted range in `[-n, n - 1]`, where `n` is the number of tensors in 'input_sequence'. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).</dd>
12644+
</dl>
12645+
12646+
#### Outputs
12647+
12648+
<dl>
12649+
<dt><tt>output_sequence</tt> : S</dt>
12650+
<dd>Output sequence that has the tensor at the specified position removed.</dd>
12651+
</dl>
12652+
12653+
#### Type Constraints
12654+
12655+
<dl>
12656+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12657+
<dd>Constrain to any tensor type.</dd>
12658+
<dt><tt>I</tt> : tensor(int32), tensor(int64)</dt>
12659+
<dd>Constrain position to integral tensor. It must be a scalar(tensor of empty shape).</dd>
12660+
</dl>
12661+
12662+
### <a name="SequenceInsert-11"></a>**SequenceInsert-11**</a>
12663+
12664+
Outputs a tensor sequence that inserts 'tensor' into 'input_sequence' at 'position'.
12665+
'tensor' must have the same data type as 'input_sequence'.
12666+
Accepted range for 'position' is in `[-n, n]`, where `n` is the number of tensors in 'input_sequence'.
12667+
Negative value means counting positions from the back.
12668+
'position' is optional, by default it inserts 'tensor' to the back of 'input_sequence'.
12669+
12670+
#### Version
12671+
12672+
This version of the operator has been available since version 11 of the default ONNX operator set.
12673+
12674+
#### Inputs (2 - 3)
12675+
12676+
<dl>
12677+
<dt><tt>input_sequence</tt> : S</dt>
12678+
<dd>Input sequence.</dd>
12679+
<dt><tt>tensor</tt> : T</dt>
12680+
<dd>Input tensor to be inserted into the input sequence.</dd>
12681+
<dt><tt>position</tt> (optional) : I</dt>
12682+
<dd>Position in the sequence where the new tensor is inserted. It is optional and default is to insert to the back of the sequence. Negative value means counting positions from the back. Accepted range in `[-n, n]`, where `n` is the number of tensors in 'input_sequence'. It is an error if any of the index values are out of bounds. It must be a scalar(tensor of empty shape).</dd>
12683+
</dl>
12684+
12685+
#### Outputs
12686+
12687+
<dl>
12688+
<dt><tt>output_sequence</tt> : S</dt>
12689+
<dd>Output sequence that contains the inserted tensor at given position.</dd>
12690+
</dl>
12691+
12692+
#### Type Constraints
12693+
12694+
<dl>
12695+
<dt><tt>T</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)</dt>
12696+
<dd>Constrain to any tensor type.</dd>
12697+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12698+
<dd>Constrain to any tensor type.</dd>
12699+
<dt><tt>I</tt> : tensor(int32), tensor(int64)</dt>
12700+
<dd>Constrain position to integral tensor. It must be a scalar(tensor of empty shape).</dd>
12701+
</dl>
12702+
12703+
### <a name="SequenceLength-11"></a>**SequenceLength-11**</a>
12704+
12705+
Produces a scalar(tensor of empty shape) containing the number of tensors in 'input_sequence'.
12706+
12707+
#### Version
12708+
12709+
This version of the operator has been available since version 11 of the default ONNX operator set.
12710+
12711+
#### Inputs
12712+
12713+
<dl>
12714+
<dt><tt>input_sequence</tt> : S</dt>
12715+
<dd>Input sequence.</dd>
12716+
</dl>
12717+
12718+
#### Outputs
12719+
12720+
<dl>
12721+
<dt><tt>length</tt> : I</dt>
12722+
<dd>Length of input sequence. It must be a scalar(tensor of empty shape).</dd>
12723+
</dl>
12724+
12725+
#### Type Constraints
12726+
12727+
<dl>
12728+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12729+
<dd>Constrain to any tensor type.</dd>
12730+
<dt><tt>I</tt> : tensor(int64)</dt>
12731+
<dd>Constrain output to integral tensor. It must be a scalar(tensor of empty shape).</dd>
12732+
</dl>
12733+
1248212734
### <a name="Slice-11"></a>**Slice-11**</a>
1248312735

1248412736
Produces a slice of the input tensor along multiple axes. Similar to numpy:
@@ -12641,6 +12893,59 @@ This version of the operator has been available since version 11 of the default
1264112893
<dd>Constrain input and output types to all tensor types.</dd>
1264212894
</dl>
1264312895

12896+
### <a name="SplitToSequence-11"></a>**SplitToSequence-11**</a>
12897+
12898+
Split a tensor into a sequence of tensors, along the specified
12899+
'axis'. Lengths of the parts can be specified using argument 'split'.
12900+
'split' must contain only positive numbers.
12901+
'split' is either a scalar (tensor of empty shape), or a 1-D tensor.
12902+
If 'split' is a scalar, then 'input' will be split into equally sized chunks(if possible).
12903+
Last chunk will be smaller if the 'input' size along the given axis 'axis' is not divisible
12904+
by 'split'.
12905+
Otherwise, the tensor is split into 'size(split)' chunks, with lengths of the parts on 'axis'
12906+
specified in 'split'. In this scenario, the sum of entries in 'split' must be equal to the
12907+
dimension size of input tensor on 'axis'.
12908+
12909+
#### Version
12910+
12911+
This version of the operator has been available since version 11 of the default ONNX operator set.
12912+
12913+
#### Attributes
12914+
12915+
<dl>
12916+
<dt><tt>axis</tt> : int (default is 0)</dt>
12917+
<dd>Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1].</dd>
12918+
<dt><tt>keepdims</tt> : int (default is 1)</dt>
12919+
<dd>Keep the split dimension or not. Default 1, which means we keep split dimension. If input 'split' is specified, this attribute is ignored.</dd>
12920+
</dl>
12921+
12922+
#### Inputs (1 - 2)
12923+
12924+
<dl>
12925+
<dt><tt>input</tt> : T</dt>
12926+
<dd>The tensor to split</dd>
12927+
<dt><tt>split</tt> (optional) : I</dt>
12928+
<dd>Length of each output. It can be either a scalar(tensor of empty shape), or a 1-D tensor. All values must be positive. </dd>
12929+
</dl>
12930+
12931+
#### Outputs
12932+
12933+
<dl>
12934+
<dt><tt>output_sequence</tt> : S</dt>
12935+
<dd>One or more outputs forming a sequence of tensors after splitting</dd>
12936+
</dl>
12937+
12938+
#### Type Constraints
12939+
12940+
<dl>
12941+
<dt><tt>T</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)</dt>
12942+
<dd>Constrain input types to all tensor types.</dd>
12943+
<dt><tt>I</tt> : tensor(int32), tensor(int64)</dt>
12944+
<dd>Constrain split size to integral tensor.</dd>
12945+
<dt><tt>S</tt> : seq(tensor(uint8)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(int8)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(float16)), seq(tensor(float)), seq(tensor(double)), seq(tensor(string)), seq(tensor(bool)), seq(tensor(complex64)), seq(tensor(complex128))</dt>
12946+
<dd>Constrain output types to all tensor types.</dd>
12947+
</dl>
12948+
1264412949
### <a name="Squeeze-11"></a>**Squeeze-11**</a>
1264512950

1264612951
Remove single-dimensional entries from the shape of a tensor.

0 commit comments

Comments
 (0)