keras-team/keras · error · RuntimeError
`convert_to_numpy` failed to convert the tensor.
Error message
`convert_to_numpy` failed to convert the tensor.
What it means
Raised by the OpenVINO backend's convert_to_numpy fast path when compiling and executing the tiny conversion model fails or the result cannot be read back as a NumPy array. It is a catch-all guard around OpenVINO model compilation/inference, signaling the tensor could not be materialized to numpy.
Solutions
- Retry with a concrete input tensor whose shape/dtype are static
- Check that the tensor is a valid OpenVINO graph output (not an invalid/empty graph)
- Rebuild or re-trace the model to produce a well-formed graph before conversion
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at keras/src/backend/openvino/core.py:950 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/ce75620acced1355.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/openvino/core.py:950
# fall back to the slow path.
pass
try:
ov_result = x.output
casted_from_bool = False
if ov_result.get_element_type() == Type.boolean:
ov_result = ov_opset.convert(ov_result, Type.i32).output(0)
casted_from_bool = True
ov_model = Model(results=[ov_result], parameters=[])
ov_compiled_model = compile_model(
ov_model,
get_device(),
config={"INFERENCE_PRECISION_HINT": "f32"},
)
result = ov_compiled_model({})[0]
if casted_from_bool:
result = result.astype(bool)
except Exception as inner_exception:
raise RuntimeError(
"`convert_to_numpy` failed to convert the tensor."
) from inner_exception
data = np.array(result)
# Same byte-reinterpretation issue applies to inference results.
if x.dtype == "bfloat16" and data.dtype != ml_dtypes.bfloat16:
data = data.view(ml_dtypes.bfloat16)
return data
def is_tensor(x):
if isinstance(x, OpenVINOKerasTensor):
return True
if isinstance(x, ov.Tensor):
return True
return False
def shape(x):View on GitHub (pinned to 7a34a03db6)