Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type family LayerNormImplF (reverseNormalizedDims :: [Dim (Name Symbol) (Size Nat)]) (reverseInputDims :: [Dim (Name Symbol) (Size Nat)]) :: [Dim (Name Symbol) (Size Nat)] where ...
- type LayerNormShapeErrorMessage = "Cannot apply the layer norm. " % "The normalized shape exceeds the input shape."
- type family LayerNormWithBiasF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (biasShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: Shape [Dim (Name Symbol) (Size Nat)] where ...
- layerNormWithBias :: forall gradient gradient' gradient'' layout layout' layout'' device device' device'' dataType dataType' dataType'' shape shape' shape''. SGetShape shape => Tensor gradient layout device dataType shape -> Tensor gradient' layout' device' dataType' shape' -> Double -> Tensor gradient'' layout'' device'' dataType'' shape'' -> Tensor (gradient' <|> (gradient' <|> gradient'')) (layout <+> (layout' <+> layout'')) (device <+> (device' <+> device'')) (dataType <+> (dataType' <+> dataType'')) (LayerNormWithBiasF shape shape' shape'')
- type family LayerNormWithoutBiasF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: Shape [Dim (Name Symbol) (Size Nat)] where ...
- type family LayerNormWithoutBiasSelectDimsF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: SelectDims [By Symbol Nat] where ...
- type family LayerNormWithoutBiasBysF (weightDims :: [Dim (Name Symbol) (Size Nat)]) (inputDims :: [Dim (Name Symbol) (Size Nat)]) (inputDimsLength :: Nat) (counter :: Nat) :: [By Symbol Nat] where ...
- layerNormWithoutBias :: forall gradient layout device dataType shape gradient' layout' device' dataType' shape'. (SGetShape shape, SGetShape shape') => Tensor gradient layout device dataType shape -> Double -> Tensor gradient' layout' device' dataType' shape' -> Tensor (gradient <|> gradient') (layout <+> layout') (device <+> device') (dataType <+> dataType') (LayerNormWithoutBiasF shape shape')
Documentation
type family LayerNormImplF (reverseNormalizedDims :: [Dim (Name Symbol) (Size Nat)]) (reverseInputDims :: [Dim (Name Symbol) (Size Nat)]) :: [Dim (Name Symbol) (Size Nat)] where ... Source #
LayerNormImplF '[] reverseInputDims = reverseInputDims | |
LayerNormImplF (normalizedDim ': reverseNormalizedDims) (inputDim ': reverseInputDims) = (normalizedDim <+> inputDim) ': LayerNormImplF reverseNormalizedDims reverseInputDims | |
LayerNormImplF _ '[] = TypeError LayerNormShapeErrorMessage |
type LayerNormShapeErrorMessage = "Cannot apply the layer norm. " % "The normalized shape exceeds the input shape." Source #
type family LayerNormWithBiasF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (biasShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: Shape [Dim (Name Symbol) (Size Nat)] where ... Source #
LayerNormWithBiasF 'UncheckedShape _ _ = 'UncheckedShape | |
LayerNormWithBiasF _ 'UncheckedShape _ = 'UncheckedShape | |
LayerNormWithBiasF _ _ 'UncheckedShape = 'UncheckedShape | |
LayerNormWithBiasF ('Shape weightDims) ('Shape biasDims) ('Shape inputDims) = 'Shape (Reverse (LayerNormImplF (Reverse (weightDims <+> biasDims)) (Reverse inputDims))) |
:: forall gradient gradient' gradient'' layout layout' layout'' device device' device'' dataType dataType' dataType'' shape shape' shape''. SGetShape shape | |
=> Tensor gradient layout device dataType shape | weight |
-> Tensor gradient' layout' device' dataType' shape' | bias |
-> Double | eps |
-> Tensor gradient'' layout'' device'' dataType'' shape'' | input |
-> Tensor (gradient' <|> (gradient' <|> gradient'')) (layout <+> (layout' <+> layout'')) (device <+> (device' <+> device'')) (dataType <+> (dataType' <+> dataType'')) (LayerNormWithBiasF shape shape' shape'') | output |
type family LayerNormWithoutBiasF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: Shape [Dim (Name Symbol) (Size Nat)] where ... Source #
LayerNormWithoutBiasF 'UncheckedShape _ = 'UncheckedShape | |
LayerNormWithoutBiasF _ 'UncheckedShape = 'UncheckedShape | |
LayerNormWithoutBiasF ('Shape weightDims) ('Shape inputDims) = 'Shape (Reverse (LayerNormImplF (Reverse weightDims) (Reverse inputDims))) |
type family LayerNormWithoutBiasSelectDimsF (weightShape :: Shape [Dim (Name Symbol) (Size Nat)]) (inputShape :: Shape [Dim (Name Symbol) (Size Nat)]) :: SelectDims [By Symbol Nat] where ... Source #
LayerNormWithoutBiasSelectDimsF 'UncheckedShape _ = 'UncheckedSelectDims | |
LayerNormWithoutBiasSelectDimsF _ 'UncheckedShape = 'UncheckedSelectDims | |
LayerNormWithoutBiasSelectDimsF ('Shape weightDims) ('Shape inputDims) = 'SelectDims (LayerNormWithoutBiasBysF weightDims inputDims (Length inputDims) 1) |
type family LayerNormWithoutBiasBysF (weightDims :: [Dim (Name Symbol) (Size Nat)]) (inputDims :: [Dim (Name Symbol) (Size Nat)]) (inputDimsLength :: Nat) (counter :: Nat) :: [By Symbol Nat] where ... Source #
LayerNormWithoutBiasBysF '[] _ _ _ = '[] | |
LayerNormWithoutBiasBysF (_ ': weightDims) (_ ': inputDims) inputDimsLength counter = 'ByIndex (inputDimsLength - counter) ': LayerNormWithoutBiasBysF weightDims inputDims inputDimsLength (counter + 1) | |
LayerNormWithoutBiasBysF _ '[] inputDimsLength counter = TypeError ("Cannot apply the layer norm." % ("The provided weight tensor has more dimensions than the input tensor," % ("" % (((" '" <> counter) <> "'") % ("" % ("and" % ("" % (((" '" <> inputDimsLength) <> "',") % ("" % "respectively."))))))))) |
:: forall gradient layout device dataType shape gradient' layout' device' dataType' shape'. (SGetShape shape, SGetShape shape') | |
=> Tensor gradient layout device dataType shape | weight |
-> Double | eps |
-> Tensor gradient' layout' device' dataType' shape' | input |
-> Tensor (gradient <|> gradient') (layout <+> layout') (device <+> device') (dataType <+> dataType') (LayerNormWithoutBiasF shape shape') | output |
T5-style layer norm