mirror of
https://github.com/tensorflow/haskell.git
synced 2024-11-26 21:09:44 +01:00
6b19e54722
* Update README to refer to 2.3.0-gpu. * Remove old package documentation from haddock directory.
159 lines
5.5 KiB
Text
159 lines
5.5 KiB
Text
-- Hoogle documentation, generated by Haddock
|
|
-- See Hoogle, http://www.haskell.org/hoogle/
|
|
|
|
|
|
-- | Code generation for TensorFlow operations.
|
|
--
|
|
-- Please see README.md
|
|
@package tensorflow-opgen
|
|
@version 0.3.0.0
|
|
|
|
|
|
-- | This module helps parse the proto OpDef into a Haskell type which is
|
|
-- more descriptive of how the attributes and arguments will be used in
|
|
-- the generated code.
|
|
module TensorFlow.OpGen.ParsedOp
|
|
data ParsedOp
|
|
ParsedOp :: Name -> Text -> Text -> [ParsedArg] -> [ParsedArg] -> [Attr AttrType] -> [Attr TypeParam] -> [Attr (NonEmpty Name)] -> Bool -> ParsedOp
|
|
[parsedOpName] :: ParsedOp -> Name
|
|
[parsedOpSummary] :: ParsedOp -> Text
|
|
[parsedOpDescription] :: ParsedOp -> Text
|
|
[parsedInputs] :: ParsedOp -> [ParsedArg]
|
|
[parsedOutputs] :: ParsedOp -> [ParsedArg]
|
|
|
|
-- | Attributes that must be set explicitly when creating the op.
|
|
-- Associated with the type of the attribute.
|
|
[explicitInputAttrs] :: ParsedOp -> [Attr AttrType]
|
|
|
|
-- | Attributes that are type parameters.
|
|
[inferredTypeAttrs] :: ParsedOp -> [Attr TypeParam]
|
|
[inferredListSizeAttrs] :: ParsedOp -> [Attr (NonEmpty Name)]
|
|
|
|
-- | Whether this op is stateful or takes a stateful input. Such ops should
|
|
-- not be CSE'd and must be monadic in our API (i.e., return a Build
|
|
-- action).
|
|
[parsedOpIsMonadic] :: ParsedOp -> Bool
|
|
data Name
|
|
Name :: HaskellName -> TFName -> Name
|
|
[haskellName] :: Name -> HaskellName
|
|
[tfName] :: Name -> TFName
|
|
|
|
-- | A name that's appropriate for a variable in a Haskell source file.
|
|
newtype HaskellName
|
|
HaskellName :: Text -> HaskellName
|
|
[unHaskellName] :: HaskellName -> Text
|
|
|
|
-- | A raw name as specified in the OpDef proto.
|
|
newtype TFName
|
|
TFName :: Text -> TFName
|
|
[unTFName] :: TFName -> Text
|
|
|
|
-- | A named attribute, associated with some information about it.
|
|
data Attr a
|
|
Attr :: Name -> Text -> a -> Attr a
|
|
[attrName] :: Attr a -> Name
|
|
[attrDescription] :: Attr a -> Text
|
|
[attrInfo] :: Attr a -> a
|
|
|
|
-- | The type of an attribute.
|
|
data AttrType
|
|
AttrSingle :: AttrBaseType -> AttrType
|
|
AttrList :: AttrBaseType -> AttrType
|
|
data AttrBaseType
|
|
AttrBytes :: AttrBaseType
|
|
AttrInt64 :: AttrBaseType
|
|
AttrFloat :: AttrBaseType
|
|
AttrBool :: AttrBaseType
|
|
AttrType :: AttrBaseType
|
|
AttrShape :: AttrBaseType
|
|
AttrTensor :: AttrBaseType
|
|
data TypeParam
|
|
TypeParam :: Bool -> Maybe (NonEmpty DataType) -> TypeParam
|
|
[typeParamIsList] :: TypeParam -> Bool
|
|
|
|
-- | The list of allowed types (see: TensorFlow.Types.OneOf). If
|
|
-- <a>Nothing</a>, then any type is acceptable.
|
|
[typeParamRestrictions] :: TypeParam -> Maybe (NonEmpty DataType)
|
|
|
|
-- | An input or output argument (Tensor) for an op.
|
|
data ParsedArg
|
|
ParsedArg :: Name -> Text -> ParsedArgCase -> ParsedArg
|
|
[parsedArgName] :: ParsedArg -> Name
|
|
[parsedArgDescription] :: ParsedArg -> Text
|
|
[parsedArgCase] :: ParsedArg -> ParsedArgCase
|
|
data ParsedArgCase
|
|
SimpleArg :: ArgType -> ArgKind -> ParsedArgCase
|
|
[argType] :: ParsedArgCase -> ArgType
|
|
[argKind] :: ParsedArgCase -> ArgKind
|
|
ListArg :: Name -> ArgType -> ArgKind -> ParsedArgCase
|
|
|
|
-- | The attribute that specifies this list's length.
|
|
[argLength] :: ParsedArgCase -> Name
|
|
[argType] :: ParsedArgCase -> ArgType
|
|
[argKind] :: ParsedArgCase -> ArgKind
|
|
|
|
-- | A heterogeneous list.
|
|
MixedListArg :: Name -> ArgKind -> ParsedArgCase
|
|
[argTypeAttr] :: ParsedArgCase -> Name
|
|
[argKind] :: ParsedArgCase -> ArgKind
|
|
|
|
-- | The type of an argument.
|
|
data ArgType
|
|
|
|
-- | A fixed type.
|
|
ArgTypeFixed :: DataType -> ArgType
|
|
|
|
-- | A type that depends on an attribute.
|
|
ArgTypeAttr :: Name -> ArgType
|
|
data ArgKind
|
|
ArgTensorRef :: ArgKind
|
|
ArgTensorValue :: ArgKind
|
|
ArgTensorBuild :: ArgKind
|
|
ArgSomeTensor :: Text -> ArgKind
|
|
parseOp :: OpDef -> ParsedOp
|
|
camelCase :: Text -> Text
|
|
instance GHC.Classes.Eq TensorFlow.OpGen.ParsedOp.ArgKind
|
|
instance GHC.Classes.Eq TensorFlow.OpGen.ParsedOp.AttrType
|
|
instance GHC.Classes.Eq TensorFlow.OpGen.ParsedOp.AttrBaseType
|
|
instance GHC.Classes.Ord TensorFlow.OpGen.ParsedOp.TFName
|
|
instance GHC.Classes.Eq TensorFlow.OpGen.ParsedOp.TFName
|
|
|
|
|
|
-- | Rendering of TensorFlow operations as Haskell functions.
|
|
--
|
|
-- The basic type signature generated for each op is:
|
|
--
|
|
-- <pre>
|
|
-- {constraints} => {mandatory attrs} -> {input tensors} -> {output tensors}
|
|
-- </pre>
|
|
--
|
|
-- where:
|
|
--
|
|
-- <ul>
|
|
-- <li><tt>{mandatory attrs}</tt> is of the form <tt>A_1 -> ... ->
|
|
-- A_N</tt>, where each <tt>A</tt> is an op attribute that doesn't have a
|
|
-- default and can't be inferred from other inputs.</li>
|
|
-- <li><tt>{constraints}</tt> restrict the type parameters of the input
|
|
-- and output tensors (for example: <tt>TensorType</tt> or
|
|
-- <tt>OneOf</tt>).</li>
|
|
-- <li><tt>{input tensors}</tt> is of the form <tt>T_1 -> ... ->
|
|
-- T_N</tt>, where each <tt>T</tt> is of the form <tt>Tensor Ref a</tt>
|
|
-- or <tt>Tensor v a</tt> (or a list of one of those types), and
|
|
-- <tt>a</tt> is either a concrete type or a (constrained) type
|
|
-- variable.</li>
|
|
-- <li><tt>{output tensors}</tt> is of the form <tt>(T_1,...,T_N)</tt>
|
|
-- for "pure" ops, and <tt>Build (T_1,...,T_N)</tt> for "stateful" ops.
|
|
-- An op is considered "stateful" if it takes a <tt>Tensor Ref</tt> or
|
|
-- <tt>Tensor v ResourceHandle</tt> as input, or if it's explicitly
|
|
-- marked "Stateful" in its <tt>REGISTER_OP</tt> definition. (If there
|
|
-- are no outputs, it is either <tt>ControlNode</tt> or <tt>Build
|
|
-- ControlNode</tt>.)</li>
|
|
-- </ul>
|
|
module TensorFlow.OpGen
|
|
data OpGenFlags
|
|
OpGenFlags :: String -> String -> String -> OpGenFlags
|
|
[outputFile] :: OpGenFlags -> String
|
|
[prefix] :: OpGenFlags -> String
|
|
[excludeList] :: OpGenFlags -> String
|
|
docOpList :: OpGenFlags -> OpList -> Doc
|
|
flagParser :: Parser OpGenFlags
|