Skip to content

Commit

Permalink
Update to current proto-lens packages. (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesperber authored May 21, 2020
1 parent 0f322b2 commit 568c9b6
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 40 deletions.
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-14.4
resolver: lts-15.11

packages:
- tensorflow
Expand Down
6 changes: 3 additions & 3 deletions tensorflow-core-ops/tensorflow-core-ops.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ library
exposed-modules: TensorFlow.GenOps.Core
autogen-modules: TensorFlow.GenOps.Core
build-depends: bytestring
, proto-lens >= 0.4.0 && < 0.6.0
, proto-lens == 0.6.*
, tensorflow == 0.2.*
, base >= 4.7 && < 5
, lens-family
, lens-family == 2.*
, text
default-language: Haskell2010

custom-setup
setup-depends: Cabal
, bytestring
, directory
, proto-lens >= 0.4.0 && < 0.6.0
, proto-lens == 0.6.*
, tensorflow-opgen == 0.2.*
, tensorflow == 0.2.*
, base >= 4.7 && < 5
Expand Down
4 changes: 2 additions & 2 deletions tensorflow-logging/tensorflow-logging.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ library
, exceptions
, filepath
, hostname
, lens-family
, proto-lens >= 0.4.0 && < 0.6.0
, lens-family == 2.*
, proto-lens == 0.6.*
, resourcet
, stm
, stm-chans
Expand Down
1 change: 0 additions & 1 deletion tensorflow-mnist/src/TensorFlow/Examples/MNIST/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Control.Monad (when, liftM)
import Data.Binary.Get (Get, runGet, getWord32be, getLazyByteString)
import Data.ByteString.Lazy (toStrict, readFile)
import Data.List.Split (chunksOf)
import Data.Monoid ((<>))
import Data.ProtoLens (Message, decodeMessageOrDie)
import Data.Text (Text)
import Data.Word (Word8, Word32)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow-mnist/tensorflow-mnist.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ library
exposed-modules: TensorFlow.Examples.MNIST.Parse
, TensorFlow.Examples.MNIST.TrainedGraph
other-modules: Paths_tensorflow_mnist
build-depends: proto-lens >= 0.4.0 && < 0.6.0
build-depends: proto-lens == 0.6.*
, base >= 4.7 && < 5
, binary
, bytestring
, filepath
, lens-family
, lens-family >= 2.0
, containers
, split
, tensorflow-proto == 0.2.*
Expand Down
1 change: 0 additions & 1 deletion tensorflow-opgen/src/TensorFlow/OpGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import Proto.Tensorflow.Core.Framework.OpDef_Fields
import Proto.Tensorflow.Core.Framework.Types (DataType(..))
import System.FilePath (takeBaseName)
import TensorFlow.OpGen.ParsedOp
import Data.Semigroup ((<>))
import Text.PrettyPrint.Mainland
( Doc
, (<+>)
Expand Down
1 change: 0 additions & 1 deletion tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Data.Char (toUpper, toLower)
import Data.List (sortBy)
import Data.List.NonEmpty (NonEmpty, nonEmpty)
import Data.Maybe (mapMaybe)
import Data.Monoid ((<>))
import Data.Ord (comparing)
import qualified Data.Set as Set
import Data.Text (Text)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow-opgen/tensorflow-opgen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ library
hs-source-dirs: src
exposed-modules: TensorFlow.OpGen.ParsedOp
, TensorFlow.OpGen
build-depends: proto-lens >= 0.4.0 && < 0.6.0
build-depends: proto-lens == 0.6.*
, tensorflow-proto == 0.2.*
, base >= 4.7 && < 5
, bytestring
, containers
, filepath
, lens-family
, lens-family == 2.*
, mainland-pretty
, optparse-applicative
, semigroups
Expand Down
6 changes: 3 additions & 3 deletions tensorflow-ops/src/TensorFlow/Gradient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ import Data.ProtoLens.TextFormat (showMessage)
import Data.Set (Set)
import Data.Text (Text)
import Data.Tuple (swap)
import Lens.Family2 (Lens', view, (&), (^.), (.~), (%~))
import Lens.Family2 (Lens', view, (&), (^.), (.~), (%~), under)
import Lens.Family2.State.Strict (uses)
import Lens.Family2.Stock (at, intAt)
import Lens.Family2.Unchecked (lens, iso)
import Lens.Family2.Unchecked (lens, adapter)
import Prelude hiding (sum, tanh)
import Text.Printf (printf)
import qualified Data.Graph.Inductive.Basic as FGL
Expand Down Expand Up @@ -244,7 +244,7 @@ _ `safeIndex` n | n < 0 = Nothing

-- Copy of http://hackage.haskell.org/package/lens-3.9.0.2/docs/Control-Lens-Iso.html#v%3anon
anon :: a -> (a -> Bool) -> Lens' (Maybe a) a
anon a p = iso (fromMaybe a) go where
anon a p = under (adapter (fromMaybe a) go) where
go b | p b = Nothing
| otherwise = Just b

Expand Down
1 change: 0 additions & 1 deletion tensorflow-ops/src/TensorFlow/Variable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonadFailDesugaring #-}
module TensorFlow.Variable
( Variable
, variable
Expand Down
4 changes: 2 additions & 2 deletions tensorflow-ops/tensorflow-ops.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ library
, TensorFlow.NN
, TensorFlow.Queue
, TensorFlow.Variable
build-depends: proto-lens >= 0.4.0 && < 0.6.0
build-depends: proto-lens == 0.6.*
, base >= 4.7 && < 5
, bytestring
, fgl
, mtl
, data-default
, lens-family
, lens-family == 2.*
, containers
, tensorflow == 0.2.*
, tensorflow-proto == 0.2.*
Expand Down
1 change: 0 additions & 1 deletion tensorflow-ops/tests/EmbeddingOpsTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoMonadFailDesugaring #-}

-- | Tests for EmbeddingOps.
module Main where
Expand Down
3 changes: 1 addition & 2 deletions tensorflow-ops/tests/GradientTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoMonadFailDesugaring #-}

import Data.Int (Int32, Int64)
import Data.List (sort)
Expand All @@ -33,7 +32,7 @@ import Control.Monad(forM_, replicateM, zipWithM)
import Control.Monad.IO.Class (liftIO)

import qualified TensorFlow.Core as TF
import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput', max, maximum, resizeBilinear', tile, pad, batchToSpaceND, spaceToBatchND, squeeze, sqrt, slice, shape, diag, depthwiseConv2dNative', depthwiseConv2dNativeBackpropInput', batchMatMul, batchMatMul', sum, conjugateTranspose)
import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput', max, maximum, resizeBilinear', tile, pad, batchToSpaceND, spaceToBatchND, squeeze, sqrt, slice, shape, diag, depthwiseConv2dNative', depthwiseConv2dNativeBackpropInput', batchMatMul, batchMatMul', conjugateTranspose)
import qualified TensorFlow.Gradient as TF
import qualified TensorFlow.Ops as TF hiding (zeroInitializedVariable, shape)
import qualified TensorFlow.Output as TF
Expand Down
6 changes: 3 additions & 3 deletions tensorflow-proto/tensorflow-proto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ library
, Proto.Tensorflow.Core.Util.SavedTensorSlice_Fields
, Proto.Tensorflow.Core.Util.TestLog
, Proto.Tensorflow.Core.Util.TestLog_Fields
build-depends: proto-lens >= 0.4.0 && < 0.6.0
, proto-lens-runtime >= 0.4.0 && < 0.6.0
, proto-lens-protobuf-types >= 0.4.0 && < 0.6.0
build-depends: proto-lens == 0.6.*
, proto-lens-runtime == 0.6.*
, proto-lens-protobuf-types == 0.6.*
, base >= 4.7 && < 5
default-language: Haskell2010
include-dirs: .
Expand Down
1 change: 0 additions & 1 deletion tensorflow-records/tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Main where

import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import Data.Monoid ((<>))
import Data.Word (Word8)
import Data.Serialize (runGet, runPut)
import Test.Framework (Test, defaultMain)
Expand Down
2 changes: 0 additions & 2 deletions tensorflow/src/TensorFlow/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ import Data.ProtoLens.Message(defMessage)
import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
import Control.Monad.Fix (MonadFix(..))
import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Fail (MonadFail(..))
import Control.Monad.Trans.Class (MonadTrans(..))
import Control.Monad.Trans.State.Strict(StateT(..), mapStateT, evalStateT)
import Data.Functor.Identity (Identity(..))
import qualified Data.Map.Strict as Map
import Data.Monoid ((<>))
import qualified Data.Set as Set
import Data.Set (Set)
import Data.String (IsString(..))
Expand Down
1 change: 0 additions & 1 deletion tensorflow/src/TensorFlow/Internal/VarInt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module TensorFlow.Internal.VarInt
import Data.Attoparsec.ByteString as Parse
import Data.Bits
import Data.ByteString.Lazy.Builder as Builder
import Data.Monoid ((<>))
import Data.Word (Word64)

-- | Decode an unsigned varint.
Expand Down
1 change: 0 additions & 1 deletion tensorflow/src/TensorFlow/Nodes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module TensorFlow.Nodes where
import Control.Applicative (liftA2, liftA3)
import Data.Functor.Identity (Identity)
import Data.Map.Strict (Map)
import Data.Monoid ((<>))
import Data.Set (Set)
import Data.Text (Text)
import qualified Data.Map.Strict as Map
Expand Down
2 changes: 0 additions & 2 deletions tensorflow/src/TensorFlow/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ module TensorFlow.Session (

import Data.ProtoLens.Message(defMessage)
import Control.Monad (forever, unless, void)
import Control.Monad.Fail (MonadFail(..))
import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Trans.Class (MonadTrans, lift)
import Control.Monad.Trans.Reader (ReaderT(..), ask, asks)
import Data.ByteString (ByteString)
import Data.Default (Default, def)
import Data.Monoid ((<>))
import Data.ProtoLens (showMessage)
import Data.Set (Set)
import Data.Text.Encoding (encodeUtf8)
Expand Down
11 changes: 5 additions & 6 deletions tensorflow/src/TensorFlow/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ import Data.Functor.Identity (Identity(..))
import Data.Complex (Complex)
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Maybe (fromMaybe)
import Data.Monoid ((<>))
import Data.ProtoLens.TextFormat (showMessageShort)
import Data.Proxy (Proxy(..))
import Data.String (IsString)
import Data.Word (Word8, Word16, Word32, Word64)
import Foreign.Storable (Storable)
import GHC.Exts (Constraint, IsList(..))
import Lens.Family2 (Lens', view, (&), (.~), (^..))
import Lens.Family2.Unchecked (iso)
import Lens.Family2 (Lens', view, (&), (.~), (^..), under)
import Lens.Family2.Unchecked (adapter)
import Text.Printf (printf)
import qualified Data.Attoparsec.ByteString as Atto
import Data.ByteString (ByteString)
Expand Down Expand Up @@ -164,7 +163,7 @@ instance TensorType Int64 where
tensorVal = int64Val

integral :: Integral a => Lens' [Int32] [a]
integral = iso (fmap fromIntegral) (fmap fromIntegral)
integral = under (adapter (fmap fromIntegral) (fmap fromIntegral))

instance TensorType Word8 where
tensorType _ = DT_UINT8
Expand Down Expand Up @@ -395,15 +394,15 @@ instance IsList Shape where
toList (Shape ss) = toList ss

protoShape :: Lens' TensorShapeProto Shape
protoShape = iso protoToShape shapeToProto
protoShape = under (adapter protoToShape shapeToProto)
where
protoToShape p = fromMaybe (error msg) (view protoMaybeShape p)
where msg = "Can't convert TensorShapeProto with unknown rank to Shape: "
++ showMessageShort p
shapeToProto s' = defMessage & protoMaybeShape .~ Just s'

protoMaybeShape :: Lens' TensorShapeProto (Maybe Shape)
protoMaybeShape = iso protoToShape shapeToProto
protoMaybeShape = under (adapter protoToShape shapeToProto)
where
protoToShape :: TensorShapeProto -> Maybe Shape
protoToShape p =
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/tensorflow.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library
, TensorFlow.Types
other-modules: TensorFlow.Internal.Raw
build-tools: c2hs
build-depends: proto-lens >= 0.4.0 && < 0.6.0
build-depends: proto-lens == 0.6.*
, tensorflow-proto == 0.2.*
, base >= 4.7 && < 5
, async
Expand All @@ -46,7 +46,7 @@ library
, data-default
, exceptions
, fgl
, lens-family
, lens-family == 2.*
, mainland-pretty
, mtl
, semigroups
Expand Down

0 comments on commit 568c9b6

Please sign in to comment.