futhark-0.25.32: An optimising compiler for a functional, array-oriented language.
Safe HaskellNone
LanguageGHC2021

Language.Futhark.Interpreter.AD

Synopsis

Documentation

data Op Source #

Constructors

OpBin BinOp 
OpCmp CmpOp 
OpUn UnOp 
OpFn Text 
OpConv ConvOp 

Instances

Instances details
Show Op Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> Op -> ShowS

show :: Op -> String

showList :: [Op] -> ShowS

data ADVariable Source #

Constructors

VJP VJPValue 
JVP JVPValue 

Instances

Instances details
Show ADVariable Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> ADVariable -> ShowS

show :: ADVariable -> String

showList :: [ADVariable] -> ShowS

data ADValue Source #

Instances

Instances details
Show ADValue Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> ADValue -> ShowS

show :: ADValue -> String

showList :: [ADValue] -> ShowS

data Tape Source #

Represents a computation tree, as well as every intermediate value in its evaluation.

Constructors

TapeID Counter ADValue

This represents a variable. Each variable is given a unique ID, and has an initial value

TapeConst ADValue

This represents a constant.

TapeOp Op [Tape] Counter ADValue

This represents the application of a mathematical operation. Each parameter is given by its Tape, and the return value of the operation is saved

Instances

Instances details
Show Tape Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> Tape -> ShowS

show :: Tape -> String

showList :: [Tape] -> ShowS

newtype VJPValue Source #

Constructors

VJPValue Tape 

Instances

Instances details
Show VJPValue Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> VJPValue -> ShowS

show :: VJPValue -> String

showList :: [VJPValue] -> ShowS

data JVPValue Source #

In JVP, the derivative of the variable must be saved. This is represented as a second value.

Constructors

JVPValue ADValue ADValue 

Instances

Instances details
Show JVPValue Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> JVPValue -> ShowS

show :: JVPValue -> String

showList :: [JVPValue] -> ShowS

newtype Counter Source #

Used to uniquely identify values.

Constructors

Counter Int 

Instances

Instances details
Num Counter Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Show Counter Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> Counter -> ShowS

show :: Counter -> String

showList :: [Counter] -> ShowS

Eq Counter Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

(==) :: Counter -> Counter -> Bool

(/=) :: Counter -> Counter -> Bool

Ord Counter Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

compare :: Counter -> Counter -> Ordering

(<) :: Counter -> Counter -> Bool

(<=) :: Counter -> Counter -> Bool

(>) :: Counter -> Counter -> Bool

(>=) :: Counter -> Counter -> Bool

max :: Counter -> Counter -> Counter

min :: Counter -> Counter -> Counter

newtype Depth Source #

An indication of the nesting depth of AD. This is used to avoid pertubation confusion.

Constructors

Depth Int 

Instances

Instances details
Show Depth Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

showsPrec :: Int -> Depth -> ShowS

show :: Depth -> String

showList :: [Depth] -> ShowS

Eq Depth Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

(==) :: Depth -> Depth -> Bool

(/=) :: Depth -> Depth -> Bool

Ord Depth Source # 
Instance details

Defined in Language.Futhark.Interpreter.AD

Methods

compare :: Depth -> Depth -> Ordering

(<) :: Depth -> Depth -> Bool

(<=) :: Depth -> Depth -> Bool

(>) :: Depth -> Depth -> Bool

(>=) :: Depth -> Depth -> Bool

max :: Depth -> Depth -> Depth

min :: Depth -> Depth -> Depth

doOp :: Op -> [ADValue] -> Counter -> Either String (ADValue, Counter) Source #

tapePrimal :: Tape -> ADValue Source #

Returns the primal value of a Tape.

deriveTape :: Tape -> ADValue -> Counter -> Either String (Map Counter ADValue, Counter) Source #

This calculates every partial derivative of a Tape. The result is a map of the partial derivatives, each key corresponding to the ID of a free variable (see TapeID).

unionWithM :: (Monad m, Ord k) => (a -> a -> m a) -> Map k a -> Map k a -> m (Map k a) Source #

unionsWithM :: (Foldable f, Monad m, Ord k) => (a -> a -> m a) -> f (Map k a) -> m (Map k a) Source #