Safe Haskell | None |
---|---|
Language | Haskell2010 |
TensorFlow.Types
- class TensorType a where
- newtype TensorData a = TensorData {}
- class TensorType a => TensorDataType s a where
- 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_VARIANT
- | DT_UINT32
- | DT_UINT64
- | 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
- | DT_VARIANT_REF
- | DT_UINT32_REF
- | DT_UINT64_REF
- type ResourceHandle = ResourceHandleProto
- data Variant
- 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
- 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 where ...
- type OneOfs ts as = (TensorTypes as, TensorTypes' ts, NoneOfs (AllTensorTypes \\ ts) as)
- data TypeError a
- data ExcludedCase
- type family NoneOf ts a :: Constraint where ...
- type family as \\ bs where ...
- type family Delete a as where ...
- type AllTensorTypes = '[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool]
Documentation
class TensorType a where Source #
The class of scalar types supported by tensorflow.
Minimal complete definition
Methods
tensorType :: a -> DataType Source #
tensorRefType :: a -> DataType Source #
tensorVal :: Lens' TensorProto [a] Source #
Instances
newtype TensorData a Source #
Tensor data with the correct memory layout for tensorflow.
Constructors
TensorData | |
Fields |
Instances
(TensorType a, (~) * a a') => Fetchable (Tensor v a) (TensorData a') Source # | |
class TensorType a => TensorDataType s a where Source #
Types that can be converted to and from TensorData
.
Vector
is the most efficient to encode/decode for most element types.
Minimal complete definition
Methods
decodeTensorData :: TensorData a -> s a Source #
Decode the bytes of a TensorData
into an s
.
encodeTensorData :: Shape -> s a -> TensorData a Source #
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 Source # | |
TensorDataType Vector Double Source # | |
TensorDataType Vector Float Source # | |
TensorDataType Vector Int8 Source # | |
TensorDataType Vector Int16 Source # | |
TensorDataType Vector Int32 Source # | |
TensorDataType Vector Int64 Source # | |
TensorDataType Vector Word8 Source # | |
TensorDataType Vector Word16 Source # | |
(Storable a, TensorDataType Vector a, TensorType a) => TensorDataType Vector a Source # | |
TensorDataType Vector ByteString Source # | |
(TensorDataType Vector a, TensorType a) => TensorDataType Scalar a Source # | |
TensorDataType Vector (Complex Double) Source # | |
TensorDataType Vector (Complex Float) Source # | |
Instances
(TensorDataType Vector a, TensorType a) => TensorDataType Scalar a Source # | |
Eq a => Eq (Scalar a) Source # | |
Floating a => Floating (Scalar a) Source # | |
Fractional a => Fractional (Scalar a) Source # | |
Num a => Num (Scalar a) Source # | |
Ord a => Ord (Scalar a) Source # | |
Real a => Real (Scalar a) Source # | |
RealFloat a => RealFloat (Scalar a) Source # | |
RealFrac a => RealFrac (Scalar a) Source # | |
Show a => Show (Scalar a) Source # | |
IsString a => IsString (Scalar a) Source # | |
Shape (dimensions) of a tensor.
TensorFlow supports shapes of unknown rank, which are represented as
Nothing :: Maybe Shape
in Haskell.
protoShape :: Lens' TensorShapeProto Shape Source #
class Attribute a where Source #
Minimal complete definition
Instances
Constructors
type ResourceHandle = ResourceHandleProto Source #
Dynamic type. TensorFlow variants aren't supported yet. This type acts a placeholder to simplify op generation.
Instances
Lists
data ListOf f as where Source #
A heterogeneous list type.
Instances
All Eq (Map f as) => Eq (ListOf f as) Source # | |
All Show (Map f as) => Show (ListOf f as) Source # | |
(Nodes (f a), Nodes (ListOf f as)) => Nodes (ListOf f ((:) * a as)) Source # | |
Nodes (ListOf f ([] *)) Source # | |
BuildInputs (ListOf (Tensor v) as) Source # | |
TensorTypes as => PureResult (TensorList Build as) Source # | |
(TensorKind v, Rendered (Tensor v), TensorTypes as) => BuildResult (TensorList v as) Source # | |
(~) * l (List ([] *)) => Fetchable (ListOf f ([] *)) l Source # | |
(Fetchable (f t) a, Fetchable (ListOf f ts) (List as), (~) (* -> *) i Identity) => Fetchable (ListOf f ((:) * t ts)) (ListOf i ((:) * a as)) Source # | |
data TensorTypeProxy a where Source #
Constructors
TensorTypeProxy :: TensorType a => TensorTypeProxy a |
class TensorTypes (ts :: [*]) where Source #
Minimal complete definition
Methods
tensorTypes :: TensorTypeList ts Source #
Instances
TensorTypes ([] *) Source # | |
(TensorType t, TensorTypes ts) => TensorTypes ((:) * t ts) Source # | A constraint that the input is a list of |
type TensorTypeList = ListOf TensorTypeProxy Source #
fromTensorTypeList :: TensorTypeList ts -> [DataType] Source #
fromTensorTypes :: forall as. TensorTypes as => Proxy as -> [DataType] Source #
Type constraints
type OneOf ts a = (TensorType a, TensorTypes' ts, NoneOf (AllTensorTypes \\ ts) a) Source #
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 where ... Source #
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) Source #
Implementation of constraints
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 Source #
type family NoneOf ts a :: Constraint where ... Source #
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.
Equations
NoneOf (t1 ': (t2 ': (t3 ': (t4 ': ts)))) a = (a /= t1, a /= t2, a /= t3, a /= t4, NoneOf ts a) | |
NoneOf (t1 ': (t2 ': (t3 ': ts))) a = (a /= t1, a /= t2, a /= t3, NoneOf ts a) | |
NoneOf (t1 ': (t2 ': ts)) a = (a /= t1, a /= t2, NoneOf ts a) | |
NoneOf (t1 ': ts) a = (a /= t1, NoneOf ts a) | |
NoneOf '[] a = () |
type AllTensorTypes = '[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool] Source #
An enumeration of all valid TensorType
s.