futhark-0.22.4: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Futhark.IR.Prop.Reshape

Description

Facilities for creating, inspecting, and simplifying reshape and coercion operations.

Synopsis

Construction

shapeCoerce :: [SubExp] -> VName -> Exp rep Source #

Construct a Reshape that is a ReshapeCoerce.

Execution

reshapeOuter :: Shape -> Int -> Shape -> Shape Source #

reshapeOuter newshape n oldshape returns a Reshape expression that replaces the outer n dimensions of oldshape with newshape.

reshapeInner :: Shape -> Int -> Shape -> Shape Source #

reshapeInner newshape n oldshape returns a Reshape expression that replaces the inner m-n dimensions (where m is the rank of oldshape) of src with newshape.

Simplification

Shape calculations

reshapeIndex :: IntegralExp num => [num] -> [num] -> [num] -> [num] Source #

reshapeIndex to_dims from_dims is transforms the index list is (which is into an array of shape from_dims) into an index list is', which is into an array of shape to_dims. is must have the same length as from_dims, and is' will have the same length as to_dims.

flattenIndex :: IntegralExp num => [num] -> [num] -> num Source #

flattenIndex dims is computes the flat index of is into an array with dimensions dims. The length of dims and is must be the same.

unflattenIndex :: IntegralExp num => [num] -> num -> [num] Source #

unflattenIndex dims i computes a list of indices into an array with dimension dims given the flat index i. The resulting list will have the same size as dims.

sliceSizes :: IntegralExp num => [num] -> [num] Source #

Given a length n list of dimensions dims, sizeSizes dims will compute a length n+1 list of the size of each possible array slice. The first element of this list will be the product of dims, and the last element will be 1.