MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / main

Function main

external/ggml/examples/gpt-2/quantize.cpp:139–184  ·  view source on GitHub ↗

usage: ./gpt-2-quantize models/gpt-2-117M/ggml-model.bin models/gpt-2-117M/ggml-model-quant.bin type

Source from the content-addressed store, hash-verified

137// ./gpt-2-quantize models/gpt-2-117M/ggml-model.bin models/gpt-2-117M/ggml-model-quant.bin type
138//
139int main(int argc, char ** argv) {
140 if (argc != 4) {
141 fprintf(stderr, "usage: %s model-f32.bin model-quant.bin type\n", argv[0]);
142 ggml_print_ftypes(stderr);
143 return 1;
144 }
145
146 // needed to initialize f16 tables
147 {
148 struct ggml_init_params params = { 0, NULL, false };
149 struct ggml_context * ctx = ggml_init(params);
150 ggml_free(ctx);
151 }
152
153 const std::string fname_inp = argv[1];
154 const std::string fname_out = argv[2];
155
156 const ggml_ftype ftype = ggml_parse_ftype(argv[3]);
157
158 const int64_t t_main_start_us = ggml_time_us();
159
160 int64_t t_quantize_us = 0;
161
162 // load the model
163 {
164 const int64_t t_start_us = ggml_time_us();
165
166 if (!gpt2_model_quantize(fname_inp, fname_out, ggml_ftype(ftype))) {
167 fprintf(stderr, "%s: failed to quantize model from '%s'\n", __func__, fname_inp.c_str());
168 return 1;
169 }
170
171 t_quantize_us = ggml_time_us() - t_start_us;
172 }
173
174 // report timing
175 {
176 const int64_t t_main_end_us = ggml_time_us();
177
178 printf("\n");
179 printf("%s: quantize time = %8.2f ms\n", __func__, t_quantize_us/1000.0f);
180 printf("%s: total time = %8.2f ms\n", __func__, (t_main_end_us - t_main_start_us)/1000.0f);
181 }
182
183 return 0;
184}

Callers

nothing calls this directly

Calls 7

ggml_print_ftypesFunction · 0.85
ggml_initFunction · 0.85
ggml_freeFunction · 0.85
ggml_parse_ftypeFunction · 0.85
ggml_time_usFunction · 0.85
gpt2_model_quantizeFunction · 0.85
ggml_ftypeEnum · 0.50

Tested by

no test coverage detected