MCPcopy Create free account
hub / github.com/ml-explore/mlx / l2_norm

Function l2_norm

mlx/linalg.cpp:43–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43inline array l2_norm(
44 const array& a,
45 const std::vector<int>& axis,
46 bool keepdims,
47 StreamOrDevice s) {
48 if (issubdtype(a.dtype(), complexfloating)) {
49 return sqrt(sum(abs(a, s) * abs(a, s), axis, keepdims, s), s);
50 } else {
51 return sqrt(sum(square(a, s), axis, keepdims, s), s);
52 }
53}
54
55inline array vector_norm(
56 const array& a,

Callers 3

vector_normFunction · 0.85
matrix_normFunction · 0.85
normFunction · 0.85

Calls 5

issubdtypeFunction · 0.85
sqrtFunction · 0.85
absFunction · 0.85
squareFunction · 0.85
sumFunction · 0.70

Tested by

no test coverage detected