And#
And - 7#
Version
name: And (GitHub)
domain: main
since_version: 7
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 7.
Summary
Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).
This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Inputs
A (heterogeneous) - T: First input operand for the logical operator.
B (heterogeneous) - T: Second input operand for the logical operator.
Outputs
C (heterogeneous) - T1: Result tensor.
Type Constraints
T in ( tensor(bool) ): Constrains input to boolean tensor.
T1 in ( tensor(bool) ): Constrains output to boolean tensor.
Examples
and_broadcast
node = onnx.helper.make_node(
'And',
inputs=['x', 'y'],
outputs=['and'],
)
# 3d vs 1d
x = (np.random.randn(3, 4, 5) > 0).astype(bool)
y = (np.random.randn(5) > 0).astype(bool)
z = np.logical_and(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_and_bcast3v1d')
# 3d vs 2d
x = (np.random.randn(3, 4, 5) > 0).astype(bool)
y = (np.random.randn(4, 5) > 0).astype(bool)
z = np.logical_and(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_and_bcast3v2d')
# 4d vs 2d
x = (np.random.randn(3, 4, 5, 6) > 0).astype(bool)
y = (np.random.randn(5, 6) > 0).astype(bool)
z = np.logical_and(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_and_bcast4v2d')
# 4d vs 3d
x = (np.random.randn(3, 4, 5, 6) > 0).astype(bool)
y = (np.random.randn(4, 5, 6) > 0).astype(bool)
z = np.logical_and(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_and_bcast4v3d')
# 4d vs 4d
x = (np.random.randn(1, 4, 1, 6) > 0).astype(bool)
y = (np.random.randn(3, 1, 5, 6) > 0).astype(bool)
z = np.logical_and(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_and_bcast4v4d')
Differences
0 | 0 | Returns the tensor resulted from performing the and logical operation | Returns the tensor resulted from performing the and logical operation |
1 | 1 | elementwise on the input tensors A and B. |
|
2 | 2 |
|
|
3 | 3 | If broadcasting is enabled, the right-hand-side argument will be broadcasted |
|
4 | to match the shape of left-hand-side argument. See the doc of Add for a | ||
5 | detailed description of the broadcasting rules. | ||
6 | 4 |
|
|
7 | **Attributes** | ||
8 |
| ||
9 | * **axis**: | ||
10 | If set, defines the broadcast dimensions. | ||
11 | * **broadcast**: | ||
12 | Enable broadcasting Default value is 0. | ||
13 |
| ||
14 | 5 | **Inputs** | **Inputs** |
15 | 6 |
|
|
16 | 7 | * **A** (heterogeneous) - **T**: | * **A** (heterogeneous) - **T**: |
17 | 8 | Left input tensor for the logical operator. |
|
18 | 9 | * **B** (heterogeneous) - **T**: | * **B** (heterogeneous) - **T**: |
19 | 10 | Right input tensor for the logical operator. |
|
20 | 11 |
|
|
21 | 12 | **Outputs** | **Outputs** |
22 | 13 |
|
|
23 | 14 | * **C** (heterogeneous) - **T1**: | * **C** (heterogeneous) - **T1**: |
24 | 15 | Result tensor. | Result tensor. |
25 | 16 |
|
|
26 | 17 | **Type Constraints** | **Type Constraints** |
27 | 18 |
|
|
28 | 19 | * **T** in ( | * **T** in ( |
29 | 20 | tensor(bool) | tensor(bool) |
30 | 21 | ): | ): |
31 | 22 | Constrains input to boolean tensor. | Constrains input to boolean tensor. |
32 | 23 | * **T1** in ( | * **T1** in ( |
33 | 24 | tensor(bool) | tensor(bool) |
34 | 25 | ): | ): |
35 | 26 | Constrains output to boolean tensor. | Constrains output to boolean tensor. |
And - 1#
Version
name: And (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 1.
Summary
Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B.
If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.
Attributes
axis: If set, defines the broadcast dimensions.
broadcast: Enable broadcasting Default value is
0
.
Inputs
A (heterogeneous) - T: Left input tensor for the logical operator.
B (heterogeneous) - T: Right input tensor for the logical operator.
Outputs
C (heterogeneous) - T1: Result tensor.
Type Constraints
T in ( tensor(bool) ): Constrains input to boolean tensor.
T1 in ( tensor(bool) ): Constrains output to boolean tensor.