@@ -23,8 +23,6 @@ import Data.Singletons
2323import Data.Singletons.Prelude.List
2424import Data.Singletons.TypeLits
2525
26−-- import Data.Type.Equality
27−
2826import Hedgehog
2927import qualified Hedgehog.Gen as Gen
3028import Hedgehog.Internal.Source
@@ -32,7 +30,12 @@ import Hedgehog.Internal.Property ( failWith )
3230
3331import Grenade
3432
33+#if MIN_VERSION_base(4,11,0)
34+import GHC.TypeLits hiding (natVal)
35+#else
3536import GHC.TypeLits
37+#endif
38+
3639import GHC.TypeLits.Witnesses
3740import Test.Hedgehog.Compat
3841import Test.Hedgehog.TypeLits
@@ -74,8 +77,9 @@ genNetwork =
7477 , pure (SomeNetwork (Elu :~> rest :: Network ( Elu ': layers ) ( h ': h ': hs )))
7578 , pure (SomeNetwork (Softmax :~> rest :: Network ( Softmax ': layers ) ( h ': h ': hs )))
7679 , do -- Reshape to two dimensions
77− let divisors n = 1 : [x | x <- [2..(n-1)], n `rem` x == 0]
78− let len = natVal l
80+ let divisors :: Integer -> [Integer]
81+ divisors n = 1 : [x | x <- [2..(n-1)], n `rem` x == 0]
82+ let len = fromIntegral $ natVal l
7983 rs <- Gen.element $ divisors len
8084 let cs = len `quot` rs
8185 case ( someNatVal rs, someNatVal cs, someNatVal len ) of
@@ -96,8 +100,8 @@ genNetwork =
96100 , do -- Build a convolution layer with one filter output
97101 -- Figure out some kernel sizes which work for this layer
98102 -- There must be a better way than this...
99− let output_r = natVal r
100− let output_c = natVal c
103+ let output_r = fromIntegral $ natVal r
104+ let output_c = fromIntegral $ natVal c
101105
102106 let ok extent kernel = [stride | stride <- [ 1 .. extent ], (extent - kernel) `mod` stride == 0]
103107
@@ -136,8 +140,8 @@ genNetwork =
136140 , do -- Build a convolution layer with one filter output
137141 -- Figure out some kernel sizes which work for this layer
138142 -- There must be a better way than this...
139− let output_r = natVal r
140− let output_c = natVal c
143+ let output_r = fromIntegral $ natVal r
144+ let output_c = fromIntegral $ natVal c
141145
142146 let ok extent kernel = [stride | stride <- [ 1 .. extent ], (extent - kernel) `mod` stride == 0]
143147
@@ -178,8 +182,8 @@ genNetwork =
178182 pure (SomeNetwork (conv :~> rest :: Network ( Convolution channels 1 kernelRows kernelCols strideRows strideCols ': layers ) ( ('D3 inRows inCols channels) ': h ': hs )))
179183 _ -> Gen.discard -- Can't occur
180184 , do -- Build a Pooling layer
181− let output_r = natVal r
182− let output_c = natVal c
185+ let output_r = fromIntegral $ natVal r
186+ let output_c = fromIntegral $ natVal c
183187
184188 let ok extent kernel = [stride | stride <- [ 1 .. extent ], (extent - kernel) `mod` stride == 0]
185189
@@ -215,8 +219,8 @@ genNetwork =
215219 pure (SomeNetwork (Pooling :~> rest :: Network ( Pooling kernelRows kernelCols strideRows strideCols ': layers ) ( ('D2 inRows inCols) ': h ': hs )))
216220 _ -> Gen.discard -- Can't occur
217221 , do -- Build a Pad layer
218− let output_r = natVal r
219− let output_c = natVal c
222+ let output_r = fromIntegral $ natVal r
223+ let output_c = fromIntegral $ natVal c
220224
221225 pad_left <- choose 0 (output_r - 1)
222226 pad_right <- choose 0 (output_r - 1 - pad_left)
@@ -242,8 +246,8 @@ genNetwork =
242246 pure (SomeNetwork (Pad :~> rest :: Network ( Pad padLeft padTop padRight padBottom ': layers ) ( ('D2 inputRows inputColumns) ': h ': hs )))
243247 _ -> Gen.discard -- Can't occur
244248 , do -- Build a Crop layer
245− let output_r = natVal r
246− let output_c = natVal c
249+ let output_r = fromIntegral $ natVal r
250+ let output_c = fromIntegral $ natVal c
247251
248252 crop_left <- choose 0 10
249253 crop_right <- choose 0 10
@@ -275,9 +279,9 @@ genNetwork =
275279 , do -- Build a convolution layer with one filter output
276280 -- Figure out some kernel sizes which work for this layer
277281 -- There must be a better way than this...
278− let output_r = natVal r
279− let output_c = natVal c
280− let output_f = natVal f
282+ let output_r = fromIntegral $ natVal r
283+ let output_c = fromIntegral $ natVal c
284+ let output_f = fromIntegral $ natVal f
281285
282286 let ok extent kernel = [stride | stride <- [ 1 .. extent ], (extent - kernel) `mod` stride == 0]
283287
@@ -318,9 +322,9 @@ genNetwork =
318322 pure (SomeNetwork (conv :~> rest :: Network ( Convolution channels filters kernelRows kernelCols strideRows strideCols ': layers ) ( ('D3 inRows inCols channels) ': h ': hs )))
319323 _ -> Gen.discard -- Can't occur
320324 , do -- Build a Pooling layer
321− let output_r = natVal r
322− let output_c = natVal c
323− let output_f = natVal f
325+ let output_r = fromIntegral $ natVal r
326+ let output_c = fromIntegral $ natVal c
327+ let output_f = fromIntegral $ natVal f
324328
325329 let ok extent kernel = [stride | stride <- [ 1 .. extent ], (extent - kernel) `mod` stride == 0]
326330
@@ -359,9 +363,9 @@ genNetwork =
359363 pure (SomeNetwork (Pooling :~> rest :: Network ( Pooling kernelRows kernelCols strideRows strideCols ': layers ) ( ('D3 inRows inCols filters) ': h ': hs )))
360364 _ -> Gen.discard -- Can't occur
361365 , do -- Build a Pad layer
362− let output_r = natVal r
363− let output_c = natVal c
364− let output_f = natVal f
366+ let output_r = fromIntegral $ natVal r
367+ let output_c = fromIntegral $ natVal c
368+ let output_f = fromIntegral $ natVal f
365369
366370 pad_left <- choose 0 (output_r - 1)
367371 pad_right <- choose 0 (output_r - 1 - pad_left)
@@ -389,9 +393,9 @@ genNetwork =
389393 pure (SomeNetwork (Pad :~> rest :: Network ( Pad padLeft padTop padRight padBottom ': layers ) ( ('D3 inputRows inputColumns filters) ': h ': hs )))
390394 _ -> Gen.discard -- Can't occur
391395 , do -- Build a Crop layer
392− let output_r = natVal r
393− let output_c = natVal c
394− let output_f = natVal f
396+ let output_r = fromIntegral $ natVal r
397+ let output_c = fromIntegral $ natVal c
398+ let output_f = fromIntegral $ natVal f
395399
396400 crop_left <- choose 0 10
397401 crop_right <- choose 0 10