Skip to content

[Bug]: Wrong output for Max op with two int16 constant inputs on GPU devices #33462

@zhihaoxu1325

Description

@zhihaoxu1325

OpenVINO Version

2025.4.0

Operating System

Ubuntu 20.04 (LTS)

Device used for inference

GPU

Framework

None

Model used

No response

Issue description

The GPU plugin produces completely incorrect (garbage/zero) values when executing Max operation with int16 data type. The bug only occurs when both inputs are initializers (constants); using runtime inputs works correctly.

Affected Configuration

Parameter: input source

Affected Values: both inputs as initializers (constants)

Working Values: at least one input as runtime input

Parameter: data type

Affected Values: int16

Working Values: int32, float32

Root Cause Hypothesis

The GPU kernel for Max operation with int16 constants appears to have incorrect constant folding or memory handling. The output values (zeros and int16 boundary values like -32768, 32767) suggest reading from uninitialized memory rather than a computational error.

Step-by-step reproduction

Please run the Minimal Reproduction code:


import numpy as np
import onnx
from onnx import helper, TensorProto, numpy_helper
from openvino import Core

# Minimal reproducer for OpenVINO GPU bug
# Bug: Max op with two int16 initializers produces wrong results on GPU

v47_data = np.array([[5, 4, 6, 6, 4]], dtype=np.int16)
v48_data = np.array([6, 5, 4, 5, 4], dtype=np.int16)

v47_init = numpy_helper.from_array(v47_data, 'v47')
v48_init = numpy_helper.from_array(v48_data, 'v48')
output = helper.make_tensor_value_info('output', TensorProto.INT16, None)

max_node = helper.make_node('Max', ['v47', 'v48'], ['output'])
graph = helper.make_graph([max_node], 'test', [], [output], [v47_init, v48_init])
model = helper.make_model(graph, opset_imports=[helper.make_opsetid('', 14)])
onnx.save(model, '/tmp/max_int16_bug.onnx')

core = Core()
compiled_cpu = core.compile_model('/tmp/max_int16_bug.onnx', 'CPU')
compiled_gpu = core.compile_model('/tmp/max_int16_bug.onnx', 'GPU')

result_cpu = compiled_cpu({})[0]
result_gpu = compiled_gpu({})[0]

print(f"Expected (CPU): {result_cpu}")  # [[6 5 6 6 4]]
print(f"Actual (GPU):   {result_gpu}")  # [[0 0 0 0 -32768]] <- WRONG!
assert np.array_equal(result_cpu, result_gpu), "BUG: GPU result differs from CPU"

Relevant log output

Expected (CPU): [[6 5 6 6 4]]
Actual (GPU):   [[     0      0      0      0 -32768]]
Traceback (most recent call last):
  File "/doc2/zhzh/OpenVINO/./test_crash.py", line 30, in <module>
    assert np.array_equal(result_cpu, result_gpu), "BUG: GPU result differs from CPU"
AssertionError: BUG: GPU result differs from CPU

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

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions