| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Futhark.IR.Prop.Types
Contents
Description
Functions for inspecting and constructing various types.
Synopsis
- rankShaped :: ArrayShape shape => TypeBase shape o -> TypeBase Rank o
- arrayRank :: ArrayShape shape => TypeBase shape o -> Int
- arrayShape :: ArrayShape shape => TypeBase shape o -> shape
- setArrayShape :: ArrayShape newshape => TypeBase oldshape o -> newshape -> TypeBase newshape o
- isEmptyArray :: Type -> Maybe (PrimType, Shape)
- existential :: ExtType -> Bool
- consuming :: TypeBase shape Diet -> Bool
- staticShapes :: [TypeBase Shape o] -> [TypeBase ExtShape o]
- staticShapes1 :: TypeBase Shape o -> TypeBase ExtShape o
- primType :: TypeBase shape o -> Bool
- isAcc :: TypeBase shape o -> Bool
- isMem :: TypeBase shape o -> Bool
- arrayOf :: ArrayShape shape => TypeBase shape o_unused -> shape -> o -> TypeBase shape o
- arrayOfRow :: TypeBase (ShapeBase d) NoMode -> d -> TypeBase (ShapeBase d) NoMode
- arrayOfShape :: Type -> Shape -> Type
- setOuterSize :: TypeBase (ShapeBase d) m -> d -> TypeBase (ShapeBase d) m
- setDimSize :: Int -> TypeBase (ShapeBase d) m -> d -> TypeBase (ShapeBase d) m
- setOuterDim :: ShapeBase d -> d -> ShapeBase d
- setOuterDims :: ShapeBase d -> Int -> ShapeBase d -> ShapeBase d
- setDim :: Int -> ShapeBase d -> d -> ShapeBase d
- setArrayDims :: TypeBase oldshape o -> [SubExp] -> TypeBase Shape o
- peelArray :: Int -> TypeBase Shape o -> Maybe (TypeBase Shape o)
- stripArray :: Int -> TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m
- arrayDims :: TypeBase (ShapeBase d) m -> [d]
- shapeSize :: Int -> Shape -> SubExp
- arraySize :: Int -> TypeBase Shape o -> SubExp
- arraysSize :: Int -> [TypeBase Shape o] -> SubExp
- elemType :: TypeBase shape o -> PrimType
- rowType :: TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m
- transposeType :: Type -> Type
- rearrangeType :: [Int] -> TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m
- mapOnExtType :: Monad m => (SubExp -> m SubExp) -> TypeBase ExtShape o -> m (TypeBase ExtShape o)
- mapOnType :: Monad m => (SubExp -> m SubExp) -> TypeBase Shape o -> m (TypeBase Shape o)
- diet :: TypeBase shape Diet -> Diet
- toDecl :: TypeBase shape NoMode -> Diet -> TypeBase shape Diet
- fromDecl :: TypeBase shape o -> TypeBase shape NoMode
- isExt :: Ext a -> Maybe Int
- isFree :: Ext a -> Maybe a
- extractShapeContext :: [TypeBase ExtShape o] -> [[a]] -> [a]
- shapeContext :: [TypeBase ExtShape o] -> Set Int
- hasStaticShape :: TypeBase ExtShape o -> Maybe (TypeBase Shape o)
- generaliseExtTypes :: [TypeBase ExtShape o] -> [TypeBase ExtShape o] -> [TypeBase ExtShape o]
- existentialiseExtTypes :: [VName] -> [ExtType] -> [ExtType]
- shapeExtMapping :: [TypeBase ExtShape o] -> [TypeBase Shape o1] -> Map Int SubExp
- int8 :: PrimType
- int16 :: PrimType
- int32 :: PrimType
- int64 :: PrimType
- float32 :: PrimType
- float64 :: PrimType
- class Typed t where
- class DeclTyped t where
- declTypeOf :: t -> DeclType
- class FixExt t => ExtTyped t where
- class FixExt t where
Documentation
rankShaped :: ArrayShape shape => TypeBase shape o -> TypeBase Rank o Source #
Remove shape information from a type.
arrayRank :: ArrayShape shape => TypeBase shape o -> Int Source #
Return the dimensionality of a type. For non-arrays, this is zero. For a one-dimensional array it is one, for a two-dimensional it is two, and so forth.
arrayShape :: ArrayShape shape => TypeBase shape o -> shape Source #
Return the shape of a type - for non-arrays, this is the
mempty.
setArrayShape :: ArrayShape newshape => TypeBase oldshape o -> newshape -> TypeBase newshape o Source #
Set the shape of an array. If the given type is not an array, return the type unchanged.
isEmptyArray :: Type -> Maybe (PrimType, Shape) Source #
If the array is statically an empty array (meaning any dimension is a static zero), return the element type and the shape.
existential :: ExtType -> Bool Source #
True if the given type has a dimension that is existentially sized.
consuming :: TypeBase shape Diet -> Bool Source #
consuming t is True if a parameter of this type consumes its
argument.
staticShapes :: [TypeBase Shape o] -> [TypeBase ExtShape o] Source #
Convert types with non-existential shapes to types with
existential shapes. Only the representation is changed, so all
the shapes will be Free.
staticShapes1 :: TypeBase Shape o -> TypeBase ExtShape o Source #
As staticShapes, but on a single type.
primType :: TypeBase shape o -> Bool Source #
A type is a primitive type if it is not an array or memory block.
arrayOf :: ArrayShape shape => TypeBase shape o_unused -> shape -> o -> TypeBase shape o Source #
arrayOf t s o constructs an array type. The convenience
compared to using the Array constructor directly is that t can
itself be an array. If t is an n-dimensional array, and s is
a list of length n, the resulting type is of an n+m dimensions.
The mode of the new array will be o, no matter the mode of t.
If the shape s has rank 0, then the t will be returned,
although if it is an array, with the mode changed to o.
arrayOfRow :: TypeBase (ShapeBase d) NoMode -> d -> TypeBase (ShapeBase d) NoMode Source #
Construct an array whose rows are the given type, and the outer
size is the given dimension. This is just a convenient wrapper
around arrayOf.
setOuterSize :: TypeBase (ShapeBase d) m -> d -> TypeBase (ShapeBase d) m Source #
Replace the size of the outermost dimension of an array. If the given type is not an array, it is returned unchanged.
setDimSize :: Int -> TypeBase (ShapeBase d) m -> d -> TypeBase (ShapeBase d) m Source #
Replace the size of the given dimension of an array. If the given type is not an array, it is returned unchanged.
setOuterDim :: ShapeBase d -> d -> ShapeBase d Source #
Replace the outermost dimension of an array shape.
setOuterDims :: ShapeBase d -> Int -> ShapeBase d -> ShapeBase d Source #
Replace some outermost dimensions of an array shape.
setDim :: Int -> ShapeBase d -> d -> ShapeBase d Source #
Replace the specified dimension of an array shape.
setArrayDims :: TypeBase oldshape o -> [SubExp] -> TypeBase Shape o Source #
Set the dimensions of an array. If the given type is not an array, return the type unchanged.
peelArray :: Int -> TypeBase Shape o -> Maybe (TypeBase Shape o) Source #
peelArray n t returns the type resulting from peeling the first
n array dimensions from t. Returns Nothing if t has less
than n dimensions.
stripArray :: Int -> TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m Source #
stripArray n t removes the n outermost layers of the array.
Essentially, it is the type of indexing an array of type t with
n indexes.
arrayDims :: TypeBase (ShapeBase d) m -> [d] Source #
Return the dimensions of a type - for non-arrays, this is the empty list.
shapeSize :: Int -> Shape -> SubExp Source #
Return the size of the given dimension. If the dimension does not exist, the zero constant is returned.
arraySize :: Int -> TypeBase Shape o -> SubExp Source #
Return the size of the given dimension. If the dimension does not exist, the zero constant is returned.
arraysSize :: Int -> [TypeBase Shape o] -> SubExp Source #
Return the size of the given dimension in the first element of the given type list. If the dimension does not exist, or no types are given, the zero constant is returned.
elemType :: TypeBase shape o -> PrimType Source #
Returns the bottommost type of an array. For [][]i32, this
would be i32. If the given type is not an array, it is returned.
rowType :: TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m Source #
Return the immediate row-type of an array. For [][]t, this
would be []t.
transposeType :: Type -> Type Source #
Swap the two outer dimensions of the type.
rearrangeType :: [Int] -> TypeBase (ShapeBase d) m -> TypeBase (ShapeBase d) m Source #
Rearrange the dimensions of the type. If the length of the permutation does not match the rank of the type, the permutation will be extended with identity.
mapOnExtType :: Monad m => (SubExp -> m SubExp) -> TypeBase ExtShape o -> m (TypeBase ExtShape o) Source #
Transform any SubExps in the type.
mapOnType :: Monad m => (SubExp -> m SubExp) -> TypeBase Shape o -> m (TypeBase Shape o) Source #
Transform any SubExps in the type.
diet :: TypeBase shape Diet -> Diet Source #
diet t returns a description of how a function parameter of
type t might consume its argument. An accumulator is consumed by
any use, so it is unconditionally Consume.
toDecl :: TypeBase shape NoMode -> Diet -> TypeBase shape Diet Source #
Add the given Diet to the types.
extractShapeContext :: [TypeBase ExtShape o] -> [[a]] -> [a] Source #
Given the existential return type of a function, and the shapes of the values returned by the function, return the existential shape context. That is, those sizes that are existential in the return type.
shapeContext :: [TypeBase ExtShape o] -> Set Int Source #
The Ext integers used for existential sizes in the given types.
generaliseExtTypes :: [TypeBase ExtShape o] -> [TypeBase ExtShape o] -> [TypeBase ExtShape o] Source #
shapeExtMapping :: [TypeBase ExtShape o] -> [TypeBase Shape o1] -> Map Int SubExp Source #
Produce a mapping for the dimensions context.
Abbreviations
The Typed typeclass
Typeclass for things that contain Types.
Instances
| Typed DeclType Source # | |
| Typed Ident Source # | |
| Typed Type Source # | |
| ASTRep rep => Typed (Entry rep) Source # | |
| RepTypes rep => Typed (NameInfo rep) Source # | |
| Typed dec => Typed (Param dec) Source # | |
| Typed dec => Typed (PatElem dec) Source # | |
| Typed b => Typed (a, b) Source # | |
Defined in Futhark.IR.Prop.Types | |
| Typed (MemInfo SubExp Diet ret) Source # | |
| Typed (MemInfo SubExp NoMode ret) Source # | |
class DeclTyped t where Source #
Typeclass for things that contain DeclTypes.
Methods
declTypeOf :: t -> DeclType Source #
Instances
| DeclTyped DeclType Source # | |
Defined in Futhark.IR.Prop.Types Methods declTypeOf :: DeclType -> DeclType Source # | |
| DeclTyped dec => DeclTyped (Param dec) Source # | |
Defined in Futhark.IR.Prop.Types Methods declTypeOf :: Param dec -> DeclType Source # | |
| DeclTyped (MemInfo SubExp Diet ret) Source # | |
Defined in Futhark.IR.Mem | |
class FixExt t => ExtTyped t where Source #
Typeclass for things that contain ExtTypes.
Something with an existential context that can be (partially) fixed.
Methods
fixExt :: Int -> SubExp -> t -> t Source #
Fix the given existentional variable to the indicated free value.
mapExt :: (Int -> Int) -> t -> t Source #
Map a function onto any existential.