on master help sign in
NoStarIsType and UndecidableInstances needed for ghc-8.6
0bc6bd5Claude Heiland-Allen
src/Grenade/Core/Shape.hs+2
@@ -8,6 +8,8 @@
8{-# LANGUAGE FlexibleContexts #-}
8{-# LANGUAGE FlexibleContexts #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE RankNTypes #-}
11+{-# LANGUAGE NoStarIsType #-}
12+{-# LANGUAGE UndecidableInstances #-}
11{-|
13{-|
12Module : Grenade.Core.Shape
14Module : Grenade.Core.Shape
13Description : Dependently typed shapes of data which are passed between layers of a network
15Description : Dependently typed shapes of data which are passed between layers of a network
src/Grenade/Layers/Concat.hs+4−1
@@ -8,6 +8,8 @@
8{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE FlexibleInstances #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE StandaloneDeriving #-}
10{-# LANGUAGE StandaloneDeriving #-}
11+{-# LANGUAGE NoStarIsType #-}
12+{-# LANGUAGE UndecidableInstances #-}
11{-|
13{-|
12Module : Grenade.Layers.Concat
14Module : Grenade.Layers.Concat
13Description : Concatenation layer
15Description : Concatenation layer
@@ -25,6 +27,7 @@ import Data.Serialize
25
27
26import Data.Singletons
28import Data.Singletons
27import GHC.TypeLits
29import GHC.TypeLits
30+import Data.Kind (Type)
28
31
29import Grenade.Core
32import Grenade.Core
30
33
@@ -43,7 +46,7 @@ import Numeric.LinearAlgebra.Static ( row, (===), splitRows, unrow, (#
43--
46--
44-- 3D images become 3D images with more channels. The sizes must be the same, one can use Pad
47-- 3D images become 3D images with more channels. The sizes must be the same, one can use Pad
45-- and Crop layers to ensure this is the case.
48-- and Crop layers to ensure this is the case.
46−data Concat :: Shape -> * -> Shape -> * -> * where
49+data Concat :: Shape -> Type -> Shape -> Type -> Type where
47 Concat :: x -> y -> Concat m x n y
50 Concat :: x -> y -> Concat m x n y
48
51
49instance (Show x, Show y) => Show (Concat m x n y) where
52instance (Show x, Show y) => Show (Concat m x n y) where
src/Grenade/Layers/Convolution.hs+5−2
@@ -8,6 +8,8 @@
8{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE FlexibleInstances #-}
9{-# LANGUAGE FlexibleInstances #-}
10{-# LANGUAGE FlexibleContexts #-}
10{-# LANGUAGE FlexibleContexts #-}
11+{-# LANGUAGE NoStarIsType #-}
12+{-# LANGUAGE UndecidableInstances #-}
11{-|
13{-|
12Module : Grenade.Layers.Convolution
14Module : Grenade.Layers.Convolution
13Description : Convolution layer
15Description : Convolution layer
@@ -35,6 +37,7 @@ import GHC.TypeLits hiding (natVal)
35#else
37#else
36import GHC.TypeLits
38import GHC.TypeLits
37#endif
39#endif
40+import Data.Kind (Type)
38
41
39import Numeric.LinearAlgebra hiding ( uniformSample, konst )
42import Numeric.LinearAlgebra hiding ( uniformSample, konst )
40import qualified Numeric.LinearAlgebra as LA
43import qualified Numeric.LinearAlgebra as LA
@@ -61,7 +64,7 @@ data Convolution :: Nat -- Number of channels, for the first layer this could be
61 -> Nat -- The number of column in the kernel filter
64 -> Nat -- The number of column in the kernel filter
62 -> Nat -- The row stride of the convolution filter
65 -> Nat -- The row stride of the convolution filter
63 -> Nat -- The columns stride of the convolution filter
66 -> Nat -- The columns stride of the convolution filter
64− -> * where
67+ -> Type where
65 Convolution :: ( KnownNat channels
68 Convolution :: ( KnownNat channels
66 , KnownNat filters
69 , KnownNat filters
67 , KnownNat kernelRows
70 , KnownNat kernelRows
@@ -80,7 +83,7 @@ data Convolution' :: Nat -- Number of channels, for the first layer this could b
80 -> Nat -- The number of column in the kernel filter
83 -> Nat -- The number of column in the kernel filter
81 -> Nat -- The row stride of the convolution filter
84 -> Nat -- The row stride of the convolution filter
82 -> Nat -- The columns stride of the convolution filter
85 -> Nat -- The columns stride of the convolution filter
83− -> * where
86+ -> Type where
84 Convolution' :: ( KnownNat channels
87 Convolution' :: ( KnownNat channels
85 , KnownNat filters
88 , KnownNat filters
86 , KnownNat kernelRows
89 , KnownNat kernelRows
src/Grenade/Layers/Crop.hs+4−1
@@ -6,6 +6,8 @@
6{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE FlexibleContexts #-}
7{-# LANGUAGE FlexibleContexts #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9+{-# LANGUAGE NoStarIsType #-}
10+{-# LANGUAGE UndecidableInstances #-}
9{-|
11{-|
10Module : Grenade.Layers.Crop
12Module : Grenade.Layers.Crop
11Description : Cropping layer
13Description : Cropping layer
@@ -27,6 +29,7 @@ import GHC.TypeLits hiding (natVal)
27#else
29#else
28import GHC.TypeLits
30import GHC.TypeLits
29#endif
31#endif
32+import Data.Kind (Type)
30
33
31import Grenade.Core
34import Grenade.Core
32import Grenade.Layers.Internal.Pad
35import Grenade.Layers.Internal.Pad
@@ -38,7 +41,7 @@ import Numeric.LinearAlgebra.Static (extract, create)
38data Crop :: Nat
41data Crop :: Nat
39 -> Nat
42 -> Nat
40 -> Nat
43 -> Nat
41− -> Nat -> * where
44+ -> Nat -> Type where
42 Crop :: Crop cropLeft cropTop cropRight cropBottom
45 Crop :: Crop cropLeft cropTop cropRight cropBottom
43
46
44instance Show (Crop cropLeft cropTop cropRight cropBottom) where
47instance Show (Crop cropLeft cropTop cropRight cropBottom) where
src/Grenade/Layers/Deconvolution.hs+5−2
@@ -8,6 +8,8 @@
8{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE FlexibleInstances #-}
9{-# LANGUAGE FlexibleInstances #-}
10{-# LANGUAGE FlexibleContexts #-}
10{-# LANGUAGE FlexibleContexts #-}
11+{-# LANGUAGE NoStarIsType #-}
12+{-# LANGUAGE UndecidableInstances #-}
11{-|
13{-|
12Module : Grenade.Layers.Deconvolution
14Module : Grenade.Layers.Deconvolution
13Description : Deconvolution layer
15Description : Deconvolution layer
@@ -39,6 +41,7 @@ import GHC.TypeLits hiding (natVal)
39#else
41#else
40import GHC.TypeLits
42import GHC.TypeLits
41#endif
43#endif
44+import Data.Kind (Type)
42
45
43import Numeric.LinearAlgebra hiding ( uniformSample, konst )
46import Numeric.LinearAlgebra hiding ( uniformSample, konst )
44import qualified Numeric.LinearAlgebra as LA
47import qualified Numeric.LinearAlgebra as LA
@@ -60,7 +63,7 @@ data Deconvolution :: Nat -- Number of channels, for the first layer this could
60 -> Nat -- The number of column in the kernel filter
63 -> Nat -- The number of column in the kernel filter
61 -> Nat -- The row stride of the Deconvolution filter
64 -> Nat -- The row stride of the Deconvolution filter
62 -> Nat -- The columns stride of the Deconvolution filter
65 -> Nat -- The columns stride of the Deconvolution filter
63− -> * where
66+ -> Type where
64 Deconvolution :: ( KnownNat channels
67 Deconvolution :: ( KnownNat channels
65 , KnownNat filters
68 , KnownNat filters
66 , KnownNat kernelRows
69 , KnownNat kernelRows
@@ -79,7 +82,7 @@ data Deconvolution' :: Nat -- Number of channels, for the first layer this could
79 -> Nat -- The number of column in the kernel filter
82 -> Nat -- The number of column in the kernel filter
80 -> Nat -- The row stride of the Deconvolution filter
83 -> Nat -- The row stride of the Deconvolution filter
81 -> Nat -- The columns stride of the Deconvolution filter
84 -> Nat -- The columns stride of the Deconvolution filter
82− -> * where
85+ -> Type where
83 Deconvolution' :: ( KnownNat channels
86 Deconvolution' :: ( KnownNat channels
84 , KnownNat filters
87 , KnownNat filters
85 , KnownNat kernelRows
88 , KnownNat kernelRows
src/Grenade/Layers/Pad.hs+4−1
@@ -6,6 +6,8 @@
6{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE FlexibleContexts #-}
8{-# LANGUAGE FlexibleContexts #-}
9+{-# LANGUAGE NoStarIsType #-}
10+{-# LANGUAGE UndecidableInstances #-}
9{-|
11{-|
10Module : Grenade.Core.Pad
12Module : Grenade.Core.Pad
11Description : Padding layer for 2D and 3D images
13Description : Padding layer for 2D and 3D images
@@ -27,6 +29,7 @@ import GHC.TypeLits hiding (natVal)
27#else
29#else
28import GHC.TypeLits
30import GHC.TypeLits
29#endif
31#endif
32+import Data.Kind (Type)
30
33
31import Grenade.Core
34import Grenade.Core
32import Grenade.Layers.Internal.Pad
35import Grenade.Layers.Internal.Pad
@@ -40,7 +43,7 @@ import Numeric.LinearAlgebra.Static (extract, create)
40data Pad :: Nat
43data Pad :: Nat
41 -> Nat
44 -> Nat
42 -> Nat
45 -> Nat
43− -> Nat -> * where
46+ -> Nat -> Type where
44 Pad :: Pad padLeft padTop padRight padBottom
47 Pad :: Pad padLeft padTop padRight padBottom
45
48
46instance Show (Pad padLeft padTop padRight padBottom) where
49instance Show (Pad padLeft padTop padRight padBottom) where
src/Grenade/Layers/Pooling.hs+4−1
@@ -7,6 +7,8 @@
7{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE FlexibleContexts #-}
9{-# LANGUAGE FlexibleContexts #-}
10+{-# LANGUAGE NoStarIsType #-}
11+{-# LANGUAGE UndecidableInstances #-}
10{-|
12{-|
11Module : Grenade.Core.Pooling
13Module : Grenade.Core.Pooling
12Description : Max Pooling layer for 2D and 3D images
14Description : Max Pooling layer for 2D and 3D images
@@ -28,6 +30,7 @@ import GHC.TypeLits hiding (natVal)
28#else
30#else
29import GHC.TypeLits
31import GHC.TypeLits
30#endif
32#endif
33+import Data.Kind (Type)
31
34
32import Grenade.Core
35import Grenade.Core
33import Grenade.Layers.Internal.Pooling
36import Grenade.Layers.Internal.Pooling
@@ -42,7 +45,7 @@ import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRow
42-- The kernel size dictates which input and output sizes will "fit". Fitting the equation:
45-- The kernel size dictates which input and output sizes will "fit". Fitting the equation:
43-- `out = (in - kernel) / stride + 1` for both dimensions.
46-- `out = (in - kernel) / stride + 1` for both dimensions.
44--
47--
45−data Pooling :: Nat -> Nat -> Nat -> Nat -> * where
48+data Pooling :: Nat -> Nat -> Nat -> Nat -> Type where
46 Pooling :: Pooling kernelRows kernelColumns strideRows strideColumns
49 Pooling :: Pooling kernelRows kernelColumns strideRows strideColumns
47
50
48instance Show (Pooling k k' s s') where
51instance Show (Pooling k k' s s') where
src/Grenade/Layers/Reshape.hs+2
@@ -3,6 +3,8 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleContexts #-}
6+{-# LANGUAGE NoStarIsType #-}
7+{-# LANGUAGE UndecidableInstances #-}
6{-|
8{-|
7Module : Grenade.Layers.Reshape
9Module : Grenade.Layers.Reshape
8Description : Multipurpose reshaping layer
10Description : Multipurpose reshaping layer
src/Grenade/Recurrent/Layers/ConcatRecurrent.hs+1
@@ -8,6 +8,7 @@
8{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE FlexibleInstances #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE StandaloneDeriving #-}
10{-# LANGUAGE StandaloneDeriving #-}
11+{-# LANGUAGE UndecidableInstances #-}
11{-|
12{-|
12Module : Grenade.Layers.Concat
13Module : Grenade.Layers.Concat
13Description : Concatenation layer
14Description : Concatenation layer