Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype ControlNode = ControlNode {}
- data Unique
- explicitName :: Text -> PendingNodeName
- implicitName :: PendingNodeName
- opDef :: OpType -> OpDef
- opDefWithName :: PendingNodeName -> OpType -> OpDef
- opName :: Lens' OpDef PendingNodeName
- opType :: Lens' OpDef OpType
- opAttr :: Attribute a => Text -> Lens' OpDef a
- opInputs :: Lens' OpDef [Output]
- opControlInputs :: Lens' OpDef [NodeName]
- data GraphState
- renderedNodeDefs :: Lens' GraphState (Map NodeName NodeDef)
- data BuildT m a
- type Build = BuildT Identity
- class Monad m => MonadBuild m where
- addInitializer :: MonadBuild m => ControlNode -> m ()
- hoistBuildT :: (forall a. m a -> n a) -> BuildT m b -> BuildT n b
- evalBuildT :: Monad m => BuildT m a -> m a
- runBuildT :: BuildT m a -> m (a, GraphState)
- asGraphDef :: Build a -> GraphDef
- addGraphDef :: MonadBuild m => GraphDef -> m ()
- flushInitializers :: Monad m => BuildT m [NodeName]
- flushNodeBuffer :: MonadBuild m => m [NodeDef]
- summaries :: Lens' GraphState [Output]
- getOrAddOp :: OpDef -> Build NodeName
- addNewOp :: OpDef -> Build NodeName
- encodeOutput :: Output -> Text
- lookupNode :: NodeName -> Build NodeDef
- withStateLens :: MonadBuild m => Lens' GraphState a -> (a -> a) -> m b -> m b
- withDevice :: MonadBuild m => Maybe Device -> m a -> m a
- withNameScope :: MonadBuild m => Text -> m a -> m a
- withNodeDependencies :: MonadBuild m => Set NodeName -> m a -> m a
Graph node types
newtype ControlNode Source #
A type of graph node which has no outputs. These nodes are valuable for causing side effects when they are run.
BuildResult ControlNode Source # | |
Nodes ControlNode Source # | |
(~) * a () => Fetchable ControlNode a Source # | |
Ops
explicitName :: Text -> PendingNodeName Source #
opDefWithName :: PendingNodeName -> OpType -> OpDef Source #
opName :: Lens' OpDef PendingNodeName Source #
opControlInputs :: Lens' OpDef [NodeName] Source #
The Build monad
data GraphState Source #
Monad m => MonadState GraphState (BuildT m) Source # | |
renderedNodeDefs :: Lens' GraphState (Map NodeName NodeDef) Source #
An action for building nodes in a TensorFlow graph.
Used to manage build state internally as part of the Session
monad.
MonadTrans BuildT Source # | |
TensorKind Build Source # | |
Monad m => MonadState GraphState (BuildT m) Source # | |
Monad m => Monad (BuildT m) Source # | |
Functor m => Functor (BuildT m) Source # | |
MonadFix m => MonadFix (BuildT m) Source # | |
Monad m => Applicative (BuildT m) Source # | |
MonadIO m => MonadIO (BuildT m) Source # | |
MonadThrow m => MonadThrow (BuildT m) Source # | |
MonadMask m => MonadMask (BuildT m) Source # | |
MonadCatch m => MonadCatch (BuildT m) Source # | |
Monad m => MonadBuild (BuildT m) Source # | |
TensorTypes as => PureResult (TensorList Build as) Source # | |
PureResult (Tensor Build a) Source # | |
class Monad m => MonadBuild m where Source #
Lift a Build
action into a monad, including any explicit op renderings.
Monad m => MonadBuild (BuildT m) Source # | |
Monad m => MonadBuild (SessionT m) Source # | |
addInitializer :: MonadBuild m => ControlNode -> m () Source #
Registers the given node to be executed before the next
run
.
hoistBuildT :: (forall a. m a -> n a) -> BuildT m b -> BuildT n b Source #
This is Control.Monad.Morph.hoist sans the dependency.
evalBuildT :: Monad m => BuildT m a -> m a Source #
runBuildT :: BuildT m a -> m (a, GraphState) Source #
asGraphDef :: Build a -> GraphDef Source #
Produce a GraphDef proto representation of the nodes that are rendered in
the given Build
action.
addGraphDef :: MonadBuild m => GraphDef -> m () Source #
flushInitializers :: Monad m => BuildT m [NodeName] Source #
Get all the initializers that have accumulated so far, and clear that buffer.
flushNodeBuffer :: MonadBuild m => m [NodeDef] Source #
Get all the NodeDefs that have accumulated so far, and clear that buffer.
summaries :: Lens' GraphState [Output] Source #
Creating and looking up Ops
getOrAddOp :: OpDef -> Build NodeName Source #
Render the given op if it hasn't been rendered already, and return its name.
addNewOp :: OpDef -> Build NodeName Source #
Add a new node for a given OpDef
. This is used for making "stateful" ops
which are not safe to dedup (e.g, "variable" and "assign").
encodeOutput :: Output -> Text Source #
Turn an Output
into a string representation for the TensorFlow
foreign APIs.
Modifying all nodes in a Build action
withStateLens :: MonadBuild m => Lens' GraphState a -> (a -> a) -> m b -> m b Source #
Modify some part of the state, run an action, and restore the state after that action is done.
withDevice :: MonadBuild m => Maybe Device -> m a -> m a Source #
Set a device for all nodes rendered in the given Build
action
(unless further overridden by another use of withDevice).
withNameScope :: MonadBuild m => Text -> m a -> m a Source #
Prepend a scope to all nodes rendered in the given Build
action.
withNodeDependencies :: MonadBuild m => Set NodeName -> m a -> m a Source #
Add control inputs to all nodes rendered in the given Build
action.