Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class TensorType a where
- tensorType :: a -> DataType
- tensorRefType :: a -> DataType
- tensorVal :: Lens' TensorProto [a]
- decodeTensorData :: TensorData a -> Vector a
- encodeTensorData :: Shape -> Vector a -> TensorData a
- newtype TensorData a = TensorData {}
- newtype Shape = Shape [Int64]
- protoShape :: Lens' TensorShapeProto Shape
- class Attribute a where
- type OneOf ts a = (TensorType a, TensorTypes ts, NoneOf (AllTensorTypes \\ ts) a)
- type family a /= b :: Constraint
- data TypeError a
- data ExcludedCase
- type family TensorTypes ts :: Constraint
- 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 Source
The class of scalar types supported by tensorflow.
tensorType :: a -> DataType Source
tensorRefType :: a -> DataType Source
tensorVal :: Lens' TensorProto [a] Source
decodeTensorData :: TensorData a -> Vector a Source
Decode the bytes of a TensorData into a Vector.
encodeTensorData :: Shape -> Vector a -> TensorData a Source
Encode a Vector into a TensorData.
The values should be in row major order, e.g.,
element 0: index (0, ..., 0) element 1: index (0, ..., 1) ...
newtype TensorData a Source
Data about a tensor that is encoded for the TensorFlow APIs.
Shape (dimensions) of a tensor.
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 Source
A constraint checking that two types are different.
a /= a = TypeError a ~ ExcludedCase | |
a /= b = () |
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 TensorTypes ts :: Constraint Source
A Constraint
checking that the input is a list of TensorType
s.
Helps improve error messages when using OneOf
.
TensorTypes `[]` = () | |
TensorTypes (t : ts) = (TensorType t, TensorTypes ts) |
type family NoneOf ts a :: Constraint 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.
Takes the difference of two lists of types.
type AllTensorTypes = `[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool]` Source
An enumeration of all valid TensorType
s.