mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 13:16:32 -06:00
* dnn: handle min > max in Clip layer and enable ONNX conformance test Under the ONNX specification, the Clip operator is defined mathematically as y = min(max(x, min), max). When min > max, the operation clamps identically to max for all input values. Previously, ClipLayerImpl asserted minValue <= maxValue in its constructor and actualMin <= actualMax in forward, causing assertion failures on valid ONNX models with min > max. Additionally, the adjacency graph fusion interpreter checked a < min first, returning min instead of max. This commit: 1. Removes the min <= max assertions in ClipLayerImpl constructor and forward, allowing ONNX-conforming evaluation where min > max clamps to max. 2. Updates FusionEltwiseOp::CLAMP in AdjacencyGraph interpreter to use std::min(std::max(a, n.scalar), n.scalar2), matching the ONNX evaluation order. 3. Removes test_clip_min_greater_than_max from the layer parser denylist. 4. Adds unit tests covering static and dynamic min > max clipping. * dnn: filter test_clip_min_greater_than_max for OpenVINO backend * dnn(test): address review comments on Clip min > max tests and fusion coverage