Safe Haskell | None |
---|---|
Language | Haskell2010 |
Futhark.Data
Contents
Description
This module defines an efficient value representation of the Futhark data format.
Synopsis
- data Value
- = I8Value (Vector Int) (Vector Int8)
- | I16Value (Vector Int) (Vector Int16)
- | I32Value (Vector Int) (Vector Int32)
- | I64Value (Vector Int) (Vector Int64)
- | U8Value (Vector Int) (Vector Word8)
- | U16Value (Vector Int) (Vector Word16)
- | U32Value (Vector Int) (Vector Word32)
- | U64Value (Vector Int) (Vector Word64)
- | F16Value (Vector Int) (Vector Half)
- | F32Value (Vector Int) (Vector Float)
- | F64Value (Vector Int) (Vector Double)
- | BoolValue (Vector Int) (Vector Bool)
- type Vector = Vector
- valueText :: Value -> Text
- data PrimType
- primTypeText :: PrimType -> Text
- primTypeBytes :: PrimType -> Int
- data ValueType = ValueType [Int] PrimType
- valueTypeTextNoDims :: ValueType -> Text
- valueType :: Value -> ValueType
- valueElemType :: Value -> PrimType
- valueShape :: Value -> [Int]
- valueTypeText :: ValueType -> Text
- class GetValue t where
- class PutValue t where
- valueElems :: Value -> [Value]
Documentation
An efficiently represented Futhark value, represented as a shape vector and a value vector, which contains elements in row-major order. The size of the value vector must be equal to the product of the shape vector. This is not enforced by the representation, but consuming functions may give unexpected results if this invariant is broken. Scalars are represented with an empty shape vector.
Use valueText
to get a human-readable representation, and put
to obtain binary a representation.
The Eq
instance is the naive one, meaning that no values
containing NaNs will be considered equal. Use the functions from
Futhark.Data.Compare if this is not what you want.
Constructors
I8Value (Vector Int) (Vector Int8) | |
I16Value (Vector Int) (Vector Int16) | |
I32Value (Vector Int) (Vector Int32) | |
I64Value (Vector Int) (Vector Int64) | |
U8Value (Vector Int) (Vector Word8) | |
U16Value (Vector Int) (Vector Word16) | |
U32Value (Vector Int) (Vector Word32) | |
U64Value (Vector Int) (Vector Word64) | |
F16Value (Vector Int) (Vector Half) | |
F32Value (Vector Int) (Vector Float) | |
F64Value (Vector Int) (Vector Double) | |
BoolValue (Vector Int) (Vector Bool) |
valueText :: Value -> Text Source #
Construct a textual representation of the value as a strict text.
Types of values
The scalar types supported by the value format.
Instances
Bounded PrimType Source # | |
Enum PrimType Source # | |
Eq PrimType Source # | |
Ord PrimType Source # | |
Defined in Futhark.Data | |
Show PrimType Source # | |
primTypeText :: PrimType -> Text Source #
Textual primitive type as a strict text.
primTypeBytes :: PrimType -> Int Source #
The number of bytes taken up by a single element of this type.
The type of a simple Futhark value, comprising a shape and an element type.
Instances
Eq ValueType Source # | |
Ord ValueType Source # | |
Show ValueType Source # | |
valueTypeTextNoDims :: ValueType -> Text Source #
Prettyprint a value type with empty dimensions as a strict text. This is needed for Futhark server programs, whose types are un-sized.
valueElemType :: Value -> PrimType Source #
Get the element type of a value.
valueShape :: Value -> [Int] Source #
The shape of a value. Empty list in case of a scalar.
valueTypeText :: ValueType -> Text Source #
Prettyprint a value type as a strict text.
Converting values
class GetValue t where Source #
A class for Haskell values that can be retrieved from Value
.
This is a convenience facility - don't expect it to be fast.
class PutValue t where Source #
A class for Haskell values that can be converted to Value
.
This is a convenience facility - don't expect it to be fast.
Instances
valueElems :: Value -> [Value] Source #
Produce a list of the immediate elements of the value. That is, a 2D array will produce a list of 1D values. A zero-dimensional value will produce an empty list. While lists are of course inefficient, the actual values are just slices of the original value, which makes them fairly space-efficient (but beware space leaks).