Safe Haskell | None |
---|---|
Language | Haskell2010 |
Torch.HList
Synopsis
- type family ListLength (xs :: [k]) :: Nat where ...
- data family HList (xs :: [k])
- pattern (:.) :: x -> HList xs -> HList (x ': xs)
- class Apply f a b where
- apply :: f -> a -> b
- class Apply' f a b | f a -> b where
- apply' :: f -> a -> b
- data AFst = AFst
- data ASnd = ASnd
- class HMap f (xs :: [k]) (ys :: [k]) where
- class HMap' f (xs :: [k]) (ys :: [k]) | f xs -> ys where
- class HMapM (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) where
- class HMapM' (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) | f xs -> ys where
- class Applicative f => HSequence (f :: Type -> Type) (xs :: [k]) (ys :: [k]) | xs -> ys, ys f -> xs where
- class HFoldr f acc (xs :: [k]) res | f acc xs -> res where
- class HFoldrM (m :: k -> Type) f acc (xs :: [k1]) (res :: k) | m f acc xs -> res where
- data HNothing = HNothing
- newtype HJust x = HJust x
- class HUnfold f res (xs :: [k]) where
- type family HUnfoldRes s (xs :: [Type]) where ...
- hunfoldr :: forall f res (xs :: [Type]) a. (Apply f a res, HUnfold f res xs, res ~ HUnfoldRes a xs) => f -> a -> HList xs
- class HUnfoldM (m :: Type -> Type) f res (xs :: [k]) where
- hunfoldrM' :: f -> res -> m (HList xs)
- type family HUnfoldMRes (m :: Type -> k) s (xs :: [Type]) :: k where ...
- hunfoldrM :: forall m f res (xs :: [Type]) a. (HUnfoldM m f res xs, Apply f a res, res ~ HUnfoldMRes m a xs) => f -> a -> m (HList xs)
- type HReplicate (n :: Nat) e = HReplicateFD n e (HReplicateR n e)
- hreplicate :: forall (n :: Nat) e. HReplicate n e => e -> HList (HReplicateR n e)
- class HReplicateFD (n :: Nat) e (es :: [Type]) | n e -> es where
- hreplicateFD :: e -> HList es
- type family HReplicateR (n :: Nat) (e :: a) :: [a] where ...
- type HConcat (xs :: [Type]) = HConcatFD xs (HConcatR xs)
- hconcat :: forall (xs :: [Type]). HConcat xs => HList xs -> HList (HConcatR xs)
- type family HConcatR (a :: [Type]) :: [Type]
- type family UnHList a :: [Type]
- class HConcatFD (xxs :: [k]) (xs :: [k]) | xxs -> xs where
- type HAppend (as :: [k]) (bs :: [k]) = HAppendFD as bs (as ++ bs)
- happend :: forall {k} (as :: [k]) (bs :: [k]). HAppend as bs => HList as -> HList bs -> HList (as ++ bs)
- hunappend :: forall {k} (cs :: [k]) (as :: [k]) (bs :: [k]). (cs ~ (as ++ bs), HAppend as bs) => HList cs -> (HList as, HList bs)
- class HAppendFD (a :: [k]) (b :: [k]) (ab :: [k]) | a b -> ab, a ab -> b where
- type family (as :: [k]) ++ (bs :: [k]) :: [k] where ...
- class HZip (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs, zs -> xs ys where
- class HZip' (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs where
- data HZipF = HZipF
- htranspose :: forall (acc :: [Type]) (xs :: [Type]) (xxs :: [Type]) res. (HReplicateFD (ListLength xs) (HList ('[] :: [Type])) acc, HFoldr HZipF (HList acc) (HList xs ': xxs) res) => HList (HList xs ': xxs) -> res
- class HZipWith f (xs :: [k]) (ys :: [k]) (zs :: [k]) | f xs ys -> zs where
- class HZipWithM (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) (zs :: [k]) | f xs ys -> zs where
- class HZip3 (as :: [k]) (bs :: [k]) (cs :: [k]) (ds :: [k]) | as bs cs -> ds, ds -> as bs cs where
- class HZipWith3 f (as :: [k]) (bs :: [k]) (cs :: [k]) (ds :: [k]) | f as bs cs -> ds where
- class HCartesianProduct (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs where
- class HAttach x (ys :: [k]) (zs :: [k]) | x ys -> zs where
Documentation
type family ListLength (xs :: [k]) :: Nat where ... Source #
Equations
ListLength ('[] :: [k]) = 0 | |
ListLength (_h ': t :: [k]) = 1 + ListLength t |
data family HList (xs :: [k]) Source #
Instances
HasToDevice device' device (HList xs) (HList ys) => ReduceGradients device' '[device] ('[HList xs] :: [Type]) (ys :: [k]) Source # | |||||
Defined in Torch.Typed.NN.DataParallel | |||||
(HasToDevice device' device (HList xs) (HList ys), ReduceGradients device' devices xxs ys, HZipWith SumF ys ys ys, 1 <= ListLength xxs) => ReduceGradients device' (device ': devices) (HList xs ': xxs :: [Type]) (ys :: [k]) Source # | |||||
Defined in Torch.Typed.NN.DataParallel | |||||
(HasToDevice device' device x x', HasToDevice device' device (HList xs) (HList xs')) => HasToDevice device' device (HList (x ': xs)) (HList (x' ': xs')) Source # | |||||
HasToDevice device' device (HList ('[] :: [Type])) (HList ('[] :: [Type])) Source # | |||||
(HasGrad (HList parameters) (HList gradients), Castable (HList gradients) [ATenTensor]) => Apply' GradConcurrentlyF (HList parameters, Loss device dtype) (Concurrently (HList gradients)) Source # | |||||
Defined in Torch.Typed.NN.DataParallel Methods apply' :: GradConcurrentlyF -> (HList parameters, Loss device dtype) -> Concurrently (HList gradients) Source # | |||||
(HConcatFD as bs, HAppendFD a bs cs) => HConcatFD (HList a ': as :: [Type]) (cs :: [Type]) Source # | |||||
(HList (x ': y) ~ z, HZip' xs ys zs) => HZip' (x ': xs :: [Type]) (HList y ': ys :: [Type]) (z ': zs :: [Type]) Source # | |||||
(IsList (Maybe (HList (a ': as))), a ~ Item (Maybe (HList (a ': as)))) => IsList (Maybe (HList (a ': (a ': as)))) Source # | |||||
Defined in Torch.HList Associated Types
| |||||
IsList (Maybe (HList '[a])) Source # | |||||
Defined in Torch.HList Associated Types
| |||||
(Monoid a, Monoid (HList as)) => Monoid (HList (a ': as)) Source # | |||||
Monoid (HList ('[] :: [k])) Source # | |||||
(Semigroup a, Semigroup (HList as)) => Semigroup (HList (a ': as)) Source # | |||||
Semigroup (HList ('[] :: [k])) Source # | |||||
(Show e, Show (HList l)) => Show (HList (e ': l)) Source # | |||||
Show (HList ('[] :: [k])) Source # | |||||
(Eq x, Eq (HList xs)) => Eq (HList (x ': xs)) Source # | |||||
Eq (HList ('[] :: [k])) Source # | |||||
(Parameterized f, Parameterized (HList fs), HAppendFD (Parameters f) (Parameters (HList fs)) (Parameters f ++ Parameters (HList fs))) => Parameterized (HList (f ': fs)) Source # | |||||
Defined in Torch.Typed.Parameter Associated Types
Methods flattenParameters :: HList (f ': fs) -> HList (Parameters (HList (f ': fs))) Source # replaceParameters :: HList (f ': fs) -> HList (Parameters (HList (f ': fs))) -> HList (f ': fs) Source # | |||||
Parameterized (HList ('[] :: [k])) Source # | |||||
Defined in Torch.Typed.Parameter Associated Types
Methods flattenParameters :: HList ('[] :: [k]) -> HList (Parameters (HList ('[] :: [k]))) Source # replaceParameters :: HList ('[] :: [k]) -> HList (Parameters (HList ('[] :: [k]))) -> HList ('[] :: [k]) Source # | |||||
(HFoldrM IO TensorListFold [ATenTensor] l [ATenTensor], Apply TensorListUnfold [ATenTensor] res, HUnfoldM IO TensorListUnfold res l, res ~ HUnfoldMRes IO [ATenTensor] l) => Castable (HList l) [ATenTensor] | |||||
Defined in Torch.Typed.Tensor Methods cast :: HList l -> ([ATenTensor] -> IO r) -> IO r uncast :: [ATenTensor] -> (HList l -> IO r) -> IO r | |||||
Castable (HList l) [ATenTensor] => Castable (HList l) (ForeignPtr TensorList) | |||||
Defined in Torch.Typed.Tensor Methods cast :: HList l -> (ForeignPtr TensorList -> IO r) -> IO r uncast :: ForeignPtr TensorList -> (HList l -> IO r) -> IO r | |||||
(Randomizable xSpec x, Randomizable (HList xsSpec) (HList xs)) => Randomizable (HList (xSpec ': xsSpec)) (HList (x ': xs)) Source # | |||||
Randomizable (HList ('[] :: [Type])) (HList ('[] :: [Type])) Source # | |||||
(HasGrad a b, HasGrad (HList as) (HList bs), Castable (HList (b ': bs)) [ATenTensor]) => HasGrad (HList (a ': as)) (HList (b ': bs)) Source # | |||||
Defined in Torch.Typed.Autograd | |||||
HasGrad (HList ('[] :: [Type])) (HList ('[] :: [Type])) Source # | |||||
data HList ('[] :: [k]) Source # | |||||
Defined in Torch.HList | |||||
newtype HList (x ': xs :: [Type]) Source # | |||||
Defined in Torch.HList | |||||
type Item (Maybe (HList (a ': (a ': as)))) Source # | |||||
Defined in Torch.HList | |||||
type Item (Maybe (HList '[a])) Source # | |||||
Defined in Torch.HList | |||||
type UnHList (HList a) Source # | |||||
Defined in Torch.HList | |||||
type Parameters (HList (f ': fs)) Source # | |||||
Defined in Torch.Typed.Parameter | |||||
type Parameters (HList ('[] :: [k])) Source # | |||||
Defined in Torch.Typed.Parameter |
class Apply f a b where Source #
Instances
Castable x ATenTensor => Apply TensorListUnfold [ATenTensor] (IO (HJust (x, [ATenTensor]))) Source # | |
Defined in Torch.Typed.Tensor Methods apply :: TensorListUnfold -> [ATenTensor] -> IO (HJust (x, [ATenTensor])) Source # | |
Apply TensorListUnfold [ATenTensor] (IO HNothing) Source # | |
Defined in Torch.Typed.Tensor Methods apply :: TensorListUnfold -> [ATenTensor] -> IO HNothing Source # |
class Apply' f a b | f a -> b where Source #
Stronger version of Apply
that allows for better inference of the return type
Instances
(HZip' a b c, x ~ (HList a, HList b), y ~ HList c) => Apply' HZipF x y Source # | |
Defined in Torch.HList | |
(momentum ~ Tensor device dtype shape, KnownDevice device, KnownDType dtype, shape ~ Reverse (Reverse shape), BasicArithmeticDTypeIsValid device dtype) => Apply' AdamBiasAdjustment momentum momentum Source # | bias adjustment |
Defined in Torch.Typed.Optim Methods apply' :: AdamBiasAdjustment -> momentum -> momentum Source # | |
(parameter ~ Parameter device dtype shape, momentum ~ Tensor device dtype shape, TensorOptions shape dtype device) => Apply' ZerosLike parameter momentum Source # | |
Defined in Torch.Typed.Optim | |
Apply' AFst (a, b) a Source # | |
Defined in Torch.HList | |
Apply' ASnd (a, b) b Source # | |
Defined in Torch.HList | |
Num y => Apply' SumF (y, y) y Source # | |
Defined in Torch.Typed.NN.DataParallel | |
(gradient ~ Tensor device dtype shape, momentum1 ~ Tensor device dtype shape, KnownDevice device) => Apply' AdamMomentum1Update (momentum1, gradient) momentum1 Source # | decaying average of the first momenta |
Defined in Torch.Typed.Optim Methods apply' :: AdamMomentum1Update -> (momentum1, gradient) -> momentum1 Source # | |
(gradient ~ Tensor device dtype shape, momentum2 ~ Tensor device dtype shape, shape ~ Broadcast shape shape, KnownDevice device, BasicArithmeticDTypeIsValid device dtype) => Apply' AdamMomentum2Update (momentum2, gradient) momentum2 Source # | decaying average of the second momenta |
Defined in Torch.Typed.Optim Methods apply' :: AdamMomentum2Update -> (momentum2, gradient) -> momentum2 Source # | |
HasForward model input output => Apply' ForwardConcurrentlyF (model, input) (Concurrently output) Source # | |
Defined in Torch.Typed.NN.DataParallel Methods apply' :: ForwardConcurrentlyF -> (model, input) -> Concurrently output Source # | |
(HasGrad (HList parameters) (HList gradients), Castable (HList gradients) [ATenTensor]) => Apply' GradConcurrentlyF (HList parameters, Loss device dtype) (Concurrently (HList gradients)) Source # | |
Defined in Torch.Typed.NN.DataParallel Methods apply' :: GradConcurrentlyF -> (HList parameters, Loss device dtype) -> Concurrently (HList gradients) Source # | |
Castable x ATenTensor => Apply' TensorListFold (x, IO [ATenTensor]) (IO [ATenTensor]) Source # | |
Defined in Torch.Typed.Tensor Methods apply' :: TensorListFold -> (x, IO [ATenTensor]) -> IO [ATenTensor] Source # | |
Apply' MakeIndependent (Tensor device dtype shape) (IO (Parameter device dtype shape)) Source # | |
Defined in Torch.Typed.Parameter | |
Apply' ToParameter (Tensor dev dtype shape) (Parameter dev dtype shape) Source # | |
Defined in Torch.Typed.Optim.CppOptim | |
Apply' ToDependent (Parameter device dtype shape) (Tensor device dtype shape) Source # | |
Defined in Torch.Typed.Parameter | |
(parameter ~ Tensor device dtype shape, gradient ~ Tensor device dtype shape, shape ~ Broadcast ('[] :: [Nat]) shape, BasicArithmeticDTypeIsValid device dtype, KnownDevice device) => Apply' (GDStep device dtype) (parameter, gradient) parameter Source # | |
Defined in Torch.Typed.Optim | |
(parameter ~ Tensor device dtype shape, momentum ~ Tensor device dtype shape, shape ~ Broadcast ('[] :: [Nat]) shape, KnownDevice device, BasicArithmeticDTypeIsValid device dtype, StandardFloatingPointDTypeValidation device dtype) => Apply' (AdamParameterUpdate device dtype) (parameter, momentum, momentum) parameter Source # | parameter update |
Defined in Torch.Typed.Optim Methods apply' :: AdamParameterUpdate device dtype -> (parameter, momentum, momentum) -> parameter Source # | |
(parameter ~ Tensor device dtype shape, gradient ~ Tensor device dtype shape, momentum ~ Tensor device dtype shape, shape ~ Broadcast ('[] :: [Nat]) shape, KnownDevice device, BasicArithmeticDTypeIsValid device dtype) => Apply' (GDMStep device dtype) (parameter, gradient, momentum) (parameter, momentum) Source # | |
Defined in Torch.Typed.Optim | |
(1 <= numHeads, embedDim ~ (headDim * numHeads), All KnownNat '[embedDim, numHeads, seqLen, batchSize, headDim], IsSuffixOf '[embedDim] '[batchSize, seqLen, embedDim], KnownDType dtype, StandardFloatingPointDTypeValidation device dtype, MatMulDTypeIsValid device dtype, BasicArithmeticDTypeIsValid device dtype, dtype ~ SumDType dtype, SumDTypeIsValid device dtype, KnownDevice device) => Apply' (FoldLayers batchSize seqLen dtype device) (TransformerLayer embedDim embedDim embedDim numHeads ffnDim dtype device, IO (Tensor device dtype '[batchSize, seqLen, embedDim])) (IO (Tensor device dtype '[batchSize, seqLen, embedDim])) Source # | |
Defined in Torch.Typed.NN.Transformer Methods apply' :: FoldLayers batchSize seqLen dtype device -> (TransformerLayer embedDim embedDim embedDim numHeads ffnDim dtype device, IO (Tensor device dtype '[batchSize, seqLen, embedDim])) -> IO (Tensor device dtype '[batchSize, seqLen, embedDim]) Source # |
Constructors
AFst |
Constructors
ASnd |
class HMap' f (xs :: [k]) (ys :: [k]) | f xs -> ys where Source #
class HMapM (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) where Source #
class HMapM' (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) | f xs -> ys where Source #
class Applicative f => HSequence (f :: Type -> Type) (xs :: [k]) (ys :: [k]) | xs -> ys, ys f -> xs where Source #
class HFoldr f acc (xs :: [k]) res | f acc xs -> res where Source #
class HFoldrM (m :: k -> Type) f acc (xs :: [k1]) (res :: k) | m f acc xs -> res where Source #
Constructors
HNothing |
Instances
HUnfold f HNothing ('[] :: [k]) Source # | |
Monad m => HUnfoldM m f (m HNothing) ('[] :: [k]) Source # | |
Defined in Torch.HList Methods hunfoldrM' :: f -> m HNothing -> m (HList ('[] :: [k])) Source # | |
Apply TensorListUnfold [ATenTensor] (IO HNothing) Source # | |
Defined in Torch.Typed.Tensor Methods apply :: TensorListUnfold -> [ATenTensor] -> IO HNothing Source # |
Constructors
HJust x |
Instances
(Monad m, HUnfoldM m f res xs, Apply f s res, res ~ HUnfoldMRes m s xs) => HUnfoldM m f (m (HJust (x, s))) (x ': xs :: [Type]) Source # | |
Defined in Torch.HList Methods hunfoldrM' :: f -> m (HJust (x, s)) -> m (HList (x ': xs)) Source # | |
(Apply f s res, HUnfold f res xs, res ~ HUnfoldRes s xs) => HUnfold f (HJust (x, s)) (x ': xs :: [Type]) Source # | |
Castable x ATenTensor => Apply TensorListUnfold [ATenTensor] (IO (HJust (x, [ATenTensor]))) Source # | |
Defined in Torch.Typed.Tensor Methods apply :: TensorListUnfold -> [ATenTensor] -> IO (HJust (x, [ATenTensor])) Source # |
type family HUnfoldRes s (xs :: [Type]) where ... Source #
Equations
HUnfoldRes _1 ('[] :: [Type]) = HNothing | |
HUnfoldRes s (x ': _1) = HJust (x, s) |
hunfoldr :: forall f res (xs :: [Type]) a. (Apply f a res, HUnfold f res xs, res ~ HUnfoldRes a xs) => f -> a -> HList xs Source #
class HUnfoldM (m :: Type -> Type) f res (xs :: [k]) where Source #
Methods
hunfoldrM' :: f -> res -> m (HList xs) Source #
Instances
Monad m => HUnfoldM m f (m HNothing) ('[] :: [k]) Source # | |
Defined in Torch.HList Methods hunfoldrM' :: f -> m HNothing -> m (HList ('[] :: [k])) Source # | |
(Monad m, HUnfoldM m f res xs, Apply f s res, res ~ HUnfoldMRes m s xs) => HUnfoldM m f (m (HJust (x, s))) (x ': xs :: [Type]) Source # | |
Defined in Torch.HList Methods hunfoldrM' :: f -> m (HJust (x, s)) -> m (HList (x ': xs)) Source # |
type family HUnfoldMRes (m :: Type -> k) s (xs :: [Type]) :: k where ... Source #
Equations
HUnfoldMRes (m :: Type -> k) _1 ('[] :: [Type]) = m HNothing | |
HUnfoldMRes (m :: Type -> k) s (x ': _1) = m (HJust (x, s)) |
hunfoldrM :: forall m f res (xs :: [Type]) a. (HUnfoldM m f res xs, Apply f a res, res ~ HUnfoldMRes m a xs) => f -> a -> m (HList xs) Source #
type HReplicate (n :: Nat) e = HReplicateFD n e (HReplicateR n e) Source #
hreplicate :: forall (n :: Nat) e. HReplicate n e => e -> HList (HReplicateR n e) Source #
class HReplicateFD (n :: Nat) e (es :: [Type]) | n e -> es where Source #
Methods
hreplicateFD :: e -> HList es Source #
Instances
(HReplicateFD (n - 1) e es, es' ~ (e ': es), 1 <= n) => HReplicateFD n e es' Source # | |
Defined in Torch.HList Methods hreplicateFD :: e -> HList es' Source # | |
HReplicateFD 0 e ('[] :: [Type]) Source # | |
Defined in Torch.HList Methods hreplicateFD :: e -> HList ('[] :: [Type]) Source # |
type family HReplicateR (n :: Nat) (e :: a) :: [a] where ... Source #
Equations
HReplicateR 0 (_1 :: a) = '[] :: [a] | |
HReplicateR n (e :: a) = e ': HReplicateR (n - 1) e |
class HConcatFD (xxs :: [k]) (xs :: [k]) | xxs -> xs where Source #
happend :: forall {k} (as :: [k]) (bs :: [k]). HAppend as bs => HList as -> HList bs -> HList (as ++ bs) Source #
hunappend :: forall {k} (cs :: [k]) (as :: [k]) (bs :: [k]). (cs ~ (as ++ bs), HAppend as bs) => HList cs -> (HList as, HList bs) Source #
class HAppendFD (a :: [k]) (b :: [k]) (ab :: [k]) | a b -> ab, a ab -> b where Source #
class HZip (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs, zs -> xs ys where Source #
class HZip' (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs where Source #
Constructors
HZipF |
htranspose :: forall (acc :: [Type]) (xs :: [Type]) (xxs :: [Type]) res. (HReplicateFD (ListLength xs) (HList ('[] :: [Type])) acc, HFoldr HZipF (HList acc) (HList xs ': xxs) res) => HList (HList xs ': xxs) -> res Source #
class HZipWith f (xs :: [k]) (ys :: [k]) (zs :: [k]) | f xs ys -> zs where Source #
class HZipWithM (m :: Type -> Type) f (xs :: [k]) (ys :: [k]) (zs :: [k]) | f xs ys -> zs where Source #
class HZip3 (as :: [k]) (bs :: [k]) (cs :: [k]) (ds :: [k]) | as bs cs -> ds, ds -> as bs cs where Source #
Methods
hzip3 :: HList as -> HList bs -> HList cs -> HList ds Source #
hunzip3 :: HList ds -> (HList as, HList bs, HList cs) Source #
class HZipWith3 f (as :: [k]) (bs :: [k]) (cs :: [k]) (ds :: [k]) | f as bs cs -> ds where Source #
class HCartesianProduct (xs :: [k]) (ys :: [k]) (zs :: [k]) | xs ys -> zs where Source #
Instances
HCartesianProduct ('[] :: [k]) (ys :: [k]) ('[] :: [k]) Source # | |
(HCartesianProduct xs ys zs, HAttach x ys xys, HAppendFD xys zs zs') => HCartesianProduct (x ': xs :: [Type]) (ys :: [Type]) (zs' :: [Type]) Source # | |