From 7a2ac27f09303a665d758772e405c31cb66ba3eb Mon Sep 17 00:00:00 2001 From: Mateusz Mikolajczyk Date: Fri, 22 Sep 2023 13:14:46 +0200 Subject: [PATCH] [Spec][Opset13] BitwiseAnd-13, BitwiseNot-13, BitwiseOr-13, BitwiseXor-13 specifications (#19798) * [Spec] BitwiseNot-13 specification * Improvements * add other specifications * Doc improvements * Fix typos * add opset13 * Fix typo * add opset13 * Fix * Improve example? * Fix step formatting * Apply suggestions from code review Co-authored-by: Katarzyna Mitrus * Add suggested changes * Fix missing the --------- Co-authored-by: Katarzyna Mitrus --- .../Operations_specifications.md | 4 + docs/ops/bitwise/BitwiseAnd_13.md | 138 ++++++++++++++++++ docs/ops/bitwise/BitwiseNot_13.md | 83 +++++++++++ docs/ops/bitwise/BitwiseOr_13.md | 138 ++++++++++++++++++ docs/ops/bitwise/BitwiseXor_13.md | 138 ++++++++++++++++++ docs/ops/opset13.md | 4 + 6 files changed, 505 insertions(+) create mode 100644 docs/ops/bitwise/BitwiseAnd_13.md create mode 100644 docs/ops/bitwise/BitwiseNot_13.md create mode 100644 docs/ops/bitwise/BitwiseOr_13.md create mode 100644 docs/ops/bitwise/BitwiseXor_13.md diff --git a/docs/OV_Runtime_UG/Operations_specifications.md b/docs/OV_Runtime_UG/Operations_specifications.md index c9d063b3881..000b3e89525 100644 --- a/docs/OV_Runtime_UG/Operations_specifications.md +++ b/docs/OV_Runtime_UG/Operations_specifications.md @@ -24,6 +24,10 @@ BatchNormInference-5 BatchToSpace-2 BinaryConvolution-1 + BitwiseAnd-13 + BitwiseNot-13 + BitwiseOr-13 + BitwiseXor-13 Broadcast-1 Broadcast-3 Bucketize-3 diff --git a/docs/ops/bitwise/BitwiseAnd_13.md b/docs/ops/bitwise/BitwiseAnd_13.md new file mode 100644 index 00000000000..7ca942281f8 --- /dev/null +++ b/docs/ops/bitwise/BitwiseAnd_13.md @@ -0,0 +1,138 @@ +# BitwiseAnd {#openvino_docs_ops_bitwise_BitwiseAnd_13} + +@sphinxdirective + +.. meta:: + :description: Learn about BitwiseAnd-13 - an element-wise, bitwise AND operation, which can be performed on two required input tensors. + +**Versioned name**: *BitwiseAnd-13* + +**Category**: *Bitwise binary* + +**Short description**: *BitwiseAnd* performs a bitwise logical AND operation with two given tensors element-wise, applying multi-directional broadcast rules. + +**Detailed description**: Before performing the operation, input tensors *a* and *b* are broadcasted if their shapes are different and the ``auto_broadcast`` attribute is not ``none``. Broadcasting is performed according to the ``auto_broadcast`` value. + +After broadcasting input tensors *a* and *b*, *BitwiseAnd* performs a bitwise logical AND operation for each corresponding element in the given tensors, based on the following algorithm. + +For ``boolean`` type tensors, BitwiseAnd is equivalent to :doc:`LogicalAnd `. + +If tensor is of ``any supported integer`` type, for each element of the tensor: + +1. Convert values from input tensors to their binary representation according to the input tensor datatype. +2. Perform a logical AND on each bit in the binary representation of values from *a* and *b*, where value ``0`` represents ``false`` and value ``1`` represents ``true``. +3. Convert the results of AND in binary representation to the input datatype. + +Example 1 - *BitwiseAnd* output for boolean tensor: + +.. code-block:: py + :force: + + # For given boolean inputs: + a = [True, False, False] + b = [True, True, False] + # Perform logical AND operation same as in LogicalAnd operator: + output = [True, False, False] + +Example 2 - *BitwiseAnd* output for uint8 tensor: + +.. code-block:: py + :force: + + # For given uint8 inputs: + a = [21, 120] + b = [3, 37] + # Create a binary representation of uint8: + # binary a: [00010101, 01111000] + # binary b: [00000011, 00100101] + # Perform bitwise AND of corresponding elements in a and b: + # [00000001, 00100000] + # Convert binary values to uint8: + output = [1, 32] + +**Attributes**: + +* *auto_broadcast* + + * **Description**: specifies the rules used for auto-broadcasting of input tensors. + * **Range of values**: + + * *none* - no auto-broadcasting is allowed, all input shapes must match, + * *numpy* - numpy broadcasting rules, description is available in :doc:`Broadcast Rules For Elementwise Operations `, + * *pdpd* - PaddlePaddle-style implicit broadcasting, description is available in :doc:`Broadcast Rules For Elementwise Operations `. + + * **Type**: string + * **Default value**: "numpy" + * **Required**: *no* + +**Inputs** + +* **1**: A tensor of type *T* and arbitrary shape. **Required.** +* **2**: A tensor of type *T* and arbitrary shape. **Required.** + +**Outputs** + +* **1**: The result of element-wise *BitwiseAnd* operation. A tensor of type *T* and the same shape equal to the broadcasted shape of two inputs. + +**Types** + +* *T*: ``any supported integer or boolean type``. + +**Examples** + +*Example 1: no broadcast* + +.. code-block:: xml + :force: + + + + + 256 + 56 + + + 256 + 56 + + + + + 256 + 56 + + + + + +*Example 2: numpy broadcast* + +.. code-block:: xml + :force: + + + + + 8 + 1 + 6 + 1 + + + 7 + 1 + 5 + + + + + 8 + 7 + 6 + 5 + + + + + +@endsphinxdirective diff --git a/docs/ops/bitwise/BitwiseNot_13.md b/docs/ops/bitwise/BitwiseNot_13.md new file mode 100644 index 00000000000..1f54f1da4d7 --- /dev/null +++ b/docs/ops/bitwise/BitwiseNot_13.md @@ -0,0 +1,83 @@ +# BitwiseNot {#openvino_docs_ops_bitwise_BitwiseNot_13} + +@sphinxdirective + +.. meta:: + :description: Learn about BitwiseNot-13 - an element-wise, bitwise negation operation, which can be performed on a single input tensor. + +**Versioned name**: *BitwiseNot-13* + +**Category**: *Bitwise unary* + +**Short description**: *BitwiseNot* performs a bitwise logical negation operation with given tensor element-wise. + +**Detailed description**: *BitwiseNot* performs a bitwise logical negation operation for each element in the given tensor, based on the following algorithm. + +For ``boolean`` type tensors, BitwiseNot is equivalent to :doc:`LogicalNot `. + +If tensor is of ``any supported integer`` type, for each element of the tensor: + +1. Convert the value from the input tensor to binary representation according to the input tensor datatype. +2. Perform a logical negation on each bit in the binary representation, where value ``0`` represents ``false`` and value ``1`` represents ``true``. +3. Convert back the binary representation to the input datatype. + +Example 1 - *BitwiseNot* output for boolean tensor: + +.. code-block:: py + :force: + + # For given boolean input: + input = [True, False] + # Perform logical negation operation same as in LogicalNot operator: + output = [False, True] + +Example 2 - *BitwiseNot* output for uint8 tensor: + +.. code-block:: py + :force: + + # For given uint8 input: + input = [1, 3] + # Create a binary representation of uint8: + # [00000001, 00000011] + # Perform bitwise negation: + # [11111110, 11111100] + # Convert back binary values to uint8: + output = [254, 252] + +**Attributes**: *BitwiseNot* operation has no attributes. + +**Inputs** + +* **1**: A tensor of type *T* and arbitrary shape. **Required.** + +**Outputs** + +* **1**: The result of bitwise logical negation operation. A tensor of type *T* and the same shape as the input tensor. + +**Types** + +* *T*: ``any supported integer or boolean type``. + +**Example** + +.. code-block:: xml + :force: + + + + + 256 + 56 + + + + + 256 + 56 + + + + + +@endsphinxdirective diff --git a/docs/ops/bitwise/BitwiseOr_13.md b/docs/ops/bitwise/BitwiseOr_13.md new file mode 100644 index 00000000000..59b3bc3195a --- /dev/null +++ b/docs/ops/bitwise/BitwiseOr_13.md @@ -0,0 +1,138 @@ +# BitwiseOr {#openvino_docs_ops_bitwise_BitwiseOr_13} + +@sphinxdirective + +.. meta:: + :description: Learn about BitwiseOr-13 - an element-wise, bitwise OR operation, which can be performed on two required input tensors. + +**Versioned name**: *BitwiseOr-13* + +**Category**: *Bitwise binary* + +**Short description**: *BitwiseOr* performs a bitwise logical OR operation with two given tensors element-wise, applying multi-directional broadcast rules. + +**Detailed description**: Before performing the operation, input tensors *a* and *b* are broadcasted if their shapes are different and the ``auto_broadcast`` attribute is not ``none``. Broadcasting is performed according to the ``auto_broadcast`` value. + +After broadcasting input tensors *a* and *b*, *BitwiseOr* performs a bitwise logical OR operation for each corresponding element in the given tensors, based on the following algorithm. + +For ``boolean`` type tensors, BitwiseOr is equivalent to :doc:`LogicalOr `. + +If tensor is of ``any supported integer`` type, for each element of the tensor: + +1. Convert values from input tensors to their binary representation according to the input tensor datatype. +2. Perform a logical OR on each bit in the binary representation of values from *a* and *b*, where value ``0`` represents ``false`` and value ``1`` represents ``true``. +3. Convert the results of OR in binary representation to the input datatype. + +Example 1 - *BitwiseOr* output for boolean tensor: + +.. code-block:: py + :force: + + # For given boolean inputs: + a = [True, False, False] + b = [True, True, False] + # Perform logical OR operation same as in LogicalOr operator: + output = [True, True, False] + +Example 2 - *BitwiseOr* output for uint8 tensor: + +.. code-block:: py + :force: + + # For given uint8 inputs: + a = [21, 120] + b = [3, 37] + # Create a binary representation of uint8: + # binary a: [00010101, 01111000] + # binary b: [00000011, 00100101] + # Perform bitwise OR of corresponding elements in a and b: + # [00010111, 01111101] + # Convert binary values to uint8: + output = [23, 125] + +**Attributes**: + +* *auto_broadcast* + + * **Description**: specifies the rules used for auto-broadcasting of input tensors. + * **Range of values**: + + * *none* - no auto-broadcasting is allowed, all input shapes must match, + * *numpy* - numpy broadcasting rules, description is available in :doc:`Broadcast Rules For Elementwise Operations `, + * *pdpd* - PaddlePaddle-style implicit broadcasting, description is available in :doc:`Broadcast Rules For Elementwise Operations `. + + * **Type**: string + * **Default value**: "numpy" + * **Required**: *no* + +**Inputs** + +* **1**: A tensor of type *T* and arbitrary shape. **Required.** +* **2**: A tensor of type *T* and arbitrary shape. **Required.** + +**Outputs** + +* **1**: The result of element-wise *BitwiseOr* operation. A tensor of type *T* and the same shape equal to the broadcasted shape of two inputs. + +**Types** + +* *T*: ``any supported integer or boolean type``. + +**Examples** + +*Example 1: no broadcast* + +.. code-block:: xml + :force: + + + + + 256 + 56 + + + 256 + 56 + + + + + 256 + 56 + + + + + +*Example 2: numpy broadcast* + +.. code-block:: xml + :force: + + + + + 8 + 1 + 6 + 1 + + + 7 + 1 + 5 + + + + + 8 + 7 + 6 + 5 + + + + + +@endsphinxdirective diff --git a/docs/ops/bitwise/BitwiseXor_13.md b/docs/ops/bitwise/BitwiseXor_13.md new file mode 100644 index 00000000000..31287854f46 --- /dev/null +++ b/docs/ops/bitwise/BitwiseXor_13.md @@ -0,0 +1,138 @@ +# BitwiseXor {#openvino_docs_ops_bitwise_BitwiseXor_13} + +@sphinxdirective + +.. meta:: + :description: Learn about BitwiseXor-13 - an element-wise, bitwise XOR operation, which can be performed on two required input tensors. + +**Versioned name**: *BitwiseXor-13* + +**Category**: *Bitwise binary* + +**Short description**: *BitwiseXor* performs a bitwise logical XOR operation with two given tensors element-wise, applying multi-directional broadcast rules. + +**Detailed description**: Before performing the operation, input tensors *a* and *b* are broadcasted if their shapes are different and the ``auto_broadcast`` attribute is not ``none``. Broadcasting is performed according to the ``auto_broadcast`` value. + +After broadcasting input tensors *a* and *b*, *BitwiseXor* performs a bitwise logical XOR operation for each corresponding element in the given tensors, based on the following algorithm. + +For ``boolean`` type tensors, BitwiseXor is equivalent to :doc:`LogicalXor `. + +If tensor is of ``any supported integer`` type, for each element of the tensor: + +1. Convert values from input tensors to their binary representation according to the input tensor datatype. +2. Perform a logical XOR on each bit in the binary representation of values from *a* and *b*, where value ``0`` represents ``false`` and value ``1`` represents ``true``. +3. Convert the results of XOR in binary representation to the input datatype. + +Example 1 - *BitwiseXor* output for boolean tensor: + +.. code-block:: py + :force: + + # For given boolean inputs: + a = [True, False, False] + b = [True, True, False] + # Perform logical XOR operation same as in LogicalXor operator: + output = [False, True, False] + +Example 2 - *BitwiseXor* output for uint8 tensor: + +.. code-block:: py + :force: + + # For given uint8 inputs: + a = [21, 120] + b = [3, 37] + # Create a binary representation of uint8: + # binary a: [00010101, 01111000] + # binary b: [00000011, 00100101] + # Perform bitwise XOR of corresponding elements in a and b: + # [00010110, 01011101] + # Convert binary values to uint8: + output = [22, 93] + +**Attributes**: + +* *auto_broadcast* + + * **Description**: specifies the rules used for auto-broadcasting of input tensors. + * **Range of values**: + + * *none* - no auto-broadcasting is allowed, all input shapes must match, + * *numpy* - numpy broadcasting rules, description is available in :doc:`Broadcast Rules For Elementwise Operations `, + * *pdpd* - PaddlePaddle-style implicit broadcasting, description is available in :doc:`Broadcast Rules For Elementwise Operations `. + + * **Type**: string + * **Default value**: "numpy" + * **Required**: *no* + +**Inputs** + +* **1**: A tensor of type *T* and arbitrary shape. **Required.** +* **2**: A tensor of type *T* and arbitrary shape. **Required.** + +**Outputs** + +* **1**: The result of element-wise *BitwiseXor* operation. A tensor of type *T* and the same shape equal to the broadcasted shape of two inputs. + +**Types** + +* *T*: ``any supported integer or boolean type``. + +**Examples** + +*Example 1: no broadcast* + +.. code-block:: xml + :force: + + + + + 256 + 56 + + + 256 + 56 + + + + + 256 + 56 + + + + + +*Example 2: numpy broadcast* + +.. code-block:: xml + :force: + + + + + 8 + 1 + 6 + 1 + + + 7 + 1 + 5 + + + + + 8 + 7 + 6 + 5 + + + + + +@endsphinxdirective diff --git a/docs/ops/opset13.md b/docs/ops/opset13.md index f1411293a17..dde2f5ce488 100644 --- a/docs/ops/opset13.md +++ b/docs/ops/opset13.md @@ -32,6 +32,10 @@ Table of Contents * :doc:`BatchNormInference ` * :doc:`BatchToSpace ` * :doc:`BinaryConvolution ` +* :doc:`BitwiseAnd ` +* :doc:`BitwiseOr ` +* :doc:`BitwiseXor ` +* :doc:`BitwiseNot ` * :doc:`Broadcast ` * :doc:`Bucketize ` * :doc:`CTCGreedyDecoder `