Safe Haskell | None |
---|---|
Language | Haskell2010 |
TensorFlow.Types
- class TensorType a where
- tensorType :: a -> DataType
- tensorRefType :: a -> DataType
- tensorVal :: Lens' TensorProto [a]
- newtype TensorData a = TensorData {}
- class TensorType a => TensorDataType s a where
- decodeTensorData :: TensorData a -> s a
- encodeTensorData :: Shape -> s a -> TensorData a
- newtype Scalar a = Scalar {
- unScalar :: a
- newtype Shape = Shape [Int64]
- protoShape :: Lens' TensorShapeProto Shape
- class Attribute a where
- data DataType :: *
- = DT_INVALID
- | DT_FLOAT
- | DT_DOUBLE
- | DT_INT32
- | DT_UINT8
- | DT_INT16
- | DT_INT8
- | DT_STRING
- | DT_COMPLEX64
- | DT_INT64
- | DT_BOOL
- | DT_QINT8
- | DT_QUINT8
- | DT_QINT32
- | DT_BFLOAT16
- | DT_QINT16
- | DT_QUINT16
- | DT_UINT16
- | DT_COMPLEX128
- | DT_HALF
- | DT_RESOURCE
- | DT_FLOAT_REF
- | DT_DOUBLE_REF
- | DT_INT32_REF
- | DT_UINT8_REF
- | DT_INT16_REF
- | DT_INT8_REF
- | DT_STRING_REF
- | DT_COMPLEX64_REF
- | DT_INT64_REF
- | DT_BOOL_REF
- | DT_QINT8_REF
- | DT_QUINT8_REF
- | DT_QINT32_REF
- | DT_BFLOAT16_REF
- | DT_QINT16_REF
- | DT_QUINT16_REF
- | DT_UINT16_REF
- | DT_COMPLEX128_REF
- | DT_HALF_REF
- | DT_RESOURCE_REF
- data ListOf f as where
- type List = ListOf Identity
- (/:/) :: a -> List as -> List (a : as)
- data TensorTypeProxy a where
- TensorTypeProxy :: TensorType a => TensorTypeProxy a
- class TensorTypes ts where
- tensorTypes :: TensorTypeList ts
- type TensorTypeList = ListOf TensorTypeProxy
- fromTensorTypeList :: TensorTypeList ts -> [DataType]
- fromTensorTypes :: forall as. TensorTypes as => Proxy as -> [DataType]
- type OneOf ts a = (TensorType a, TensorTypes ts, NoneOf (AllTensorTypes \\ ts) a)
- type family a /= b :: Constraint
- type OneOfs ts as = (TensorTypes as, TensorTypes ts, NoneOfs (AllTensorTypes \\ ts) as)
- data TypeError a
- data ExcludedCase
- type family NoneOf ts a :: Constraint
- type family as \\ bs
- type family Delete a as
- type AllTensorTypes = `[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool]`
Documentation
class TensorType a where
The class of scalar types supported by tensorflow.
newtype TensorData a
Tensor data with the correct memory layout for tensorflow.
Constructors
TensorData | |
Fields |
Instances
(TensorType a, (~) * a a') => Fetchable (Tensor v a) (TensorData a') |
class TensorType a => TensorDataType s a where
Types that can be converted to and from TensorData
.
Vector
is the most efficient to encode/decode for most element types.
Methods
decodeTensorData :: TensorData a -> s a
Decode the bytes of a TensorData
into an s
.
encodeTensorData :: Shape -> s a -> TensorData a
Encode an s
into a TensorData
.
The values should be in row major order, e.g.,
element 0: index (0, ..., 0) element 1: index (0, ..., 1) ...
Instances
TensorDataType Vector Bool | |
TensorDataType Vector Double | |
TensorDataType Vector Float | |
TensorDataType Vector Int8 | |
TensorDataType Vector Int16 | |
TensorDataType Vector Int32 | |
TensorDataType Vector Int64 | |
TensorDataType Vector Word8 | |
TensorDataType Vector Word16 | |
(Storable a, TensorDataType Vector a) => TensorDataType Vector a | |
TensorDataType Vector ByteString | |
TensorDataType Vector a => TensorDataType Scalar a | |
TensorDataType Vector (Complex Double) | |
TensorDataType Vector (Complex Float) |
newtype Scalar a
Instances
TensorDataType Vector a => TensorDataType Scalar a | |
Eq a => Eq (Scalar a) | |
Floating a => Floating (Scalar a) | |
Fractional a => Fractional (Scalar a) | |
Num a => Num (Scalar a) | |
Ord a => Ord (Scalar a) | |
Real a => Real (Scalar a) | |
RealFloat a => RealFloat (Scalar a) | |
RealFrac a => RealFrac (Scalar a) | |
Show a => Show (Scalar a) | |
IsString a => IsString (Scalar a) |
newtype Shape
Shape (dimensions) of a tensor.
protoShape :: Lens' TensorShapeProto Shape
class Attribute a where
data DataType :: *
Constructors
Lists
data ListOf f as where
A heterogeneous list type.
Instances
All Eq (Map f as) => Eq (ListOf f as) | |
All Show (Map f as) => Show (ListOf f as) | |
BuildInputs (ListOf (Tensor v) as) | |
TensorTypes as => PureResult (TensorList Build as) | |
(Rendered v, TensorTypes as) => BuildResult (TensorList v as) | |
(Nodes (f a), Nodes (ListOf f as)) => Nodes (ListOf f ((:) * a as)) | |
Nodes (ListOf f ([] *)) | |
(~) * l (List ([] *)) => Fetchable (ListOf f ([] *)) l | |
(Fetchable (f t) a, Fetchable (ListOf f ts) (List as), (~) (* -> *) i Identity) => Fetchable (ListOf f ((:) * t ts)) (ListOf i ((:) * a as)) |
data TensorTypeProxy a where
Constructors
TensorTypeProxy :: TensorType a => TensorTypeProxy a |
class TensorTypes ts where
Methods
tensorTypes :: TensorTypeList ts
Instances
TensorTypes ([] *) | |
(TensorType t, TensorTypes ts) => TensorTypes ((:) * t ts) | A constraint that the input is a list of |
type TensorTypeList = ListOf TensorTypeProxy
fromTensorTypeList :: TensorTypeList ts -> [DataType]
fromTensorTypes :: forall as. TensorTypes as => Proxy as -> [DataType]
Type constraints
type OneOf ts a = (TensorType a, TensorTypes ts, NoneOf (AllTensorTypes \\ ts) a)
A Constraint
specifying the possible choices of a TensorType
.
We implement a Constraint
like OneOf '[Double, Float] a
by turning the
natural representation as a conjunction, i.e.,
a == Double || a == Float
into a disjunction like
a /= Int32 && a /= Int64 && a /= ByteString && ...
using an enumeration of all the possible TensorType
s.
type family a /= b :: Constraint
A constraint checking that two types are different.
Equations
a /= a = TypeError a ~ ExcludedCase | |
a /= b = () |
type OneOfs ts as = (TensorTypes as, TensorTypes ts, NoneOfs (AllTensorTypes \\ ts) as)
Implementation of constraints
data TypeError a
Helper types to produce a reasonable type error message when the Constraint "a /= a" fails. TODO(judahjacobson): Use ghc-8's CustomTypeErrors for this.
data ExcludedCase
type family NoneOf ts a :: Constraint
A constraint that the type a
doesn't appear in the type list ts
.
Assumes that a
and each of the elements of ts
are TensorType
s.
type family as \\ bs
Takes the difference of two lists of types.
type family Delete a as
Removes a type from the given list of types.
type AllTensorTypes = `[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool]`
An enumeration of all valid TensorType
s.