SequenceLength#

  • Domain: ai.onnx

  • Since version: 11

Produces a scalar(tensor of empty shape) containing the number of tensors in ‘input_sequence’.

Inputs

  • input_sequence (S): Input sequence.

Outputs

  • length (I): Length of input sequence. It must be a scalar(tensor of empty shape).

Type Constraints

  • S: Constrain to any tensor type. Allowed types: seq(tensor(bool)), seq(tensor(complex128)), seq(tensor(complex64)), seq(tensor(double)), seq(tensor(float)), seq(tensor(float16)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(int8)), seq(tensor(string)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(uint8)).

  • I: Constrain output to integral tensor. It must be a scalar(tensor of empty shape). Allowed types: tensor(int64).

Examples#

test_cc_sequence_empty_default

Node:
  SequenceLength(empty_seq) -> (length)
Inputs:

Outputs:
  length: shape=(), dtype=int64
    0

test_cc_sequence_empty_int64

Node:
  SequenceLength(empty_seq) -> (length)
Inputs:

Outputs:
  length: shape=(), dtype=int64
    0

test_cc_sequence_length

Node:
  SequenceLength(input_seq) -> (length)
Inputs:
  input_seq: shape=(2, 3), dtype=float32
    [[-1.  ,  0.  ,  1.5 ],
     [-2.25,  3.5 , -4.75]]
  input_1: shape=(2, 3), dtype=float32
    [[0., 1., 2.],
     [3., 4., 5.]]
  input_2: shape=(2, 3), dtype=float32
    [[ 6.,  7.,  8.],
     [ 9., 10., 11.]]

Outputs:
  length: shape=(), dtype=int64
    3