BitwiseAnd#
BitwiseAnd - 18#
Version
name: BitwiseAnd (GitHub)
domain: main
since_version: 18
function:
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 18.
Summary
Inputs
A (heterogeneous) - T:
B (heterogeneous) - T:
Outputs
C (heterogeneous) - T:
Type Constraints
T in ( tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input to integer tensors.
Examples
default
import numpy as np
import onnx
node = onnx.helper.make_node(
"BitwiseAnd",
inputs=["x", "y"],
outputs=["bitwiseand"],
)
# 2d
x = create_random_int((3, 4), np.int32)
y = create_random_int((3, 4), np.int32)
z = np.bitwise_and(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_bitwise_and_i32_2d")
# 3d
x = create_random_int((3, 4, 5), np.int16)
y = create_random_int((3, 4, 5), np.int16)
z = np.bitwise_and(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_bitwise_and_i16_3d")
_bitwiseand_broadcast
import numpy as np
import onnx
node = onnx.helper.make_node(
"BitwiseAnd",
inputs=["x", "y"],
outputs=["bitwiseand"],
)
# 3d vs 1d
x = create_random_int((3, 4, 5), np.uint64)
y = create_random_int((5,), np.uint64)
z = np.bitwise_and(x, y)
expect(
node, inputs=[x, y], outputs=[z], name="test_bitwise_and_ui64_bcast_3v1d"
)
# 4d vs 3d
x = create_random_int((3, 4, 5, 6), np.uint8)
y = create_random_int((4, 5, 6), np.uint8)
z = np.bitwise_and(x, y)
expect(node, inputs=[x, y], outputs=[z], name="test_bitwise_and_ui8_bcast_4v3d")