Fix ClampFusion for case when min is greater then max (#21509)

This commit is contained in:
Maxim Vafin 2023-12-07 14:58:38 +01:00 committed by GitHub
parent ec40652cea
commit dd8f4f3661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -48,6 +48,8 @@ ov::pass::ClampFusion::ClampFusion() {
double min_value = min_const->cast_vector<double>()[0];
double max_value = max_const->cast_vector<double>()[0];
if (min_value > max_value)
return false;
auto clamp = register_new_node<ov::op::v0::Clamp>(data, min_value, max_value);

View File

@ -42,7 +42,7 @@ class TestClamp(PytorchLayerTest):
return aten_clamp(minimum, maximum, as_tensors, op_type), ref_net, op_name
@pytest.mark.parametrize("minimum,maximum",
[(0., 1.), (-0.5, 1.5), (None, 10.), (None, -10.), (10., None), (-10., None), (100, 200)])
[(0., 1.), (-0.5, 1.5), (None, 10.), (None, -10.), (10., None), (-10., None), (100, 200), (1.0, 0.0)])
@pytest.mark.parametrize("as_tensors", [True, False])
@pytest.mark.parametrize("op_type", ["clamp", "clamp_"])
@pytest.mark.nightly
@ -50,11 +50,6 @@ class TestClamp(PytorchLayerTest):
self._test(*self.create_model(minimum, maximum, as_tensors,
op_type), ie_device, precision, ir_version)
@pytest.mark.xfail(reason='OpenVINO clamp does not support min > max')
def test_clamp_min_greater(self, ie_device, precision, ir_version):
self._test(*self.create_model(1.0, 0.0),
ie_device, precision, ir_version)
class TestClampMin(PytorchLayerTest):
def _prepare_input(self):