MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _get_reduce_axis

Function _get_reduce_axis

python/paddle/tensor/math.py:190–210  ·  view source on GitHub ↗

Internal function for max, min, amax and amin. It computes the attribute reduce_all value based on axis.

(axis, x)

Source from the content-addressed store, hash-verified

188
189
190def _get_reduce_axis(axis, x):
191 """
192 Internal function for max, min, amax and amin.
193 It computes the attribute reduce_all value based on axis.
194 """
195 if axis is not None and not isinstance(axis, list):
196 if isinstance(axis, (tuple, range)):
197 axis = list(axis)
198 elif isinstance(axis, int):
199 axis = [axis]
200 else:
201 raise TypeError(
202 f"The type of axis must be int, list or tuple, but received {type(axis)}"
203 )
204 if axis is None:
205 axis = []
206 if axis == [] or len(axis) == len(x.shape):
207 reduce_all = True
208 else:
209 reduce_all = False
210 return reduce_all, axis
211
212
213def _get_reduce_axis_with_tensor(axis, x):

Callers 8

inf_normFunction · 0.85
vector_norm_axis_tupleFunction · 0.85
nuclear_normFunction · 0.85
p_matrix_normFunction · 0.85
mat_normFunction · 0.85
fro_normFunction · 0.85
svd_normFunction · 0.85

Calls 3

listFunction · 0.85
TypeErrorClass · 0.85
typeFunction · 0.50

Tested by

no test coverage detected