Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit d80ec3b

Browse files
Shashi456rxwei
authored andcommitted
Add a 'clipped(min:max:)' method. (#198)
1 parent 36686da commit d80ec3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/TensorFlow/Operators/Basic.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,16 @@ public extension Tensor {
575575
}
576576
}
577577

578+
public extension Tensor where Scalar: Numeric {
579+
/// Returns a tensor by clipping scalars to a specified minimum and maximum.
580+
// FIXME: Define a derivative function.
581+
// @differentiable(wrt: self where Scalar: TensorFlowFloatingPoint)
582+
@inlinable
583+
func clipped(min: Tensor, max: Tensor) -> Tensor {
584+
Raw.clipByValue(t: self, clipValueMin: min, clipValueMax: max)
585+
}
586+
}
587+
578588
//===------------------------------------------------------------------------------------------===//
579589
// Broadcasting
580590
//===------------------------------------------------------------------------------------------===//

0 commit comments

Comments
 (0)