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

Commit e77c152

Browse files
committed
Moving clip out of broadcasting and declaring a separate block
1 parent e975f2b commit e77c152

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Sources/TensorFlow/Operators/Basic.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,15 @@ public extension Tensor {
576576
}
577577
}
578578

579+
public extension Tensor where Scalar: Numeric {
580+
/// Returns a `Tensor` by clipping tensor values to a specified min and max.
581+
@inlinable
582+
@differentiable(wrt: self where Scalar: TensorFlowFloatingPoint)
583+
func clipped(min minimum: Tensor, max maximum: Tensor) -> Tensor{
584+
return Raw.clipByValue(t: self, clipValueMin: minimum, clipValueMax: maximum)
585+
}
586+
}
587+
579588
//===------------------------------------------------------------------------------------------===//
580589
// Broadcasting
581590
//===------------------------------------------------------------------------------------------===//
@@ -611,14 +620,6 @@ public extension Tensor {
611620
}
612621

613622
public extension Tensor where Scalar: Numeric {
614-
615-
/// Returns a `Tensor` by clipping tensor values to a specified min and max.
616-
@inlinable
617-
@differentiable(wrt: self where Scalar: TensorFlowFloatingPoint)
618-
func clipped(min minimum: Tensor, max maximum: Tensor) -> Tensor{
619-
return Raw.clipByValue(t: self, clipValueMin: minimum, clipValueMax: maximum)
620-
}
621-
622623
@inlinable
623624
@differentiable(wrt: self where Scalar: TensorFlowFloatingPoint)
624625
func unbroadcasted(toShape otherShape: Tensor<Int32>) -> Tensor {

0 commit comments

Comments
 (0)