@@ -1316,63 +1316,7 @@ def complex_from_polar(abs, angle):
1316
1316
"""Return complex-valued tensor from polar coordinate specification."""
1317
1317
1318
1318
1319
- class Mean (FixedOpCAReduce ):
1320
- __props__ = ("axis" ,)
1321
- nfunc_spec = ("mean" , 1 , 1 )
1322
-
1323
- def __init__ (self , axis = None ):
1324
- super ().__init__ (ps .mean , axis )
1325
- assert self .axis is None or len (self .axis ) == 1
1326
-
1327
- def __str__ (self ):
1328
- if self .axis is not None :
1329
- args = ", " .join (str (x ) for x in self .axis )
1330
- return f"Mean{{{ args } }}"
1331
- else :
1332
- return "Mean"
1333
-
1334
- def _output_dtype (self , idtype ):
1335
- # we want to protect against overflow
1336
- return "float64"
1337
-
1338
- def perform (self , node , inp , out ):
1339
- (input ,) = inp
1340
- (output ,) = out
1341
- if self .axis is None :
1342
- axis = None
1343
- else :
1344
- axis = self .axis [0 ]
1345
- # numpy.asarray is needed as otherwise we can end up with a
1346
- # numpy scalar.
1347
- output [0 ] = np .asarray (np .mean (input , dtype = "float64" , axis = axis ))
1348
-
1349
- def c_code (self , node , name , inames , onames , sub ):
1350
- ret = super ().c_code (node , name , inames , onames , sub )
1351
-
1352
- if self .axis is not None :
1353
- return ret
1354
-
1355
- # TODO: c_code perform support only axis is None
1356
- return (
1357
- ret
1358
- + f"""
1359
- *((double *)PyArray_DATA({ onames [0 ]} )) /= PyArray_SIZE({ inames [0 ]} );
1360
- """
1361
- )
1362
-
1363
- def clone (self , ** kwargs ):
1364
- axis = kwargs .get ("axis" , self .axis )
1365
- return type (self )(axis = axis )
1366
-
1367
-
1368
- # TODO: implement the grad. When done and tested, you can make this the default
1369
- # version.
1370
- # def grad(self, (x,), (gout,)):
1371
- # import pdb;pdb.set_trace()
1372
- # return grad(mean(x, self.axis, op=False),[x])
1373
-
1374
-
1375
- def mean (input , axis = None , dtype = None , op = False , keepdims = False , acc_dtype = None ):
1319
+ def mean (input , axis = None , dtype = None , keepdims = False , acc_dtype = None ):
1376
1320
"""
1377
1321
Computes the mean value along the given axis(es) of a tensor `input`.
1378
1322
@@ -1397,25 +1341,6 @@ def mean(input, axis=None, dtype=None, op=False, keepdims=False, acc_dtype=None)
1397
1341
be in a float type). If None, then we use the same rules as `sum()`.
1398
1342
"""
1399
1343
input = as_tensor_variable (input )
1400
- if op :
1401
- if dtype not in (None , "float64" ):
1402
- raise NotImplementedError (
1403
- "The Mean op does not support the dtype argument, "
1404
- "and will always use float64. If you want to specify "
1405
- "the dtype, call tensor.mean(..., op=False)." ,
1406
- dtype ,
1407
- )
1408
- if acc_dtype not in (None , "float64" ):
1409
- raise NotImplementedError (
1410
- "The Mean op does not support the acc_dtype argument, "
1411
- "and will always use float64. If you want to specify "
1412
- "acc_dtype, call tensor.mean(..., op=False)." ,
1413
- dtype ,
1414
- )
1415
- out = Mean (axis )(input )
1416
- if keepdims :
1417
- out = makeKeepDims (input , out , axis )
1418
- return out
1419
1344
1420
1345
if dtype is not None :
1421
1346
# The summation will be done with the specified dtype.
0 commit comments