forked from hxim/paq8px
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModels.cpp
159 lines (124 loc) · 4.08 KB
/
Models.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "Models.hpp"
/*
relationship between compression level, shared->mem and NormalModel memory use as an example
level shared->mem NormalModel memory use (shared->mem*32)
----- ----------- ----------------------
1 0.125 MB 4 MB
2 0.25 MB 8 MB
3 0.5 MB 16 MB
4 1.0 MB 32 MB
5 2.0 MB 64 MB
6 4.0 MB 128 MB
7 8.0 MB 256 MB
8 16.0 MB 512 MB
9 32.0 MB 1024 MB
10 64.0 MB 2048 MB
11 128.0 MB 4096 MB
12 256.0 MB 8192 MB
*/
Models::Models(Shared* const sh) : shared(sh) {}
auto Models::normalModel() -> NormalModel & {
static NormalModel instance {shared, shared->mem * 32};
return instance;
}
auto Models::dmcForest() -> DmcForest & {
static DmcForest instance {shared, shared->mem}; /**< Not the actual memory use - see in the model */
return instance;
}
auto Models::charGroupModel() -> CharGroupModel & {
static CharGroupModel instance {shared, shared->mem / 2};
return instance;
}
auto Models::recordModel() -> RecordModel & {
static RecordModel instance {shared, shared->mem * 2};
return instance;
}
auto Models::sparseBitModel() -> SparseBitModel& {
static SparseBitModel instance{ shared, shared->mem / 4 };
return instance;
}
auto Models::sparseModel() -> SparseModel & {
static SparseModel instance {shared, shared->mem * 4};
return instance;
}
auto Models::matchModel() -> MatchModel & {
static MatchModel instance {shared, shared->mem / 4 /*hashtablesize*/, shared->mem /*mapmemorysize*/ }; /**< Not the actual memory use - see in the model */
return instance;
}
auto Models::sparseMatchModel() -> SparseMatchModel & {
static SparseMatchModel instance {shared, shared->mem};
return instance;
}
auto Models::indirectModel() -> IndirectModel & {
static IndirectModel instance {shared, shared->mem * 2};
return instance;
}
#ifndef DISABLE_TEXTMODEL
auto Models::textModel() -> TextModel & {
static TextModel instance {shared, shared->mem * 16};
return instance;
}
auto Models::wordModel() -> WordModel & {
static WordModel instance {shared, shared->mem * 16};
return instance;
}
#else
auto wordModel() -> WordModel & {
static WordModel instance {};
return instance;
}
#endif //DISABLE_TEXTMODEL
auto Models::nestModel() -> NestModel & {
static NestModel instance {shared, shared->mem};
return instance;
}
auto Models::xmlModel() -> XMLModel & {
static XMLModel instance {shared, shared->mem / 4};
return instance;
}
auto Models::exeModel() -> ExeModel & {
static ExeModel instance {shared, shared->mem * 4};
return instance;
}
auto Models::linearPredictionModel() -> LinearPredictionModel & {
static LinearPredictionModel instance {shared};
return instance;
}
auto Models::jpegModel() -> JpegModel & {
static JpegModel instance {shared, shared->mem}; /**< Not the actual memory use - see in the model */
return instance;
}
auto Models::image24BitModel() -> Image24BitModel & {
static Image24BitModel instance {shared, shared->mem * 4};
return instance;
}
auto Models::image8BitModel() -> Image8BitModel & {
static Image8BitModel instance {shared, shared->mem * 4};
return instance;
}
auto Models::image4BitModel() -> Image4BitModel & {
static Image4BitModel instance {shared, shared->mem / 2};
return instance;
}
auto Models::image1BitModel() -> Image1BitModel & {
static Image1BitModel instance {shared};
return instance;
}
#ifndef DISABLE_AUDIOMODEL
auto Models::audio8BitModel() -> Audio8BitModel & {
static Audio8BitModel instance {shared};
return instance;
}
auto Models::audio16BitModel() -> Audio16BitModel & {
static Audio16BitModel instance {shared};
return instance;
}
#endif //DISABLE_AUDIOMODEL
auto Models::lstmModel() -> LstmModel<> & {
static LstmModel<>* instance = LstmFactory<>::CreateLSTM(shared, 200, 2, 100, 0.06f, 16.f);
return *instance;
}
auto Models::decAlphaModel() -> DECAlphaModel & {
static DECAlphaModel instance{ shared };
return instance;
}