Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
clip-quantize-cli.cpp60 linesDownload Raw Back to llava
1#include "arg.h"2#include "base64.hpp"3#include "log.h"4#include "common.h"5#include "sampling.h"6#include "clip.h"7#include "llava.h"8#include "llama.h"9#include "ggml.h"10 11static void print_usage(int argc, char ** argv) {12    (void) argc;13 14    fprintf(stderr, "usage: %s /path/to/ggml-model-f32.gguf /path/to/ggml-model-quantized.gguf type\n", argv[0]);15    fprintf(stderr, "  type = 2 - q4_0\n");16    fprintf(stderr, "  type = 3 - q4_1\n");17    fprintf(stderr, "  type = 6 - q5_0\n");18    fprintf(stderr, "  type = 7 - q5_1\n");19    fprintf(stderr, "  type = 8 - q8_0\n");20}21 22int main(int argc, char ** argv) {23    if (argc != 4) {24        print_usage(argc, argv);25        return 1;26    }27 28    const std::string fname_inp = argv[1];29    const std::string fname_out = argv[2];30 31    const int itype = atoi(argv[3]);32 33    const int64_t t_main_start_us = ggml_time_us();34 35    int64_t t_quantize_us = 0;36 37    // load the model38    {39        const int64_t t_start_us = ggml_time_us();40 41        if (!clip_model_quantize(fname_inp.c_str(), fname_out.c_str(), itype)) {42            fprintf(stderr, "%s: failed to quantize model from '%s'\n", __func__, fname_inp.c_str());43            return 1;44        }45 46        t_quantize_us = ggml_time_us() - t_start_us;47    }48 49    // report timing50    {51        const int64_t t_main_end_us = ggml_time_us();52 53        printf("\n");54        printf("%s: quantize time = %8.2f ms\n", __func__, t_quantize_us / 1000.0f);55        printf("%s:    total time = %8.2f ms\n", __func__, (t_main_end_us - t_main_start_us) / 1000.0f);56    }57 58    return 0;59}60