on master help sign in
Add some benchmarks
commitbd881faf2b3c5598fef7c1e367d5adcaade310a0 authorHuw Campbell <huw.campbell@ambiata.com> dateMon 12 Dec 2016, 10:20 (10 years ago) parentc0bb69d
2 files changed+44
bench/bench.hs+26 grenade.cabal+18
bench/bench.hsnew file+26
@@ -0,0 +1,26 @@
1+import Criterion.Main
2+
3+import Grenade.Layers.Internal.Convolution
4+import Grenade.Layers.Internal.Pooling
5+
6+import Numeric.LinearAlgebra
7+
8+main :: IO ()
9+main = defaultMain [
10+ bgroup "im2col" [ bench "im2col 3x4" $ whnf (im2colUnsafe 2 2 1 1) ((3><4) [1..])
11+ , bench "im2col 28x28" $ whnf (im2colUnsafe 5 5 1 1) ((28><28) [1..])
12+ , bench "im2col 100x100" $ whnf (im2colUnsafe 10 10 1 1) ((100><100) [1..])
13+ ]
14+ , bgroup "col2im" [ bench "col2im 3x4" $ whnf (col2imUnsafe 2 2 1 1 3 4) ((6><4) [1..])
15+ , bench "col2im 28x28" $ whnf (col2imUnsafe 5 5 1 1 28 28) ((576><25) [1..])
16+ , bench "col2im 100x100" $ whnf (col2imUnsafe 10 10 1 1 100 100) ((8281><100) [1..])
17+ ]
18+ , bgroup "poolfw" [ bench "poolforwards 3x4" $ whnf (poolForward 2 2 1 1 2 3) ((3><4) [1..])
19+ , bench "poolforwards 28x28" $ whnf (poolForward 5 5 1 1 4 24) ((28><28) [1..])
20+ , bench "poolforwards 100x100" $ whnf (poolForward 10 10 1 1 91 91) ((100><100) [1..])
21+ ]
22+ , bgroup "poolbw" [ bench "poolbackwards 3x4" $ whnf (poolBackward 2 2 1 1 ((3><4) [1..])) ((2><3) [1..])
23+ , bench "poolbackwards 28x28" $ whnf (poolBackward 5 5 1 1 ((28><28) [1..])) ((24><24) [1..])
24+ , bench "poolbackwards 100x100" $ whnf (poolBackward 10 10 1 1 ((100><100) [1..])) ((91><91) [1..])
25+ ]
26+ ]
grenade.cabal+18
@@ -104,3 +104,21 @@ test-suite test
104104 , text == 1.2.*
105105 , QuickCheck >= 2.7 && < 2.9
106106 , quickcheck-instances == 0.3.*
107+
108+
109+benchmark bench
110+ type: exitcode-stdio-1.0
111+
112+ main-is: bench.hs
113+
114+ ghc-options: -Wall -threaded -O2
115+
116+ hs-source-dirs:
117+ bench
118+
119+ build-depends:
120+ base >= 3 && < 5
121+ , bytestring == 0.10.*
122+ , criterion == 1.1.*
123+ , grenade
124+ , hmatrix