keras-team/keras · error · ValueError

Operation must be 'min' or 'max', received

Error message

Operation must be 'min' or 'max', received {operation}

What it means

Raised by the internal _compute_extrema helper in the OpenVINO backend when its operation argument is neither 'min' nor 'max'. The helper selects reduce_min/reduce_max; anything else falls to this catch-all guard (it indicates an internal/misuse of the private API).

Solutions

  1. Use keras.ops.max or keras.ops.min which call the helper with valid operations
  2. If calling the private helper, pass 'min' or 'max' only
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

            False,
        ).output(0)

    return OpenVINOKerasTensor(result)


def max(x, axis=None, keepdims=False, initial=None):
    return _compute_extrema(x, "max", axis, keepdims, initial)


def _compute_extrema(x, operation, axis=None, keepdims=False, initial=None):
    if operation == "min":
        reduction_op = ov_opset.reduce_min
        elementwise_op = ov_opset.minimum
    elif operation == "max":
        reduction_op = ov_opset.reduce_max
        elementwise_op = ov_opset.maximum
    else:
        raise ValueError(
            f"Operation must be 'min' or 'max', received {operation}"
        )

    x = get_ov_output(x)
    x_type = x.get_element_type()
    x_for_rank = x

    is_bool = x_type == Type.boolean
    if is_bool:
        x = ov_opset.convert(x, Type.i32).output(0)
        x_type = Type.i32

    if isinstance(axis, tuple) and len(axis) == 0:
        return OpenVINOKerasTensor(x)

    was_axis_none = axis is None
    x, axis = _resolve_axis(x, axis)

View on GitHub (pinned to 7a34a03db6)