Revise equal (#6605)

* update spec, init backend file for equal op

* add backend, visitors, serialize SLT tests

* add backend test to manifest cause of mismatch of output type with cpu plugin

* add equal to list of trusted ops and to cmakelist file

* refactor backend tests to the new template

* refactor spec

* remove external link in numpy broadcast and update example

* remove comparison.in.cpp file and related tests from manifest

* fix example

* remove redundant arguments

* refactor backend tests

* add pdpd broadcast to the spec, and different precison to SLT test

* add precisions to SLT cpu

* remove unsupported type from SLT

* revert the deletion of comparison.in.cpp file

* remove visitors test, since it will be added in the other PR

* remove equal from CMakeLists.txt

* refactor links in the spec

* revert unwanted changes

* remove equal from unit test manifest

* revert links modification in spec

* add namespace

* split SSLTs for comaprison ops into seperate files

* fix SSLTs names

* add missing new lines

* udpate output type in spec

* rafactor numeric backend test to template

* merge numeric template tests into equal
This commit is contained in:
Bartek Szmelczynski
2021-08-11 12:04:30 +02:00
committed by GitHub
parent 5292de5338
commit 289df8db27
14 changed files with 473 additions and 100 deletions

View File

@@ -4,35 +4,10 @@
**Category**: Comparison binary operation
**Short description**: *Equal* performs element-wise comparison operation with two given tensors applying multi-directional broadcast rules.
**Attributes**:
* *auto_broadcast*
* **Description**: specifies rules used for auto-broadcasting of input tensors.
* **Range of values**:
* *none* - no auto-broadcasting is allowed, all input shapes should match
* *numpy* - numpy broadcasting rules, aligned with ONNX Broadcasting. Description is available in <a href="https://github.com/onnx/onnx/blob/master/docs/Broadcasting.md">ONNX docs</a>.
* **Type**: string
* **Default value**: "numpy"
* **Required**: *no*
**Inputs**
* **1**: A tensor of type *T*. **Required.**
* **2**: A tensor of type *T*. **Required.**
**Outputs**
* **1**: The result of element-wise comparison operation. A tensor of type boolean.
**Types**
* *T*: arbitrary supported type.
**Short description**: *Equal* performs element-wise comparison operation with two given input tensors applying multi-directional broadcast rules specified in the *auto_broadcast* attribute.
**Detailed description**
Before performing arithmetic operation, input tensors *a* and *b* are broadcasted if their shapes are different and `auto_broadcast` attributes is not `none`. Broadcasting is performed according to `auto_broadcast` value.
Before performing arithmetic operation, input tensors *a* and *b* are broadcasted if their shapes are different and *auto_broadcast* attributes is not *none*. Broadcasting is performed according to *auto_broadcast* value.
After broadcasting *Equal* does the following with the input tensors *a* and *b*:
@@ -40,12 +15,40 @@ After broadcasting *Equal* does the following with the input tensors *a* and *b*
o_{i} = a_{i} == b_{i}
\f]
**Attributes**:
* *auto_broadcast*
* **Description**: specifies rules used for auto-broadcasting of input tensors.
* **Range of values**:
* *none* - no auto-broadcasting is allowed, all input shapes should match,
* *numpy* - numpy broadcasting rules, description is available in [Broadcast Rules For Elementwise Operations](../broadcast_rules.md),
* *pdpd* - PaddlePaddle-style implicit broadcasting, description is available in [Broadcast Rules For Elementwise Operations](../broadcast_rules.md).
* **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 **comparison** operation applied to the input tensors. A tensor of type *T_BOOL* and the same shape equal to broadcasted shape of two inputs.
**Types**
* *T*: arbitrary supported type.
* *T_BOOL*: `boolean`.
**Examples**
*Example 1*
*Example 1: no broadcast*
```xml
<layer ... type="Equal">
<data auto_broadcast="none"/>
<input>
<port id="0">
<dim>256</dim>
@@ -65,9 +68,10 @@ o_{i} = a_{i} == b_{i}
</layer>
```
*Example 2: broadcast*
*Example 2: numpy broadcast*
```xml
<layer ... type="Equal">
<data auto_broadcast="numpy"/>
<input>
<port id="0">
<dim>8</dim>