{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module TensorFlow.ControlFlow
(
withControlDependencies
, group
, noOp
) where
import TensorFlow.BuildOp
import TensorFlow.Build
import TensorFlow.Nodes
withControlDependencies :: (MonadBuild m, Nodes t) => t -> m a -> m a
withControlDependencies :: t -> m a -> m a
withControlDependencies deps :: t
deps act :: m a
act = do
Set NodeName
nodes <- Build (Set NodeName) -> m (Set NodeName)
forall (m :: * -> *) a. MonadBuild m => Build a -> m a
build (Build (Set NodeName) -> m (Set NodeName))
-> Build (Set NodeName) -> m (Set NodeName)
forall a b. (a -> b) -> a -> b
$ t -> Build (Set NodeName)
forall t. Nodes t => t -> Build (Set NodeName)
getNodes t
deps
Set NodeName -> m a -> m a
forall (m :: * -> *) a. MonadBuild m => Set NodeName -> m a -> m a
withNodeDependencies Set NodeName
nodes m a
act
group :: (MonadBuild m, Nodes t) => t -> m ControlNode
group :: t -> m ControlNode
group deps :: t
deps = t -> m ControlNode -> m ControlNode
forall (m :: * -> *) t a.
(MonadBuild m, Nodes t) =>
t -> m a -> m a
withControlDependencies t
deps m ControlNode
forall (m :: * -> *). MonadBuild m => m ControlNode
noOp
noOp :: MonadBuild m => m ControlNode
noOp :: m ControlNode
noOp = Build ControlNode -> m ControlNode
forall (m :: * -> *) a. MonadBuild m => Build a -> m a
build (Build ControlNode -> m ControlNode)
-> Build ControlNode -> m ControlNode
forall a b. (a -> b) -> a -> b
$ [Int64] -> OpDef -> Build ControlNode
forall a. BuildResult a => [Int64] -> OpDef -> Build a
buildOp [] (OpDef -> Build ControlNode) -> OpDef -> Build ControlNode
forall a b. (a -> b) -> a -> b
$ OpType -> OpDef
opDef "NoOp"