taco-0.2.0.0: Tensor Algebra COmpiler

Safe HaskellNone
LanguageHaskell2010

Data.Tensor.Compiler

Contents

Synopsis

Documentation

contract Source #

Arguments

:: MonadThrow m 
=> [Int]

Tensor contraction indices

-> Tensor i a 
-> Tensor i b 
-> ([Int] -> Tensor i a -> Tensor i b -> Phoas c)

Contraction function

-> m (Phoas c) 

Tensor contraction

Inject two Tensor constant into Vars, while ensuring that all the contraction indices are compatible with those of the tensors.

Throws a CException if any index is nonnegative or too large for the shape of the given tensor.

Tensor types

data Tensor i a where Source #

The Tensor type. Tensor data entries are stored as one single array

Constructors

Tensor :: Sh i -> Vector a -> Tensor (Sh i) a 

Instances

Functor (Tensor i) Source # 

Methods

fmap :: (a -> b) -> Tensor i a -> Tensor i b #

(<$) :: a -> Tensor i b -> Tensor i a #

Eq a => Eq (Tensor i a) Source # 

Methods

(==) :: Tensor i a -> Tensor i a -> Bool #

(/=) :: Tensor i a -> Tensor i a -> Bool #

Show a => Show (Tensor i a) Source # 

Methods

showsPrec :: Int -> Tensor i a -> ShowS #

show :: Tensor i a -> String #

showList :: [Tensor i a] -> ShowS #

data Sh sh where Source #

A statically-typed tensor shape parameter that supports both sparse and dense dimensions. Dimensions are indexed with Int32 indices, which should be enough for most applications.

Constructors

Z :: Sh Z 
D :: Sh sh -> Dd Int32 -> Sh (sh :# Int32)

Constructor for a dense dimension

S :: Sh sh -> Sd Int32 -> Sh (sh :. Int32)

Constructor for a sparse dimension

Instances

Eq (Sh sh) Source # 

Methods

(==) :: Sh sh -> Sh sh -> Bool #

(/=) :: Sh sh -> Sh sh -> Bool #

Show (Sh sh) Source # 

Methods

showsPrec :: Int -> Sh sh -> ShowS #

show :: Sh sh -> String #

showList :: [Sh sh] -> ShowS #

newtype Dd i Source #

To define a dense dimension we only need the dimensionality parameter

Constructors

Dd 

Fields

Instances

Eq i => Eq (Dd i) Source # 

Methods

(==) :: Dd i -> Dd i -> Bool #

(/=) :: Dd i -> Dd i -> Bool #

Show i => Show (Dd i) Source # 

Methods

showsPrec :: Int -> Dd i -> ShowS #

show :: Dd i -> String #

showList :: [Dd i] -> ShowS #

data Sd i Source #

To define a sparse dimension we need a cumulative array, an index array and a dimensionality parameter

Constructors

Sd 

Fields

  • sCml :: Maybe (Vector i)

    Cumulative array (# nonzero entries per degree of freedom). Not all storage formats (e.g. COO for rank-2 tensors) need this information.

  • sIdx :: Vector i

    Index array (indices of nonzero entries)

  • sDim :: i

    Size of the tensor along this dimension

Instances

(Eq i, Unbox i) => Eq (Sd i) Source # 

Methods

(==) :: Sd i -> Sd i -> Bool #

(/=) :: Sd i -> Sd i -> Bool #

(Unbox i, Show i) => Show (Sd i) Source # 

Methods

showsPrec :: Int -> Sd i -> ShowS #

show :: Sd i -> String #

showList :: [Sd i] -> ShowS #

Syntax

data Phoas a Source #

Parametric higher-order abstract syntax (PHOAS), after B. Oliveira, A. Loeh, `Abstract Syntax Graphs for Domain Specific Languages`

eval :: Phoas a -> a Source #

Semantic function for evaluation

var :: a -> Phoas a Source #

Inject a constant into the abstract syntax

let_ :: Phoas a -> (a -> Phoas b) -> Phoas b Source #

Bind a variable into a closure

let2_ :: Phoas a -> Phoas b -> (a -> b -> Phoas c) -> Phoas c Source #

Bind two variables into a closure

Exceptions