Idris2Doc : Data.Tensor.Tensor

Data.Tensor.Tensor

(source)

Reexports

importpublic Data.Vect
importpublic Data.Vect.Quantifiers
importpublic Data.Vect.Elem
importpublic Decidable.Equality
importpublic Data.Fin.Split
importpublic Data.Container.Base
importpublic Data.Container.Applicative
importpublic Data.Container.Base.Object.Instances as Cont
importpublic Data.Num
importpublic Data.Layout
importpublic Data.Tensor.Shape.Axis
importpublic Data.Tensor.Shape.Shape
importpublic Misc

Definitions

recordTensor : TensorShaperank->Type->Type
  Tensor is the core datatype of TensorType.
Implementation-wise, it's a wrapper around the extension of `Cont.Tensor`
to aid type inference, and to add the axis name functionality

Totality: total
Visibility: public export
Constructor: 
MkT : Ext (Tensor (contsshape)) a->Tensorshapea

Projection: 
.GetT : Tensorshapea->Ext (Tensor (contsshape)) a

Hints:
Absa=>AllCTensorMonoidshape=>Abs (Tensorshapea)
AllAlgebrashapea=>Algebra (Tensorshape) a
AllCTensorMonoidshape=>Applicative (Tensorshape)
AllDisplay2Dshapea=>TensorCubEvidenceshape=>Display2D (Tensorshapea)
AllEqshapea=>Eq (Tensorshapea)
Expa=>AllCTensorMonoidshape=>Exp (Tensorshapea)
AllCIsFoldableshape=>Foldable (Tensorshape)
Fractionala=>AllCTensorMonoidshape=>Fractional (Tensorshapea)
FromDoublea=>AllCTensorMonoidshape=>FromDouble (Tensorshapea)
Functor (Tensorshape)
Nega=>AllCTensorMonoidshape=>Neg (Tensorshapea)
Numa=>AllCTensorMonoidshape=>Num (Tensorshapea)
Randoma=>Applicative (Tensorshape) =>Traversable (Tensorshape) =>Random (Tensorshapea)
AllDisplay2Dshapea=>TensorCubEvidenceshape=>Show (Tensorshapea)
AllTraversableshape=>AllCIsFoldableshape=>Traversable (Tensorshape)
.GetT : Tensorshapea->Ext (Tensor (contsshape)) a
Visibility: public export
GetT : Tensorshapea->Ext (Tensor (contsshape)) a
Visibility: public export
.shape : (0_ : Tensorshapea) ->VectrankAxis
Visibility: public export
.axisNames : (0_ : Tensorshapea) ->VectrankAxisName
Visibility: public export
.sizes : (0_ : Tensorshapea) ->VectrankCont
Visibility: public export
.indexAxis : (0_ : Tensorshapea) -> (axisName : AxisName) ->ElemaxisNameshape=>Cont
Visibility: public export
.renameAxis : Tensorshapea-> (axisName : AxisName) -> (newAxisName : AxisName) ->ElemaxisNameshape=>Tensor (renameshapeaxisNamenewAxisName) a
Visibility: public export
.rename : Tensorshapea-> (axisIndex : Finrank) -> (newAxisName : AxisName) ->Tensor (renameshapeaxisIndexnewAxisName) a
Visibility: public export
BatchSize : Axis
Visibility: public export
extract : Tensor [] a->a
Visibility: public export
embed : a->Tensor [] a
Visibility: public export
fromExtensionComposition : composeExtensions (contsshape) a->Tensorshapea
  With the added data of the wrapper around (Ext (Tensor shape) a), this
effectively states a list version of the following isomorphism
Ext c . Ext d = Ext (c . d)

Visibility: public export
toExtensionComposition : Tensorshapea->composeExtensions (contsshape) a
Visibility: public export
extractTopExt : {auto{conArg:17957} : ConsistentWithccs} ->Tensor (c::cs) a->Ext (c.cont) (Tensorcsa)
  For this and the function below, the commented out definition is 'cleaner'
but it requires non-erased `c` and `cs`

Visibility: public export
embedTopExt : {auto{conArg:18019} : ConsistentWithccs} ->Ext (c.cont) (Tensorcsa) ->Tensor (c::cs) a
Visibility: public export
extToVector : Ext (c.cont) a->Tensor [c] a
  This is useful because container composition adds non-trivial data to the
vector type (i.e. `c >@ Scalar` is not equal to `c`)

Visibility: public export
vectorToExt : Tensor [c] a->Ext (c.cont) a
Visibility: public export
toNestedTensor : {auto{conArg:18211} : ConsistentWithccs} ->Tensor (c::cs) a->Tensor [c] (Tensorcsa)
Visibility: public export
fromNestedTensor : {auto{conArg:18266} : ConsistentWithccs} ->Tensor [c] (Tensorcsa) ->Tensor (c::cs) a
Visibility: public export
tensorMapFirstAxis : {autoccs : ConsistentWithccs} -> {autocds : ConsistentWithcds} -> (Tensorcsa->Tensordsa) ->Tensor (c::cs) a->Tensor (c::ds) a
  TODO generalise to function operating on an axis name instead of index

Visibility: public export
(<-$>) : {auto{conArg:18408} : ConsistentWithccs} -> {auto{conArg:18412} : ConsistentWithcds} -> (Tensorcsa->Tensordsa) ->Tensor (c::cs) a->Tensor (c::ds) a
  Is meant to look like infix map (i.e. `<$>`) with the added difference
that we keep the container on the left side untouched, hence the `<-$>`

Visibility: public export
Fixity Declaration: infixr operator, level 4
concreteTypeTensor : (shape : TensorShaperank) ->AllCIsConcreteshape=>Type->Type
Visibility: public export
concreteTypeFunctor : {auto{conArg:18521} : AllCIsConcreteshape} ->Functor (concreteTypeTensorshape)
Visibility: public export
concreteToExtensions : {auto{conArg:18565} : AllCIsConcreteshape} ->concreteTypeTensorshapea->composeExtensions (contsshape) a
Visibility: public export
extensionsToConcreteType : {auto{conArg:18632} : AllCIsConcreteshape} ->composeExtensions (contsshape) a->concreteTypeTensorshapea
Visibility: public export
toTensor : {auto{conArg:18693} : AllCIsConcreteshape} ->concreteTypeTensorshapea->Tensorshapea
Visibility: public export
fromTensor : {auto{conArg:18735} : AllCIsConcreteshape} ->Tensorshapea->concreteTypeTensorshapea
Visibility: public export
fromConcreteTy : {auto{conArg:18776} : AllCIsConcreteshape} ->concreteTypeTensorshapea->Tensorshapea
  Many containers have a `FromConcrete` instance, allowing them to easily
be converted to and from a (usually familiar) Idris type
This works with tensors defined as a fold over containers, but it requires
burdensome shape annotations everywhere
The decision was made to wrap that fold in `Tensor` as above, and then
(as this isn't a container anymore) provide equally named functions like
the ones `FromConcrete` provides. Idris' name resolution should be able to
detect which one needs to be used at call sites

Visibility: public export
toConcreteTy : {auto{conArg:18809} : AllCIsConcreteshape} ->Tensorshapea->concreteTypeTensorshapea
Visibility: public export
(>#) : {auto{conArg:18841} : AllCIsConcreteshape} ->concreteTypeTensorshapea->Tensorshapea
  Prefix operator for converting from a concrete type to a tensor
We read it as a map `>` going into the tensor `#`

Visibility: public export
Fixity Declarations:
prefix operator, level 0
prefix operator, level 0
(#>) : {auto{conArg:18874} : AllCIsConcreteshape} ->Tensorshapea->concreteTypeTensorshapea
  Prefix operator for converting from a tensor to concrete type
We read it as a map `>` going out of the tensor `#`

Visibility: public export
Fixity Declarations:
prefix operator, level 0
prefix operator, level 0
(>#>) : {auto{conArg:18912} : AllCIsConcreteshapeOld} -> {auto{conArg:18918} : AllCIsConcreteshapeNew} -> (TensorshapeOlda->TensorshapeNewb) ->concreteTypeTensorshapeOlda->concreteTypeTensorshapeNewb
Visibility: public export
Fixity Declaration: infixr operator, level 0
(#>#) : {auto{conArg:18984} : AllCIsConcreteshapeOld} -> {auto{conArg:18990} : AllCIsConcreteshapeNew} -> (concreteTypeTensorshapeOlda->concreteTypeTensorshapeNewb) ->TensorshapeOlda->TensorshapeNewb
Visibility: public export
Fixity Declaration: infixr operator, level 0
restructure : Tensor (contscs) =%>Tensor (contsds) ->tensorShapesConsistentcsds=>Tensorcsa->Tensordsa
  A wrapper around `extMap`
Allows us to define views, traversals and general reshaping

Visibility: public export
reshape : {auto{conArg:19110} : AllIsCubical (contsoldShape)} -> {auto{conArg:19117} : AllIsCubical (contsnewShape)} ->TensoroldShapea->size (contsoldShape) =size (contsnewShape) =>tensorShapesConsistentoldShapenewShape=>TensornewShapea
  Reshape is `restructure` for cubical tensors that leaves number of 
elements unchanged. This is currently by
1) flattening out the entire tensor into a vector
2) recast the type to be of the right shape
3) unflatten the vector into the right shape
Importantly, the content of tensors is never touched, only the shape is
manipulated

Visibility: public export
tensorReplicate : AllCTensorMonoidshape=>a->Tensorshapea
Visibility: public export
liftA2Tensor : AllCTensorMonoidshape=>Tensorshapea->Tensorshapeb->Tensorshape (a, b)
Visibility: public export
dataAllEq : TensorShaperank->Type->Type
Totality: total
Visibility: public export
Constructors:
Nil : Eqa=>AllEq [] a
Cons : Eq (fullOf (c.cont) (Tensorcsa)) => {autone : ConsistentWithccs} ->AllEq (c::cs) a

Hint: 
AllEqshapea=>Eq (Tensorshapea)
tensorEq : AllEqshapea=>Tensorshapea->Tensorshapea->Bool
Visibility: public export
interfacePosEq : InterfaceOnPositions (Tensor [Vectn]) Eq
Visibility: public export
join : SeqMonoid (i.cont) =>Tensor [i, i] a->Tensor [i] a
  Captures both "diagonal" operation for vector (Naperian containers) and
"concat"-like operation for lists

Visibility: public export
diagonal : IsNaperian (i.cont) =>Tensor [i, i] a->Tensor [i] a
  Alias for `join` for Naperian containers

Visibility: public export
codiagonal : Numa=>Tensor [i] a->Tensor [i, i] a
Visibility: public export
tDiagVect : Tensor [("i"~~>2), ("j"~~>2)] Double
Visibility: public export
tDiagList : Tensor [("i"~>List), ("j"~>List)] Double
Visibility: public export
dataAllAlgebra : TensorShaperank->Type->Type
  Unlike all other instantiations of 'AllX', `AllAlgebra` is not
stating that each container in an list has an algebra, but rather
'cumulatively'. For instance, `AllAlgebra [c, d] a` is not defined as
`Algebra c a` and `Algebra d a`, bur rather as `Algebra c (Algebra d a)`
and `Algebra d a`.

Totality: total
Visibility: public export
Constructors:
Nil : AllAlgebra [] a
Cons : Algebra (Ext (c.cont)) (Tensorcsa) =>AllAlgebracsa=> {auto{conArg:21042} : ConsistentWithccs} ->AllAlgebra (c::cs) a

Hint: 
AllAlgebrashapea=>Algebra (Tensorshape) a
reduceTensor : AllAlgebrashapea=>Tensorshapea->a
Visibility: public export
reduceFirstAxis : Algebra (Ext (s.cont)) (Tensorshapea) => {auto{conArg:21127} : ConsistentWithsshape} ->Tensor (s::shape) a->Tensorshapea
Visibility: public export
reduceSingleAxis : (toReduce : AxisName) -> {autouElem : UniqueElemtoReduceshape} ->Tensorshapea->AllCTensorMonoidshape=>Numa=>IsFinite (indexshapetoReduce) =>Tensor (removeAxistoReduceshape) a
  Reduces a tensor along an axis appearing only once in the shape
In the presence of multiple axes (at least in the Naperian case) we
first have to transpose them to the front, and then diagonalise.
Using `IsFinite` instead of `Algebra` because `IsFinite` allows us to
refer to only the container, instead of the underlying type `a`

Visibility: public export
tensorFoldr : AllCIsFoldableshape=> (a->acc->acc) ->acc->Tensorshapea->acc
Visibility: public export
allFoldableFromAllCubical : AllIsCubicalshape->AllCIsFoldableshape
Visibility: public export
dataAllTraversable : TensorShaperank->Type
Totality: total
Visibility: public export
Constructors:
Nil : AllTraversable []
Cons : Traversable (Ext (c.cont)) =>AllTraversablecs=> {auto{conArg:22070} : ConsistentWithccs} ->AllTraversable (c::cs)

Hint: 
AllTraversableshape=>AllCIsFoldableshape=>Traversable (Tensorshape)
tensorTraverse : AllTraversableshape=>Applicativef=> (a->fb) ->Tensorshapea->f (Tensorshapeb)
Visibility: public export
transposeMatrix : {auto{conArg:22308} : ConsistentWithi [j]} -> {auto{conArg:22316} : ConsistentWithj [i]} ->IsNaperiani=>IsNaperianj=>Tensor [i, j] a->Tensor [j, i] a
Visibility: public export
positions : Tensor [c] ((c.cont) .Possh)
  Like 'positions' from Naperian, but parametric, and not requiring the
Naperian instance here

Visibility: public export
interfaceDisplayNestedCont : Cont->Type
  Tensor-context rendering of container extensions.
A separate interface from `Display2D (Ext c a)` because layered
containers need to make separate choices (vertical bracket stacking for
List/Vect, structural tree layout for trees)

Parameters: c
Methods:
boxedForSiblings : GridChar->GridChar
  Action a parent of `c` needs to apply to `c`
For instance, trees get boxed if they're multi-line, cubical
containers do not apply any action. Defaults to boxing
displayNestedCont : Nat-> (GridChar->GridChar) ->Extc (GridChar) ->GridChar
  Given the content of `c` rendered as grids individually, render
the layout given information of how many axes are below, and
information on whether to box children, to keep visual separation
Container can in principle decide whether to use `childBox` or not

Implementations:
DisplayNestedContList
DisplayNestedCont (Vectn)
DisplayNestedContBinTree
DisplayNestedContBinTreeLeaf
DisplayNestedContBinTreeNode
DisplayNestedContScalar
DisplayNestedContPair
boxedForSiblings : DisplayNestedContc=>GridChar->GridChar
  Action a parent of `c` needs to apply to `c`
For instance, trees get boxed if they're multi-line, cubical
containers do not apply any action. Defaults to boxing

Visibility: public export
displayNestedCont : DisplayNestedContc=>Nat-> (GridChar->GridChar) ->Extc (GridChar) ->GridChar
  Given the content of `c` rendered as grids individually, render
the layout given information of how many axes are below, and
information on whether to box children, to keep visual separation
Container can in principle decide whether to use `childBox` or not

Visibility: public export
dataAllDisplay2D : TensorShaperank->Type->Type
Totality: total
Visibility: public export
Constructors:
Nil : Display2Da=>AllDisplay2D [] a
(::) : DisplayNestedCont (c.cont) ->AllDisplay2Dcsa-> {auto{conArg:23131} : ConsistentWithccs} ->TensorCubEvidencecs=>AllDisplay2D (c::cs) a

Hints:
AllDisplay2Dshapea=>TensorCubEvidenceshape=>Display2D (Tensorshapea)
AllDisplay2Dshapea=>TensorCubEvidenceshape=>Show (Tensorshapea)
scalarDisplay : AllDisplay2Dshapea=>Display2Da
  Recover the scalar-element `Display2D a` instance from a shape

Visibility: public export
maxWidthCubical : AllDisplay2Dshapea=>AllCIsFoldableshape=>Tensorshapea->Nat
  Fold through the content of the tensor, and return the maximum
width of the displayed scalar element

Visibility: public export
renderCubicalWithWidth : AllDisplay2Dshapea=>AllIsCubicalshape=>Nat->Nat->Tensorshapea->GridChar
  Render a cubical tensor given
1) a specific width of content for each cell
2) the number of outer bracket levels that need to surround the tensor

Visibility: public export
display2DTensorCubical : AllDisplay2Dshapea=>AllCIsFoldableshape=>AllIsCubicalshape=>Tensorshapea->GridChar
  Render a tensor we know is cubical: first compute the maximum width of 
a scalar element that appears, then render.

Visibility: public export
dispatchTensorDisplay : AllDisplay2Dshapea=>TensorCubEvidenceshape=>Tensorshapea->GridChar
  Dispatch between cubical and non-cubical rendering.
Is there a better way than with `TensorCubEvidence`?

Visibility: public export
dotWith : Algebra (Tensorshape) c=>AllCTensorMonoidshape=> (a->b->c) ->Tensorshapea->Tensorshapeb->Tensor [] c
Visibility: public export
dot : Numa=>Algebra (Tensorshape) a=>AllCTensorMonoidshape=>Tensorshapea->Tensorshapea->Tensor [] a
Visibility: public export
outerWith : TensorMonoid (i.cont) =>TensorMonoid (j.cont) => {autoac : ConsistentWithi [j]} -> (a->b->c) ->Tensor [i] a->Tensor [j] b->Tensor [i, j] c
Visibility: public export
outer : TensorMonoid (i.cont) =>TensorMonoid (j.cont) => {autoac : ConsistentWithi [j]} ->Numa=>Tensor [i] a->Tensor [j] a->Tensor [i, j] a
Visibility: public export
matrixVectorProduct : Numa=>TensorMonoid (j.cont) =>AllAlgebra [j] a=> {autoac : ConsistentWithi [j]} ->Tensor [i, j] a->Tensor [j] a->Tensor [i] a
Visibility: public export
vectorMatrixProduct : Numa=>TensorMonoid (i.cont) => {autoac : ConsistentWithi [j]} ->Algebra (Ext (i.cont)) (Tensor [j] a) =>Tensor [i] a->Tensor [i, j] a->Tensor [j] a
Visibility: public export
matMul : Numa=>TensorMonoid (j.cont) => {autoac1 : ConsistentWithi [j]} -> {autoac2 : ConsistentWithj [k]} -> {autoac3 : ConsistentWithi [k]} ->Algebra (Ext (j.cont)) (Tensor [k] a) =>Tensor [i, j] a->Tensor [j, k] a->Tensor [i, k] a
Visibility: public export
matrixMatrixProduct : {autoac1 : ConsistentWithi [j]} -> {autoac2 : ConsistentWithk [j]} -> {autoac3 : ConsistentWithk [i]} ->Numa=>TensorMonoid (j.cont) =>AllAlgebra [j] a=>Tensor [i, j] a->Tensor [k, j] a->Tensor [k, i] a
Visibility: public export
tEx : Tensor [("i"~~>3), ("j"~~>4)] Integer
Visibility: public export
Ex2 : Tensor [("k"~~>12)] Integer
Visibility: public export
Ex3 : Tensor [("i"~~>2), ("j"~~>6)] Integer
Visibility: public export
dataIndexTo : Tensorshapea-> (indexAxis : AxisName) ->UniqueElemindexAxisshape=>Type
Totality: total
Visibility: public export
Constructors:
Nil : {auto{conArg:25666} : ConsistentWithaxas} -> {auto{conArg:25670} : NotElem (ax.name) as} ->IndexTot (ax.name)
(::) : {auto{conArg:25699} : IsSuccrank} -> {auto{conArg:25706} : ConsistentWithaxas} -> {auto{conArg:25710} : UniqueElemindexAxisas} -> {auto{conArg:25714} : IsNo (decEqindexAxis (ax.name))} -> (p : (ax.cont) .Pos (shapeExt (extractTopExtt))) ->IndexTo (index (extractTopExtt) p) indexAxis->IndexTotindexAxis
indexShapeFw : (t : Tensorshapea) -> (indexAxis : AxisName) -> {autoinShape : UniqueElemindexAxisshape} ->IndexTotindexAxis->indexshapeindexAxis.Shp
  Here "axis shape" here meant in the container sense

Visibility: public export
dataIndex : (shape : TensorShaperank) ->Tensorshapea->Type
  Datatype containing information needed to index into a Tensor
Unlike with cubical tensors, where the underlying tensor is not
necessary, here we require the data of `t : Tensor shape a` too.
Based on absolute positions

Totality: total
Visibility: public export
Constructors:
Nil : Index [] t
(::) : {auto{conArg:25904} : ConsistentWithaxas} -> (p : (ax.cont) .Pos (shapeExt (extractTopExtt))) ->Indexas (index (extractTopExtt) p) ->Index (ax::as) t
index : (t : Tensorshapea) ->Indexshapet->a
Visibility: public export
(@@) : (t : Tensorshapea) ->Indexshapet->a
Visibility: public export
Fixity Declarations:
infixr operator, level 9
prefix operator, level 10
set : (t : Tensorshapea) ->InterfaceOnPositions (Tensor (contsshape)) Eq=>Indexshapet->a->Tensorshapea
Visibility: public export
dataIndexC : VectrankNat->Type
Totality: total
Visibility: public export
Constructors:
Nil : IndexC []
(::) : Finn->IndexCns->IndexC (n::ns)
treeExample1Test : Tensor [("myTree"~>BinTree)] Double
Visibility: public export