def test_clamp_operator_with_array(): runtime = get_runtime() data_value = np.array([[-5, 9], [45, 3]], dtype=np.float32) min_value = np.float32(3) max_value = np.float32(12) model = ov.clamp(data_value, min_value, max_value) computation = runtime.computation(model) result = computation() expected = np.clip(data_value, min_value, max_value) assert np.allclose(result, expected)
def test_clamp_operator(): runtime = get_runtime() data_shape = [2, 2] parameter_data = ov.parameter(data_shape, name="Data", dtype=np.float32) min_value = np.float32(3) max_value = np.float32(12) model = ov.clamp(parameter_data, min_value, max_value) computation = runtime.computation(model, parameter_data) data_value = np.array([[-5, 9], [45, 3]], dtype=np.float32) result = computation(data_value) expected = np.clip(data_value, min_value, max_value) assert np.allclose(result, expected)