@@ -1225,10 +1225,6 @@ public extension Tensor where Scalar : Numeric {
1225
1225
/// - Parameter axes: The dimensions to reduce.
1226
1226
/// - Precondition: Each value in `axes` must be in the range `-rank...rank`.
1227
1227
@inlinable @inline ( __always)
1228
- @differentiable (
1229
- wrt: self , vjp: _vjpMean ( squeezingAxes: )
1230
- where Scalar : Differentiable & FloatingPoint
1231
- )
1232
1228
func mean( squeezingAxes axes: [ Int32 ] ) -> Tensor {
1233
1229
return Raw . mean ( self , reductionIndices: Tensor < Int32 > ( axes) ,
1234
1230
keepDims: false )
@@ -1239,10 +1235,6 @@ public extension Tensor where Scalar : Numeric {
1239
1235
/// - Parameter axes: The dimensions to reduce.
1240
1236
/// - Precondition: Each value in `axes` must be in the range `-rank...rank`.
1241
1237
@inlinable @inline ( __always)
1242
- @differentiable (
1243
- wrt: self , vjp: _vjpMean ( squeezingAxes: )
1244
- where Scalar : Differentiable & FloatingPoint
1245
- )
1246
1238
func mean( squeezingAxes axes: Int32 ... ) -> Tensor {
1247
1239
return mean ( squeezingAxes: axes)
1248
1240
}
@@ -1252,10 +1244,6 @@ public extension Tensor where Scalar : Numeric {
1252
1244
/// - Parameter axes: The dimensions to reduce.
1253
1245
/// - Precondition: Each value in `axes` must be in the range `-rank...rank`.
1254
1246
@inlinable @inline ( __always)
1255
- @differentiable (
1256
- wrt: self , vjp: _vjpSum ( squeezingAxes: )
1257
- where Scalar : Differentiable & FloatingPoint
1258
- )
1259
1247
func sum( squeezingAxes axes: [ Int32 ] ) -> Tensor {
1260
1248
return Raw . sum ( self , reductionIndices: Tensor < Int32 > ( axes) , keepDims: false )
1261
1249
}
@@ -1265,10 +1253,6 @@ public extension Tensor where Scalar : Numeric {
1265
1253
/// - Parameter axes: The dimensions to reduce.
1266
1254
/// - Precondition: Each value in `axes` must be in the range `-rank...rank`.
1267
1255
@inlinable @inline ( __always)
1268
- @differentiable (
1269
- wrt: self , vjp: _vjpSum ( squeezingAxes: )
1270
- where Scalar : Differentiable & FloatingPoint
1271
- )
1272
1256
func sum( squeezingAxes axes: Int32 ... ) -> Tensor {
1273
1257
return sum ( squeezingAxes: axes)
1274
1258
}
@@ -1298,7 +1282,7 @@ public extension Tensor where Scalar : Numeric {
1298
1282
/// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1299
1283
@inlinable @inline ( __always)
1300
1284
@differentiable (
1301
- wrt: self , vjp: _vjpMean ( squeezingAxes : )
1285
+ wrt: self , vjp: _vjpMean ( alongAxes : )
1302
1286
where Scalar : Differentiable & FloatingPoint
1303
1287
)
1304
1288
func mean( alongAxes axes: [ Int32 ] ) -> Tensor {
@@ -1310,10 +1294,7 @@ public extension Tensor where Scalar : Numeric {
1310
1294
/// - Parameter axes: The dimensions to reduce.
1311
1295
/// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1312
1296
@inlinable @inline ( __always)
1313
- @differentiable (
1314
- wrt: self , vjp: _vjpMean ( squeezingAxes: )
1315
- where Scalar : Differentiable & FloatingPoint
1316
- )
1297
+ @differentiable ( wrt: self where Scalar : Differentiable & FloatingPoint)
1317
1298
func mean( alongAxes axes: Int32 ... ) -> Tensor {
1318
1299
return mean ( alongAxes: axes)
1319
1300
}
@@ -1324,7 +1305,7 @@ public extension Tensor where Scalar : Numeric {
1324
1305
/// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1325
1306
@inlinable @inline ( __always)
1326
1307
@differentiable (
1327
- wrt: self , vjp: _vjpSum ( squeezingAxes : )
1308
+ wrt: self , vjp: _vjpSum ( alongAxes : )
1328
1309
where Scalar : Differentiable & FloatingPoint
1329
1310
)
1330
1311
func sum( alongAxes axes: [ Int32 ] ) -> Tensor {
@@ -1336,14 +1317,33 @@ public extension Tensor where Scalar : Numeric {
1336
1317
/// - Parameter axes: The dimensions to reduce.
1337
1318
/// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1338
1319
@inlinable @inline ( __always)
1339
- @differentiable (
1340
- wrt: self , vjp: _vjpSum ( squeezingAxes: )
1341
- where Scalar : Differentiable & FloatingPoint
1342
- )
1320
+ @differentiable ( wrt: self where Scalar : Differentiable & FloatingPoint)
1343
1321
func sum( alongAxes axes: Int32 ... ) -> Tensor {
1344
1322
return sum ( alongAxes: axes)
1345
1323
}
1346
1324
1325
+ /// Returns the variance along the specified axes. The reduced dimensions are
1326
+ /// retained with value 1. Does not apply Bessel's correction.
1327
+ /// - Parameter axes: The dimensions to reduce.
1328
+ /// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1329
+ @inlinable @inline ( __always)
1330
+ @differentiable ( wrt: self where Scalar : Differentiable & FloatingPoint)
1331
+ func variance( alongAxes axes: Int32 ... ) -> Tensor {
1332
+ return variance ( alongAxes: axes)
1333
+ }
1334
+
1335
+ /// Returns the variance along the specified axes. The reduced dimensions are
1336
+ /// retained with value 1. Does not apply Bessel's correction.
1337
+ /// - Parameter axes: The dimensions to reduce.
1338
+ /// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1339
+ @inlinable @inline ( __always)
1340
+ @differentiable ( wrt: self where Scalar : Differentiable & FloatingPoint)
1341
+ func variance( alongAxes axes: [ Int32 ] ) -> Tensor {
1342
+ let mean = self . mean ( alongAxes: axes)
1343
+ let squaredDiff = ( self - mean) . squared ( )
1344
+ return squaredDiff. mean ( alongAxes: axes)
1345
+ }
1346
+
1347
1347
/// Returns the product along the specified axes. The reduced dimensions are
1348
1348
/// retained with value 1.
1349
1349
/// - Parameter axes: The dimensions to reduce.
0 commit comments