keras-team/keras · error · ValueError

indexing must be either 'xy' or 'ij'

Error message

indexing must be either 'xy' or 'ij'

What it means

Raised by keras.ops.numpy.meshgrid in the OpenVINO backend when the indexing argument is not 'xy' or 'ij'. Only these two cartesian indexing conventions are implemented; anything else hits the string guard.

Solutions

  1. Use indexing='xy' (default, first dim varies fastest) or 'ij' (matrix indexing)
  2. Omit indexing to use the default 'xy'
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

                [1] * original_rank, Type.i32
            ).output(0)
            median_result = ov_opset.reshape(
                median_result, ones_shape, False
            ).output(0)
        else:
            median_result = ov_opset.unsqueeze(median_result, [axis]).output(0)

    return OpenVINOKerasTensor(median_result)


def meshgrid(*x, indexing="xy"):
    if len(x) < 2:
        raise ValueError(
            "meshgrid requires at least 2 input arrays. "
            f"Received: {len(x)} input array(s)."
        )
    if indexing not in ("xy", "ij"):
        raise ValueError("indexing must be either 'xy' or 'ij'")

    tensors = [get_ov_output(xi) for xi in x]
    n = len(tensors)

    shapes = [
        ov_opset.shape_of(t, Type.i64).output(0) for t in tensors
    ]  # each is [Ni]
    one = ov_opset.constant([1], Type.i64).output(0)

    if indexing == "xy":
        shape_list = [shapes[1], shapes[0]] + shapes[2:]
        out_shape = ov_opset.concat(shape_list, axis=0).output(0)
    else:
        out_shape = ov_opset.concat(shapes, axis=0).output(0)

    outputs = []
    for i, t in enumerate(tensors):
        reshape_parts = [one] * n

View on GitHub (pinned to 7a34a03db6)