Skip to content

Commit

Permalink
Rename Adaptor classes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj committed Jan 28, 2025
1 parent 5e43c09 commit baf992e
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 268 deletions.
20 changes: 10 additions & 10 deletions bench/common/BenchMnistTools.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mnistTrainBench1VTA extraPrefix chunkLength xs widthHidden widthHidden2
MnistFcnnRanked1.afcnnMnistLoss1
widthHidden widthHidden2
mnist (unAsHVector
$ parseHVector (AsHVector $ fromDValue valsInit) adinputs)
$ fromTarget (AsHVector $ fromDValue valsInit) adinputs)
chunk = take chunkLength xs
grad c = tunvector $ fst $ sgd gamma f c (dmkHVector hVectorInit)
name = extraPrefix
Expand Down Expand Up @@ -153,8 +153,8 @@ mnistTrainBench1VTO extraPrefix chunkLength testData widthHidden widthHidden2
(glyphR, labelR) pars
g :: AstTensor AstMethodLet FullSpan TKUntyped
-> AstTensor AstMethodLet FullSpan TKUntyped
g !hv = toHVectorOf $ AsHVector $ f
$ unAsHVector $ parseHVector (AsHVector $ fromValue (valsInit, dataInit)) hv
g !hv = toTarget $ AsHVector $ f
$ unAsHVector $ fromTarget (AsHVector $ fromValue (valsInit, dataInit)) hv
(artRaw, _) = revProduceArtifact False g emptyEnv
(FTKUntyped $ voidFromHVector
$ hVectorInit
Expand Down Expand Up @@ -224,18 +224,18 @@ mnistTrainBench2VTA extraPrefix chunkLength testData widthHidden widthHidden2
case someNatVal $ toInteger widthHidden2 of
Just (SomeNat @widthHidden2 _) ->
forgetShape $ fst
$ randomVals
$ randomValue
@(MnistFcnnRanked2.ADFcnnMnist2ParametersShaped
RepN widthHidden widthHidden2 r)
1 (mkStdGen 44)
Nothing -> error "valsInit: impossible someNatVal error"
Nothing -> error "valsInit: impossible someNatVal error"
hVectorInit = dunHVector $ toHVectorOf $ AsHVector valsInit
hVectorInit = dunHVector $ toTarget $ AsHVector valsInit
f :: MnistData r -> ADVal RepN TKUntyped
-> ADVal target (TKR 0 r)
f mnist adinputs =
MnistFcnnRanked2.afcnnMnistLoss2
mnist (unAsHVector $ parseHVector (AsHVector $ fromDValue valsInit) adinputs)
mnist (unAsHVector $ fromTarget (AsHVector $ fromDValue valsInit) adinputs)
chunk = take chunkLength testData
grad c = tunvector $ fst $ sgd gamma f c (dmkHVector hVectorInit)
name = extraPrefix
Expand All @@ -254,13 +254,13 @@ mnistTestBench2VTA extraPrefix chunkLength testData widthHidden widthHidden2 = d
case someNatVal $ toInteger widthHidden2 of
Just (SomeNat @widthHidden2 _) ->
forgetShape $ fst
$ randomVals
$ randomValue
@(MnistFcnnRanked2.ADFcnnMnist2ParametersShaped
RepN widthHidden widthHidden2 r)
1 (mkStdGen 44)
Nothing -> error "valsInit: impossible someNatVal error"
Nothing -> error "valsInit: impossible someNatVal error"
hVectorInit = dunHVector $ toHVectorOf $ AsHVector valsInit
hVectorInit = dunHVector $ toTarget $ AsHVector valsInit
ftest :: [MnistData r] -> HVector RepN -> r
ftest = MnistFcnnRanked2.afcnnMnistTest2 valsInit
chunk = take chunkLength testData
Expand Down Expand Up @@ -311,13 +311,13 @@ mnistTrainBench2VTO extraPrefix chunkLength testData widthHidden widthHidden2
case someNatVal $ toInteger widthHidden2 of
Just (SomeNat @widthHidden2 _) ->
forgetShape $ fst
$ randomVals
$ randomValue
@(MnistFcnnRanked2.ADFcnnMnist2ParametersShaped
RepN widthHidden widthHidden2 r)
1 (mkStdGen 44)
Nothing -> error "valsInit: impossible someNatVal error"
Nothing -> error "valsInit: impossible someNatVal error"
hVectorInit = dunHVector $ toHVectorOf $ AsHVector valsInit
hVectorInit = dunHVector $ toTarget $ AsHVector valsInit
name = extraPrefix
++ unwords [ "v0 m" ++ show (V.length hVectorInit)
, " =" ++ show (sizeHVector hVectorInit) ]
Expand Down
8 changes: 4 additions & 4 deletions bench/common/BenchProdTools.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ _rankedNoShareVecProd = V.foldl1' multNotShared
-- to the existential variables in AstRanked that show up, e.g., when
-- pattern matching on that type, dictionaries seen in the datatype
-- constructors.
inspect $ hasNoTypeClassesExcept 'crevRankedListProd [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''OD.Storable, ''AdaptableHVector, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'revRankedListProd [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''(~), ''PermC, ''OD.Storable, ''AdaptableHVector, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'crevRankedListProdr [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''OD.Storable, ''AdaptableHVector, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'revRankedListProdr [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''(~), ''PermC, ''OD.Storable, ''AdaptableHVector, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'crevRankedListProd [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''OD.Storable, ''AdaptableTarget, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'revRankedListProd [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''(~), ''PermC, ''OD.Storable, ''AdaptableTarget, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'crevRankedListProdr [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''OD.Storable, ''AdaptableTarget, ''OS.Vector]
inspect $ hasNoTypeClassesExcept 'revRankedListProdr [''GoodScalar, ''KnownNat, ''KnownShS, ''AstSpan, ''Show, ''Ord, ''Numeric, ''Num, ''RowSum, ''Typeable, ''IfDifferentiable, ''NFData, ''(~), ''PermC, ''OD.Storable, ''AdaptableTarget, ''OS.Vector]
-- OD.Storable is needed, for 9.4, only until new orthotope is released
-}
Expand Down
Loading

0 comments on commit baf992e

Please sign in to comment.