MCPcopy
hub / github.com/tinygrad/tinygrad / LpNormalization

Function LpNormalization

tinygrad/nn/onnx.py:949–950  ·  view source on GitHub ↗
(x:Tensor, axis:int=-1, p:int=2)

Source from the content-addressed store, hash-verified

947 return (x - x.mean(axis, keepdim=True)) / (x.std(axis, keepdim=True, correction=0) + 1e-9)
948
949 def LpNormalization(x:Tensor, axis:int=-1, p:int=2):
950 return x / (x.abs().sum(axis, keepdim=True) if p == 1 else x.square().sum(axis, keepdim=True).sqrt())
951
952 def OneHot(indices:Tensor, depth:float|int|list[int|float], values:Tensor, axis:int=-1):
953 # Scalar or Rank 1 tensor containing exactly one element

Callers

nothing calls this directly

Calls 4

sumMethod · 0.80
absMethod · 0.80
sqrtMethod · 0.80
squareMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…