keras-team/keras · error · ValueError

`slice` operation requires tuple for `start_indices with…

Error message

`slice` operation requires tuple for `start_indices with the openvino backend. Received: start_indices={start_indices}

What it means

Raised by the OpenVINO backend slice op when start_indices is not a tuple (lists and numpy arrays are auto-converted first). The underlying OpenVINO StridedSlice requires Python tuples, so any other type after conversion is rejected by this type guard.

Solutions

  1. Pass start_indices as a tuple (a list or np.ndarray is also accepted and converted)
  2. Build the tuple dynamically instead of passing another sequence type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at keras/src/backend/openvino/core.py:1363 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/468fcae39e8ae377. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/openvino/core.py:1363

    elif reduction in ("max", "min"):
        ov_reduction = reduction
    else:
        raise ValueError(f"Unsupported reduction: {reduction}")

    result = ov_opset.scatter_nd_update(
        inputs, indices, updates, reduction=ov_reduction
    ).output(0)
    return OpenVINOKerasTensor(result)


def slice(inputs, start_indices, shape):
    inputs = get_ov_output(inputs)
    if isinstance(start_indices, (list, np.ndarray)):
        start_indices = tuple(start_indices)
    if isinstance(shape, (list, np.ndarray)):
        shape = tuple(shape)
    if not isinstance(start_indices, tuple):
        raise ValueError(
            "`slice` operation requires tuple for `start_indices with the "
            f"openvino backend. Received: start_indices={start_indices}"
        )
    if not isinstance(shape, tuple):
        raise ValueError(
            "`slice` operation requires tuple for `shape` with the "
            f"openvino backend. Received: shape={shape}"
        )

    axes = []
    start = []
    stop = []

    def prepare_slice_index(val):
        val_type = val.get_element_type()
        if not val_type.is_integral():
            raise ValueError(
                "`slice` is not supported by OpenVINO backend "

View on GitHub (pinned to 7a34a03db6)