on master help sign in
Tests
commit670f2d952fea9fdded0b850b107be839718f2a54 authorHuw Campbell <huw.campbell@ambiata.com> dateThu 8 Dec 2016, 09:03 (10 years ago) parentb090b5f
6 files changed+111−118
grenade.cabal+3−1 src/Grenade/Layers/Convolution.hs+9−13 src/Grenade/Layers/Convolution/Internal.hs → src/Grenade/Layers/Internal/Convolution.hs+42−52 src/Grenade/Layers/Internal/Pooling.hs+48 src/Grenade/Layers/Pooling.hs+2−45 test/Test/Grenade/Layers/Convolution.hs+7−7
grenade.cabal+3−1
@@ -40,7 +40,6 @@ library
4040 Grenade.Core.Shape
4141 Grenade.Layers.Crop
4242 Grenade.Layers.Convolution
43− Grenade.Layers.Convolution.Internal
4443 Grenade.Layers.Dropout
4544 Grenade.Layers.FullyConnected
4645 Grenade.Layers.Flatten
@@ -51,6 +50,9 @@ library
5150 Grenade.Layers.Pad
5251 Grenade.Layers.Pooling
5352
53+ Grenade.Layers.Internal.Convolution
54+ Grenade.Layers.Internal.Pooling
55+
5456
5557executable feedforward
5658 ghc-options: -Wall -threaded -O2
src/Grenade/Layers/Convolution.hs+9−13
@@ -31,7 +31,7 @@ import Numeric.LinearAlgebra.Static hiding ((|||), build, toRows)
3131import Grenade.Core.Network
3232import Grenade.Core.Shape
3333import Grenade.Core.Vector
34−import Grenade.Layers.Convolution.Internal
34+import Grenade.Layers.Internal.Convolution
3535
3636-- | A convolution layer for a neural network.
3737-- This uses the im2col convolution trick popularised by Caffe, which essentially turns the
@@ -149,15 +149,13 @@ instance ( KnownNat kernelRows
149149 runForwards (Convolution kernel _) (S2D' input) =
150150 let ex = extract input
151151 ek = extract kernel
152− ix = fromIntegral $ natVal (Proxy :: Proxy inputRows)
153− iy = fromIntegral $ natVal (Proxy :: Proxy inputCols)
154152 kx = fromIntegral $ natVal (Proxy :: Proxy kernelRows)
155153 ky = fromIntegral $ natVal (Proxy :: Proxy kernelCols)
156154 sx = fromIntegral $ natVal (Proxy :: Proxy strideRows)
157155 sy = fromIntegral $ natVal (Proxy :: Proxy strideCols)
158156 ox = fromIntegral $ natVal (Proxy :: Proxy outputRows)
159157 oy = fromIntegral $ natVal (Proxy :: Proxy outputCols)
160− c = im2colUnsafe kx ky sx sy ix iy ex
158+ c = im2colUnsafe kx ky sx sy ex
161159 mt = c LA.<> ek
162160 r = col2vidUnsafe 1 1 1 1 ox oy mt
163161 rs = fmap (fromJust . create) r
@@ -173,14 +171,13 @@ instance ( KnownNat kernelRows
173171 sy = fromIntegral $ natVal (Proxy :: Proxy strideCols)
174172 ox = fromIntegral $ natVal (Proxy :: Proxy outputRows)
175173 oy = fromIntegral $ natVal (Proxy :: Proxy outputCols)
176− fl = fromIntegral $ natVal (Proxy :: Proxy filters)
177174
178− c = im2colUnsafe kx ky sx sy ix iy ex
175+ c = im2colUnsafe kx ky sx sy ex
179176
180177 eo = vecToList $ fmap extract dEdy
181178 ek = extract kernel
182179
183− vs = vid2colUnsafe fl 1 1 1 1 ox oy eo
180+ vs = vid2colUnsafe 1 1 1 1 ox oy eo
184181
185182 kN = fromJust . create $ tr c LA.<> vs
186183 dW = vs LA.<> tr ek
@@ -216,8 +213,8 @@ instance ( KnownNat kernelRows
216213 sy = fromIntegral $ natVal (Proxy :: Proxy strideCols)
217214 ox = fromIntegral $ natVal (Proxy :: Proxy outputRows)
218215 oy = fromIntegral $ natVal (Proxy :: Proxy outputCols)
219− ch = fromIntegral $ natVal (Proxy :: Proxy channels)
220− c = vid2colUnsafe ch kx ky sx sy ix iy ex
216+
217+ c = vid2colUnsafe kx ky sx sy ix iy ex
221218 mt = c LA.<> ek
222219 r = col2vidUnsafe 1 1 1 1 ox oy mt
223220 rs = fmap (fromJust . create) r
@@ -232,14 +229,13 @@ instance ( KnownNat kernelRows
232229 sy = fromIntegral $ natVal (Proxy :: Proxy strideCols)
233230 ox = fromIntegral $ natVal (Proxy :: Proxy outputRows)
234231 oy = fromIntegral $ natVal (Proxy :: Proxy outputCols)
235− ch = fromIntegral $ natVal (Proxy :: Proxy channels)
236− fl = fromIntegral $ natVal (Proxy :: Proxy filters)
237− c = vid2colUnsafe ch kx ky sx sy ix iy ex
232+
233+ c = vid2colUnsafe kx ky sx sy ix iy ex
238234
239235 eo = vecToList $ fmap extract dEdy
240236 ek = extract kernel
241237
242− vs = vid2colUnsafe fl 1 1 1 1 ox oy eo
238+ vs = vid2colUnsafe 1 1 1 1 ox oy eo
243239
244240 kN = fromJust . create $ tr c LA.<> vs
245241
src/Grenade/Layers/Convolution/Internal.hs → src/Grenade/Layers/Internal/Convolution.hsrenamed+42−52
@@ -1,4 +1,4 @@
1−module Grenade.Layers.Convolution.Internal (
1+module Grenade.Layers.Internal.Convolution (
22 im2col
33-- , im2colUnsafe
44 , vid2col
@@ -72,7 +72,7 @@ fittingStart width kernel steps =
7272 | left + kernel == width
7373 = [left]
7474 | otherwise
75− = error "Kernel and step do not fit in matrix."
75+ = [] -- error "Kernel and step do not fit in matrix."
7676 in go 0
7777
7878col2imFit :: [(Int,Int)] -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
@@ -119,14 +119,9 @@ col2imFit starts krows kcols drows dcols m =
119119-- }
120120-- }
121121
122−
123−-- let starts = fittingStart (cols m) (krows * kcols) (krows * kcols)
124−-- r = rows m
125−-- mats = fmap (\s -> subMatrix (0,s) (r, krows * kcols) m) starts
126−-- in parMap rseq (col2imUnsafe krows kcols srows scols drows dcols) mats
127−
128122col2imUnsafe :: Int -> Int -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
129123col2imUnsafe kernelRows kernelColumns strideRows strideColumns destinationRows destinationCols columnMatrix = U.runSTMatrix $ do
124+
130125 let columnMatrixRows = rows columnMatrix
131126
132127 dataIm <- U.newMatrix 0 destinationRows destinationCols
@@ -134,15 +129,15 @@ col2imUnsafe kernelRows kernelColumns strideRows strideColumns destinationRows d
134129 offsetR <- newSTRef 0
135130 offsetC <- newSTRef 0
136131
137− forM_ [0 .. columnMatrixRows - 1] $ \ir -> do
138− inputColumn <- newSTRef 0
132+ forM_ [0 .. columnMatrixRows - 1] $ \inputRow -> do
133+ inputColumnRef <- newSTRef 0
139134 forM_ [0 .. kernelRows -1] $ \kr ->
140135 forM_ [0 .. kernelColumns -1] $ \kc -> do
141− ic <- readSTRef inputColumn
142− offsetR' <- readSTRef offsetR
143− offsetC' <- readSTRef offsetC
144− U.modifyMatrix dataIm (kr + offsetR') (kc + offsetC') (+ atIndex columnMatrix (ir,ic))
145− modifySTRef inputColumn (+1)
136+ inputColumn <- readSTRef inputColumnRef
137+ offsetR' <- readSTRef offsetR
138+ offsetC' <- readSTRef offsetC
139+ U.modifyMatrix dataIm (kr + offsetR') (kc + offsetC') (+ U.atM' columnMatrix inputRow inputColumn)
140+ modifySTRef inputColumnRef (+1)
146141
147142 offsetC' <- readSTRef offsetC
148143 if offsetC' + kernelColumns < destinationCols
@@ -158,12 +153,12 @@ col2vidUnsafe kernelRows kernelColumns strideRows strideColumns destinationRows
158153
159154 dataIms <- traverse (\_ -> U.newMatrix 0 destinationRows destinationCols) [0 .. filters-1]
160155
161− offsetR <- newSTRef 0
162− offsetC <- newSTRef 0
163156 offsetM <- newSTRef 0
164157
165158 forM_ dataIms $ \dataIm -> do
166− offsetM' <- readSTRef offsetM
159+ offsetR <- newSTRef 0
160+ offsetC <- newSTRef 0
161+ offsetM' <- readSTRef offsetM
167162 forM_ [0 .. columnMatrixRows - 1] $ \ir -> do
168163 inputColumn <- newSTRef 0
169164 forM_ [0 .. kernelRows -1] $ \kr ->
@@ -171,7 +166,7 @@ col2vidUnsafe kernelRows kernelColumns strideRows strideColumns destinationRows
171166 ic <- readSTRef inputColumn
172167 offsetR' <- readSTRef offsetR
173168 offsetC' <- readSTRef offsetC
174− U.modifyMatrix dataIm (kr + offsetR') (kc + offsetC') (+ atIndex columnMatrix (ir, ic + offsetM'))
169+ U.modifyMatrix dataIm (kr + offsetR') (kc + offsetC') (+ U.atM' columnMatrix ir (ic + offsetM'))
175170 modifySTRef inputColumn (+1)
176171
177172 offsetC' <- readSTRef offsetC
@@ -179,60 +174,55 @@ col2vidUnsafe kernelRows kernelColumns strideRows strideColumns destinationRows
179174 then modifySTRef offsetC (+ strideColumns)
180175 else writeSTRef offsetC 0 >> modifySTRef offsetR (+ strideRows)
181176
182− writeSTRef offsetR 0
183− writeSTRef offsetC 0
184177 modifySTRef offsetM (+ (kernelRows * kernelColumns))
185178
186− traverse U.freezeMatrix dataIms
179+ traverse U.unsafeFreezeMatrix dataIms
187180
188−vid2colUnsafe :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> [Matrix Double] -> Matrix Double
189−vid2colUnsafe channels kernelRows kernelColumns striderows stridecols vidrows vidcols dataVid = U.runSTMatrix $ do
181+vid2colUnsafe :: Int -> Int -> Int -> Int -> Int -> Int -> [Matrix Double] -> Matrix Double
182+vid2colUnsafe kernelRows kernelColumns striderows stridecols vidrows vidcols dataVid = U.runSTMatrix $ do
190183 let starts = fittingStarts vidrows kernelRows striderows vidcols kernelColumns stridecols
191− matWidth = kernelRows * kernelColumns
192− destinationRows = 1 + (vidrows - kernelRows) `div` striderows
193− destinationCols = 1 + (vidcols - kernelColumns) `div` stridecols
194− destinationSize = destinationRows * destinationCols
184+ kernelSize = kernelRows * kernelColumns
185+ numberOfPatches = length starts
186+ channels = length dataVid
195187
196− dataCol <- U.newMatrix 0 destinationSize (channels * matWidth)
188+ dataCol <- U.newMatrix 0 numberOfPatches (channels * kernelSize)
197189
198190 offsetC <- newSTRef 0
199191
200192 forM_ dataVid $ \dataIm -> do
201− inputRow <- newSTRef 0
193+ inputRowRef <- newSTRef 0
202194 offsetC' <- readSTRef offsetC
203195 forM_ starts $ \(startRow, startCol) -> do
204− inputColumn <- newSTRef 0
205− inputRow' <- readSTRef inputRow
196+ inputColumnRef <- newSTRef 0
197+ inputRow <- readSTRef inputRowRef
206198 forM_ [0 .. kernelRows -1] $ \kr ->
207199 forM_ [0 .. kernelColumns -1] $ \kc -> do
208− inputColumn' <- readSTRef inputColumn
209− U.modifyMatrix dataCol inputRow' (inputColumn' + offsetC') (+ atIndex dataIm (kr + startRow, kc + startCol))
210− modifySTRef inputColumn (+1)
211− modifySTRef inputRow (+1)
200+ inputColumn <- readSTRef inputColumnRef
201+ U.modifyMatrix dataCol inputRow (inputColumn + offsetC') (+ U.atM' dataIm (kr + startRow) (kc + startCol))
202+ modifySTRef inputColumnRef (+1)
203+ modifySTRef inputRowRef (+1)
212204
213− modifySTRef offsetC (+ matWidth)
205+ modifySTRef offsetC (+ kernelSize)
214206
215207 return dataCol
216208
217−im2colUnsafe :: Int -> Int -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
218−im2colUnsafe kernelRows kernelColumns striderows stridecols vidrows vidcols dataIm = U.runSTMatrix $ do
219− let starts = fittingStarts vidrows kernelRows striderows vidcols kernelColumns stridecols
220− matWidth = kernelRows * kernelColumns
221− destinationRows = 1 + (vidrows - kernelRows) `div` striderows
222− destinationCols = 1 + (vidcols - kernelColumns) `div` stridecols
223− destinationSize = destinationRows * destinationCols
209+im2colUnsafe :: Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
210+im2colUnsafe kernelRows kernelColumns striderows stridecols dataIm = U.runSTMatrix $ do
211+ let starts = fittingStarts (rows dataIm) kernelRows striderows (cols dataIm) kernelColumns stridecols
212+ kernelSize = kernelRows * kernelColumns
213+ numberOfPatches = length starts
224214
225− dataCol <- U.newMatrix 0 destinationSize matWidth
215+ dataCol <- U.newMatrix 0 numberOfPatches kernelSize
226216
227− inputRow <- newSTRef 0
217+ inputRowRef <- newSTRef 0
228218 forM_ starts $ \(startRow, startCol) -> do
229− inputColumn <- newSTRef 0
230− inputRow' <- readSTRef inputRow
219+ inputColumnRef <- newSTRef 0
220+ inputRow <- readSTRef inputRowRef
231221 forM_ [0 .. kernelRows -1] $ \kr ->
232222 forM_ [0 .. kernelColumns -1] $ \kc -> do
233− inputColumn' <- readSTRef inputColumn
234− U.modifyMatrix dataCol inputRow' inputColumn' (+ atIndex dataIm (kr + startRow, kc + startCol))
235− modifySTRef inputColumn (+1)
236− modifySTRef inputRow (+1)
223+ inputColumn <- readSTRef inputColumnRef
224+ U.modifyMatrix dataCol inputRow inputColumn (+ U.atM' dataIm (kr + startRow) (kc + startCol))
225+ modifySTRef inputColumnRef (+1)
226+ modifySTRef inputRowRef (+1)
237227
238228 return dataCol
src/Grenade/Layers/Internal/Pooling.hsnew file+48
@@ -0,0 +1,48 @@
1+module Grenade.Layers.Internal.Pooling (
2+ poolForward
3+ , poolBackward
4+ , poolForwardList
5+ , poolBackwardList
6+ ) where
7+
8+import Numeric.LinearAlgebra hiding ( uniformSample, konst )
9+import qualified Numeric.LinearAlgebra as LA
10+
11+import Grenade.Layers.Internal.Convolution
12+
13+poolForward :: Int -> Int -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
14+poolForward nrows ncols srows scols outputRows outputCols m =
15+ let starts = fittingStarts (rows m) nrows srows (cols m) ncols scols
16+ in poolForwardFit starts nrows ncols outputRows outputCols m
17+
18+poolForwardList :: Functor f => Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> f (Matrix Double) -> f (Matrix Double)
19+poolForwardList nrows ncols srows scols inRows inCols outputRows outputCols ms =
20+ let starts = fittingStarts inRows nrows srows inCols ncols scols
21+ in poolForwardFit starts nrows ncols outputRows outputCols <$> ms
22+
23+poolForwardFit :: [(Int,Int)] -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
24+poolForwardFit starts nrows ncols _ outputCols m =
25+ let els = fmap (\start -> maxElement $ subMatrix start (nrows, ncols) m) starts
26+ in LA.matrix outputCols els
27+
28+poolBackward :: Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double -> Matrix Double
29+poolBackward krows kcols srows scols inputMatrix gradientMatrix =
30+ let inRows = rows inputMatrix
31+ inCols = cols inputMatrix
32+ starts = fittingStarts inRows krows srows inCols kcols scols
33+ in poolBackwardFit starts krows kcols inputMatrix gradientMatrix
34+
35+poolBackwardList :: Functor f => Int -> Int -> Int -> Int -> Int -> Int -> f (Matrix Double, Matrix Double) -> f (Matrix Double)
36+poolBackwardList krows kcols srows scols inRows inCols inputMatrices =
37+ let starts = fittingStarts inRows krows srows inCols kcols scols
38+ in uncurry (poolBackwardFit starts krows kcols) <$> inputMatrices
39+
40+poolBackwardFit :: [(Int,Int)] -> Int -> Int -> Matrix Double -> Matrix Double -> Matrix Double
41+poolBackwardFit starts krows kcols inputMatrix gradientMatrix =
42+ let inRows = rows inputMatrix
43+ inCols = cols inputMatrix
44+ inds = fmap (\start -> maxIndex $ subMatrix start (krows, kcols) inputMatrix) starts
45+ grads = toList $ flatten gradientMatrix
46+ grads' = zip3 starts grads inds
47+ accums = fmap (\((stx',sty'),grad,(inx, iny)) -> ((stx' + inx, sty' + iny), grad)) grads'
48+ in accum (LA.konst 0 (inRows, inCols)) (+) accums
src/Grenade/Layers/Pooling.hs+2−45
@@ -24,10 +24,8 @@ import GHC.TypeLits
2424import Grenade.Core.Network
2525import Grenade.Core.Shape
2626import Grenade.Core.Vector
27−import Grenade.Layers.Convolution.Internal
27+import Grenade.Layers.Internal.Pooling
2828
29−import Numeric.LinearAlgebra hiding (uniformSample)
30−import qualified Numeric.LinearAlgebra as LA
3129import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRows)
3230
3331-- | A pooling layer for a neural network.
@@ -37,16 +35,12 @@ import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRow
3735-- The kernel size dictates which input and output sizes will "fit". Fitting the equation:
3836-- `out = (in - kernel) / stride + 1` for both dimensions.
3937--
40−data Pooling :: Nat
41− -> Nat
42− -> Nat
43− -> Nat -> * where
38+data Pooling :: Nat -> Nat -> Nat -> Nat -> * where
4439 Pooling :: Pooling kernelRows kernelColumns strideRows strideColumns
4540
4641instance Show (Pooling k k' s s') where
4742 show Pooling = "Pooling"
4843
49−
5044instance UpdateLayer (Pooling kernelRows kernelColumns strideRows strideColumns) where
5145 type Gradient (Pooling kr kc sr sc) = ()
5246 runUpdate _ Pooling _ = Pooling
@@ -123,40 +117,3 @@ instance ( KnownNat kernelRows
123117 ez = vectorZip (,) ex eo
124118 vs = poolBackwardList kx ky sx sy ix iy ez
125119 in ((), S3D' . fmap (fromJust . create) $ vs)
126−
127−poolForward :: Int -> Int -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
128−poolForward nrows ncols srows scols outputRows outputCols m =
129− let starts = fittingStarts (rows m) nrows srows (cols m) ncols scols
130− in poolForwardFit starts nrows ncols outputRows outputCols m
131−
132−poolForwardList :: Functor f => Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> f (Matrix Double) -> f (Matrix Double)
133−poolForwardList nrows ncols srows scols inRows inCols outputRows outputCols ms =
134− let starts = fittingStarts inRows nrows srows inCols ncols scols
135− in poolForwardFit starts nrows ncols outputRows outputCols <$> ms
136−
137−poolForwardFit :: [(Int,Int)] -> Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double
138−poolForwardFit starts nrows ncols _ outputCols m =
139− let els = fmap (\start -> maxElement $ subMatrix start (nrows, ncols) m) starts
140− in LA.matrix outputCols els
141−
142−poolBackward :: Int -> Int -> Int -> Int -> Matrix Double -> Matrix Double -> Matrix Double
143−poolBackward krows kcols srows scols inputMatrix gradientMatrix =
144− let inRows = (rows inputMatrix)
145− inCols = (cols inputMatrix)
146− starts = fittingStarts inRows krows srows inCols kcols scols
147− in poolBackwardFit starts krows kcols inputMatrix gradientMatrix
148−
149−poolBackwardList :: Functor f => Int -> Int -> Int -> Int -> Int -> Int -> f (Matrix Double, Matrix Double) -> f (Matrix Double)
150−poolBackwardList krows kcols srows scols inRows inCols inputMatrices =
151− let starts = fittingStarts inRows krows srows inCols kcols scols
152− in (uncurry $ poolBackwardFit starts krows kcols) <$> inputMatrices
153−
154−poolBackwardFit :: [(Int,Int)] -> Int -> Int -> Matrix Double -> Matrix Double -> Matrix Double
155−poolBackwardFit starts krows kcols inputMatrix gradientMatrix =
156− let inRows = (rows inputMatrix)
157− inCols = (cols inputMatrix)
158− inds = fmap (\start -> maxIndex $ subMatrix start (krows, kcols) inputMatrix) starts
159− grads = toList $ flatten gradientMatrix
160− grads' = zip3 starts grads inds
161− accums = fmap (\((stx',sty'),grad,(inx, iny)) -> ((stx' + inx, sty' + iny), grad)) grads'
162− in accum (LA.konst 0 (inRows, inCols)) (+) accums
test/Test/Grenade/Layers/Convolution.hs+7−7
@@ -8,7 +8,7 @@ import Grenade.Core.Shape
88import Grenade.Core.Vector as Grenade
99import Grenade.Core.Network
1010import Grenade.Layers.Convolution
11−import Grenade.Layers.Convolution.Internal
11+import Grenade.Layers.Internal.Convolution
1212
1313import Numeric.LinearAlgebra hiding (uniformSample, konst, (===))
1414import qualified Numeric.LinearAlgebra.Static as HStatic
@@ -51,7 +51,7 @@ prop_im2col_other = once $
5151 expected = (2><6)
5252 [ 1.0, 2.0, 5.0, 6.0 , 9.0, 10.0
5353 , 3.0, 4.0, 7.0, 8.0 , 11.0 ,12.0 ]
54− out = im2col 3 2 1 2 input
54+ out = im2colUnsafe 3 2 1 2 input
5555 in expected === out
5656
5757-- If there's no overlap (stride is the same size as the kernel)
@@ -71,7 +71,7 @@ prop_im2colunsafe_sym_on_same_stride = once $
7171 [ 1.0, 2.0, 3.0, 4.0
7272 , 5.0, 6.0, 7.0, 8.0
7373 , 9.0, 10.0, 11.0, 12.0 ]
74− out = col2imUnsafe 3 2 3 2 3 4 . im2colUnsafe 3 2 3 2 3 4 $ input
74+ out = col2imUnsafe 3 2 3 2 3 4 . im2colUnsafe 3 2 3 2 $ input
7575 in input === out
7676
7777
@@ -86,7 +86,7 @@ prop_im2col_col2im_additive = once $
8686 [ 1.0, 2.0, 2.0, 1.0
8787 , 2.0, 4.0, 4.0, 2.0
8888 , 1.0, 2.0, 2.0, 1.0 ]
89− out = col2im 2 2 1 1 3 4 . im2col 2 2 1 1 $ input
89+ out = col2imUnsafe 2 2 1 1 3 4 . im2colUnsafe 2 2 1 1 $ input
9090 in expected === out
9191
9292prop_simple_conv_forwards = once $
@@ -166,7 +166,7 @@ prop_vid2col_no_stride = once $
166166 , 5.0, 6.0, 9.0, 10.0 , 25.0, 26.0, 29.0, 30.0
167167 , 6.0, 7.0, 10.0, 11.0 , 26.0, 27.0, 30.0, 31.0
168168 , 7.0, 8.0, 11.0, 12.0 , 27.0, 28.0, 31.0, 32.0 ]
169− out = vid2col 2 2 1 1 3 4 input
169+ out = vid2colUnsafe 2 2 1 1 3 4 input
170170 in expected === out
171171
172172prop_vid2col_stride = once $
@@ -183,7 +183,7 @@ prop_vid2col_stride = once $
183183 , 3.0, 4.0, 7.0, 8.0 , 23.0, 24.0, 27.0, 28.0
184184 , 5.0, 6.0, 9.0, 10.0 , 25.0, 26.0, 29.0, 30.0
185185 , 7.0, 8.0, 11.0, 12.0 , 27.0, 28.0, 31.0, 32.0 ]
186− out = vid2col 2 2 1 2 3 4 input
186+ out = vid2colUnsafe 2 2 1 2 3 4 input
187187 in expected === out
188188
189189
@@ -208,7 +208,7 @@ prop_vid2col_invert_unsafe = once $
208208 [ 21.0, 22.0, 23.0, 24.0
209209 , 25.0, 26.0, 27.0, 28.0
210210 , 29.0, 30.0, 31.0, 32.0 ] ]
211− out = col2vidUnsafe 3 2 3 2 3 4 . vid2colUnsafe 2 3 2 3 2 3 4 $ input
211+ out = col2vidUnsafe 3 2 3 2 3 4 . vid2colUnsafe 3 2 3 2 3 4 $ input
212212 in input === out
213213
214214