<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCActivationLayer/clamp(min:max:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCActivationLayer(cm)clampLayerWithMinValue:maxValue:"
  },
  "title" : "clamp(min:max:)"
}
-->

# clamp(min:max:)

Creates an instance of a clamp activation layer using the minimum and maximum values you specify for the clamp formation.

```
class func clamp(min minValue: Float, max maxValue: Float) -> Self
```

## Parameters

`minValue`

The minimum value to clamp.

`maxValue`

The maximum value to clamp.

## Return Value

A new `MLCActivationLayer` instance.

## Discussion

The [`clamp(min:max:)`](/documentation/MLCompute/MLCActivationLayer/clamp(min:max:)) factory type method creates an activation descriptor using [`init(type:a:b:)`](/documentation/MLCompute/MLCActivationDescriptor/init(type:a:b:)), where `type =` [`MLCActivationType.clamp`](/documentation/MLCompute/MLCActivationType/clamp) and `a = minValue,` `b = maxValue`, and passes that descriptor to [`init(descriptor:)`](/documentation/MLCompute/MLCActivationLayer/init(descriptor:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)