Or#

Or - 7#

Version

  • name: Or (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 or 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) ): Constrain input to boolean tensor.

  • T1 in ( tensor(bool) ): Constrain output to boolean tensor.

Examples

default

node = onnx.helper.make_node(
    "Or",
    inputs=["x", "y"],
    outputs=["or"],
)

# 2d
x = (np.random.randn(3, 4) > 0).astype(bool)
y = (np.random.randn(3, 4) > 0).astype(bool)
z = np.logical_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or2d")

# 3d
x = (np.random.randn(3, 4, 5) > 0).astype(bool)
y = (np.random.randn(3, 4, 5) > 0).astype(bool)
z = np.logical_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or3d")

# 4d
x = (np.random.randn(3, 4, 5, 6) > 0).astype(bool)
y = (np.random.randn(3, 4, 5, 6) > 0).astype(bool)
z = np.logical_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or4d")

_or_broadcast

node = onnx.helper.make_node(
    "Or",
    inputs=["x", "y"],
    outputs=["or"],
)

# 3d vs 1d
x = (np.random.randn(3, 4, 5) > 0).astype(bool)
y = (np.random.randn(5) > 0).astype(bool)
z = np.logical_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or_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_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or_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_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or_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_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or_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_or(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_or_bcast4v4d")

Differences

00Returns the tensor resulted from performing the or logical operationReturns the tensor resulted from performing the or logical operation
11elementwise on the input tensors A and B.elementwise on the input tensors A and B (with Numpy-style broadcasting support).
22
33If broadcasting is enabled, the right-hand-side argument will be broadcastedThis operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX <https://github.com/onnx/onnx/blob/master/docs/Broadcasting.md>_.
4to match the shape of left-hand-side argument. See the doc of Add for a
5detailed description of the broadcasting rules.
64
7**Attributes**
8
9* **axis**:
10 If set, defines the broadcast dimensions.
11* **broadcast**:
12 Enable broadcasting Default value is 0.
13
145**Inputs****Inputs**
156
167* **A** (heterogeneous) - **T**:* **A** (heterogeneous) - **T**:
178 Left input tensor for the logical operator. First input operand for the logical operator.
189* **B** (heterogeneous) - **T**:* **B** (heterogeneous) - **T**:
1910 Right input tensor for the logical operator. Second input operand for the logical operator.
2011
2112**Outputs****Outputs**
2213
2314* **C** (heterogeneous) - **T1**:* **C** (heterogeneous) - **T1**:
2415 Result tensor. Result tensor.
2516
2617**Type Constraints****Type Constraints**
2718
2819* **T** in (* **T** in (
2920 tensor(bool) tensor(bool)
3021 ): ):
3122 Constrain input to boolean tensor. Constrain input to boolean tensor.
3223* **T1** in (* **T1** in (
3324 tensor(bool) tensor(bool)
3425 ): ):
3526 Constrain output to boolean tensor. Constrain output to boolean tensor.

Or - 1#

Version

  • name: Or (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 or 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) ): Constrain input to boolean tensor.

  • T1 in ( tensor(bool) ): Constrain output to boolean tensor.