:nosearch: .. _op_ai_onnx_OptionalHasElement-18: OptionalHasElement - version 18 =============================== This page documents version **18** of operator **OptionalHasElement**. See :doc:`OptionalHasElement` for the latest version (since version 28). - **Domain**: ``ai.onnx`` - **Since version**: 18 Returns true if (1) the input is an optional-type and contains an element, or, (2) the input is a tensor or sequence type. If the input is not provided or is an empty optional-type, this op returns false. **Inputs** - **input** (*O*): The optional input. **Outputs** - **output** (*B*): A scalar boolean tensor. If true, it indicates that optional-type input contains an element. Otherwise, it is empty. **Type Constraints** - **O**: Constrain input type to optional, tensor and sequence types. Allowed types: optional(seq(tensor(bool))), optional(seq(tensor(complex128))), optional(seq(tensor(complex64))), optional(seq(tensor(double))), optional(seq(tensor(float))), optional(seq(tensor(float16))), optional(seq(tensor(int16))), optional(seq(tensor(int32))), optional(seq(tensor(int64))), optional(seq(tensor(int8))), optional(seq(tensor(string))), optional(seq(tensor(uint16))), optional(seq(tensor(uint32))), optional(seq(tensor(uint64))), optional(seq(tensor(uint8))), optional(tensor(bool)), optional(tensor(complex128)), optional(tensor(complex64)), optional(tensor(double)), optional(tensor(float)), optional(tensor(float16)), optional(tensor(int16)), optional(tensor(int32)), optional(tensor(int64)), optional(tensor(int8)), optional(tensor(string)), optional(tensor(uint16)), optional(tensor(uint32)), optional(tensor(uint64)), optional(tensor(uint8)), 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)), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8). - **B**: Constrain output to a boolean tensor. Allowed types: tensor(bool). Examples -------- **test_cc_optional_has_element_empty_no_input_name_optional_input** .. code-block:: text Node: OptionalHasElement("") -> (output) .. code-block:: text Inputs: Outputs: output: shape=(), dtype=bool False **test_cc_optional_has_element_empty_no_input_name_tensor_input** .. code-block:: text Node: OptionalHasElement("") -> (output) .. code-block:: text Inputs: Outputs: output: shape=(), dtype=bool False **test_cc_optional_has_element_empty_no_input_optional_input** .. code-block:: text Node: OptionalHasElement() -> (output) .. code-block:: text Inputs: Outputs: output: shape=(), dtype=bool False **test_cc_optional_has_element_empty_no_input_tensor_input** .. code-block:: text Node: OptionalHasElement() -> (output) .. code-block:: text Inputs: Outputs: output: shape=(), dtype=bool False **test_cc_optional_has_element_empty_optional_input** .. code-block:: text Node: OptionalHasElement() -> (output) .. code-block:: text Inputs: Outputs: output: shape=(), dtype=bool False **test_cc_optional_has_element_tensor_input** .. code-block:: text Node: OptionalHasElement(input) -> (output) .. code-block:: text Inputs: input: shape=(2, 3), dtype=float32 [[-1. , 0. , 1.5 ], [-2.25, 3.5 , -4.75]] Outputs: output: shape=(), dtype=bool True Differences with previous version (15) -------------------------------------- **SchemaDiff**: ``OptionalHasElement`` (domain ``'ai.onnx'``) * old version: 15 * new version: 18 * breaking: no **Type constraints:** * changed 'O': added 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))', 'tensor(bool)', 'tensor(complex128)', 'tensor(complex64)', 'tensor(double)', 'tensor(float)', 'tensor(float16)', 'tensor(int16)', 'tensor(int32)', 'tensor(int64)', 'tensor(int8)', 'tensor(string)', 'tensor(uint16)', 'tensor(uint32)', 'tensor(uint64)', 'tensor(uint8)'] **Documentation:** * line similarity: 0.33 (+3/-1 lines) .. code-block:: diff --- OptionalHasElement v15 +++ OptionalHasElement v18 @@ -1,2 +1,4 @@ -Returns true if the optional-type input contains an element. If it is an empty optional-type, this op returns false. +Returns true if (1) the input is an optional-type and contains an element, +or, (2) the input is a tensor or sequence type. +If the input is not provided or is an empty optional-type, this op returns false.