Skip to content

[Bug]: bitwise_and / bitwise_or / bitwise_xor return incorrect values for int8/uint8 when broadcasting #34638

@goyaladitya05

Description

@goyaladitya05

OpenVINO Version

2026.0

Operating System

Windows System

Device used for inference

CPU

Framework

None

Model used

N/A

Issue description

BitwiseAnd, BitwiseOr, and BitwiseXor silently produce incorrect results for int8/uint8 operands when one operand is broadcast to match the other's shape. Same-shape operations always produce correct results. No exception or warning is raised. The op executes normally but returns wrong values.

Expected: element-wise result identical to NumPy's np.bitwise_and / np.bitwise_or / np.bitwise_xor.

The issue is with Python API (openvino.opset15).

Step-by-step reproduction

import numpy as np
import openvino.opset15 as ov_opset
from openvino.runtime import Model, compile_model

def run(x_np, m_np, label):
    x = ov_opset.constant(x_np)
    m = ov_opset.constant(m_np)
    node = ov_opset.bitwise_and(x.output(0), m.output(0))
    result = compile_model(Model([node.output(0)], []), "CPU")({})[0]
    expected = np.bitwise_and(x_np, m_np)
    ok = np.array_equal(result, expected)
    print(f"{label}: {'OK' if ok else f'FAIL — {(result != expected).sum()}/{result.size} wrong'}")

x = np.arange(64, dtype=np.int8).reshape(1, 64)
run(x, np.full((1, 64), np.int8(0x0F)), "same-shape (1,64)")   # OK
run(x, np.array(np.int8(0x0F)),          "(1,64) vs scalar")    # FAIL
run(x, np.array([[np.int8(0x0F)]]),      "(1,64) vs (1,1)")     # FAIL

x2 = np.arange(32 * 256, dtype=np.int8).reshape(32, 256)
run(x2, np.full((32, 256), np.int8(0x0F)), "same-shape (32,256)")  # OK
run(x2, np.array(np.int8(0x0F)),            "(32,256) vs scalar")   # FAIL

Relevant log output

same-shape (1,64): OK
(1,64) vs scalar:  FAIL — 48/64 wrong
(1,64) vs (1,1):   FAIL — 48/64 wrong
same-shape (32,256): OK
(32,256) vs scalar:  FAIL — 6144/8192 wrong

Issue submission checklist

  • I'm reporting an issue. It's not a question.
  • I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
  • There is reproducer code and related data files such as images, videos, models, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions