---
title: "clamped(to:)"
framework: coreml
role: symbol
role_heading: Instance Method
path: "coreml/mltensor/clamped(to:)"
---

# clamped(to:)

Clamps all elements to the given lower and upper bounds, inclusively.

## Declaration

```swift
func clamped(to bounds: ClosedRange<Float>) -> MLTensor
```

## Discussion

Discussion For example: let x = MLTensor([-1.0, 1.0, 2.0]) let y = x.clamped(to: 0...1) await y.shapedArray(of: Float.self) // is [0.0, 1.0, 1.0]

## See Also

### Clamping and concatenating

- [concatenated(with:alongAxis:)](coreml/mltensor/concatenated(with:alongaxis:).md)
