keras-team/keras · error · ValueError

`kron` does not support tensors with dynamic rank for the…

Error message

`kron` does not support tensors with dynamic rank for the OpenVINO backend.

What it means

Raised by keras.ops.numpy.kron in the OpenVINO backend when either input has a dynamic rank. The Kronecker product construction reshapes and broadcasts using explicit rank arithmetic, so static ranks are required.

Solutions

  1. Pass tensors with statically known ranks
  2. Rebuild the graph so shapes/ranks are concrete
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/openvino/numpy.py:2523 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/950c2e4ee26e0236. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/openvino/numpy.py:2523

            inf = ov_opset.constant(inf_value, Type.f32).output(0)
        is_inf = ov_opset.equal(x, inf).output(0)
    return OpenVINOKerasTensor(is_inf)


def isreal(x):
    # Implement complex support when OpenVINO adds complex dtypes.
    x = convert_to_tensor(x)
    return ones(x.shape, dtype="bool")


def kron(x1, x2):
    x1 = get_ov_output(x1)
    x2 = get_ov_output(x2)
    x1, x2 = _align_operand_types(x1, x2, "kron()")
    x1_shape = x1.get_partial_shape()
    x2_shape = x2.get_partial_shape()
    if x1_shape.rank.is_dynamic or x2_shape.rank.is_dynamic:
        raise ValueError(
            "`kron` does not support tensors with dynamic rank for "
            "the OpenVINO backend."
        )
    ndim1 = x1_shape.rank.get_length()
    ndim2 = x2_shape.rank.get_length()
    if ndim1 < ndim2:
        axes = ov_opset.range(
            ov_opset.constant(0, Type.i32),
            ov_opset.constant(ndim2 - ndim1, Type.i32),
            ov_opset.constant(1, Type.i32),
        )
        x1 = ov_opset.unsqueeze(x1, axes)
        ndim1 = ndim2
    elif ndim2 < ndim1:
        axes = ov_opset.range(
            ov_opset.constant(0, Type.i32),
            ov_opset.constant(ndim1 - ndim2, Type.i32),
            ov_opset.constant(1, Type.i32),

View on GitHub (pinned to 7a34a03db6)