LLVMFuzzerTestOneInput:
  140|     17|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  141|     17|  if (size < 256) {
  ------------------
  |  Branch (141:7): [True: 14, False: 3]
  ------------------
  142|     14|    return 0;
  143|     14|  }
  144|      3|  llama_backend_init();
  145|      3|  FuzzedDataProvider fdp(data, size);
  146|       |
  147|      3|  auto params = llama_model_params{};
  148|      3|  memset(&params, 0x0, sizeof(struct llama_model_params));
  149|      3|  params.use_mmap = false;
  150|      3|  params.progress_callback = [](float progress, void *ctx) {
  151|      3|    (void)ctx;
  152|      3|    return progress > 0.50;
  153|      3|  };
  154|       |
  155|      3|  int overwrite_idx = 0;
  156|       |
  157|       |  // set the architecture
  158|      3|  std::string arch_key = "general.architecture";
  159|      3|  uint8_t arch_index =
  160|      3|      fdp.ConsumeIntegralInRange<uint8_t>(0, possible_architectures.size() - 1);
  161|       |
  162|      3|  std::string arch_val = std::string(possible_architectures[arch_index]);
  163|      3|  fuzz_kv_overrides[overwrite_idx].tag = LLAMA_KV_OVERRIDE_TYPE_STR;
  164|      3|  strcpy(fuzz_kv_overrides[overwrite_idx].key, arch_key.c_str());
  165|      3|  strcpy(fuzz_kv_overrides[overwrite_idx].val_str, arch_val.c_str());
  166|      3|  overwrite_idx++;
  167|       |
  168|    153|  for (int i = 0; i < possible_prefix_keys.size(); i++) {
  ------------------
  |  Branch (168:19): [True: 150, False: 3]
  ------------------
  169|    150|    std::string key;
  170|    150|    std::string val;
  171|       |
  172|       |    // Get the key
  173|    150|    key = arch_val + possible_prefix_keys[i];
  174|    150|    val = fdp.ConsumeRandomLengthString(32);
  175|       |
  176|       |    // Copy the data into the overrides array
  177|    150|    fuzz_kv_overrides[overwrite_idx].tag = fdp.PickValueInArray(arrayed_enums);
  178|    150|    strcpy(fuzz_kv_overrides[overwrite_idx].key, key.c_str());
  179|    150|    strcpy(fuzz_kv_overrides[overwrite_idx].val_str, val.c_str());
  180|    150|    overwrite_idx++;
  181|    150|  }
  182|       |
  183|       |  // Create the model
  184|      3|  std::string model_payload = fdp.ConsumeRandomLengthString();
  185|      3|  if (model_payload.size() < 10) {
  ------------------
  |  Branch (185:7): [True: 1, False: 2]
  ------------------
  186|      1|    return 0;
  187|      1|  }
  188|      2|  model_payload[0] = 'G';
  189|      2|  model_payload[1] = 'G';
  190|      2|  model_payload[2] = 'U';
  191|      2|  model_payload[3] = 'F';
  192|       |
  193|      2|  char filename[256];
  194|      2|  sprintf(filename, "/tmp/libfuzzer.%d", getpid());
  195|       |
  196|      2|  FILE *fp = fopen(filename, "wb");
  197|      2|  if (!fp) {
  ------------------
  |  Branch (197:7): [True: 0, False: 2]
  ------------------
  198|      0|    return 0;
  199|      0|  }
  200|      2|  fwrite(model_payload.data(), model_payload.size(), 1, fp);
  201|      2|  fclose(fp);
  202|       |
  203|       |  // Override an arbitrary set of arguments
  204|     50|  for (int i = overwrite_idx; i < NUM_OVERRIDES; i++) {
  ------------------
  |  |   26|     50|#define NUM_OVERRIDES 75
  ------------------
  |  Branch (204:31): [True: 48, False: 2]
  ------------------
  205|     48|    std::string key;
  206|     48|    std::string val;
  207|       |
  208|       |    // Get the key
  209|     48|    if (fdp.ConsumeProbability<float>() > 0.90) {
  ------------------
  |  Branch (209:9): [True: 0, False: 48]
  ------------------
  210|      0|      key = fdp.ConsumeRandomLengthString(20);
  211|     48|    } else {
  212|     48|      int i = fdp.ConsumeIntegralInRange<int>(0, possible_keys.size() - 1);
  213|     48|      key = possible_keys[i];
  214|     48|    }
  215|     48|    val = fdp.ConsumeRandomLengthString(30);
  216|       |
  217|       |    // Copy the data into the overrides array
  218|     48|    fuzz_kv_overrides[i].tag = fdp.PickValueInArray(arrayed_enums);
  219|     48|    strcpy(fuzz_kv_overrides[i].key, key.c_str());
  220|     48|    strcpy(fuzz_kv_overrides[i].val_str, val.c_str());
  221|     48|  }
  222|       |
  223|       |  // For debugging
  224|       |  // std::cout << "--- overwrote ---\n";
  225|       |  // for (int m = 0; m < NUM_OVERRIDES-1; m++) {
  226|       |  //  std::cout << "===  " << fuzz_kv_overrides[m].key << "\n";
  227|       |  //}
  228|       |  // std::cout << "#############\n";
  229|       |
  230|      2|  params.kv_overrides =
  231|      2|      (const struct llama_model_kv_override *)fuzz_kv_overrides;
  232|       |
  233|      2|  if (setjmp(fuzzing_jmp_buf) == 0) {
  ------------------
  |  Branch (233:7): [True: 2, False: 0]
  ------------------
  234|      2|    auto *model = llama_load_model_from_file(filename, params);
  235|      2|    if (model != nullptr) {
  ------------------
  |  Branch (235:9): [True: 0, False: 2]
  ------------------
  236|      0|      llama_free_model(model);
  237|      0|    }
  238|      2|  }
  239|      2|  llama_backend_free();
  240|       |
  241|       |  // close any open descriptors.
  242|  2.04k|  for (int i = 3; i < 1024; i++) {
  ------------------
  |  Branch (242:19): [True: 2.04k, False: 2]
  ------------------
  243|  2.04k|    close(i);
  244|  2.04k|  }
  245|       |
  246|      2|  unlink(filename);
  247|      2|  return 0;
  248|      2|}

ggml_backend_reg_count:
  316|      5|size_t ggml_backend_reg_count() {
  317|      5|    return get_reg().backends.size();
  318|      5|}
ggml-backend-reg.cpp:_ZL7get_regv:
  292|      5|static ggml_backend_registry & get_reg() {
  293|      5|    static ggml_backend_registry reg;
  294|      5|    return reg;
  295|      5|}
_ZN21ggml_backend_registryC2Ev:
  119|      1|    ggml_backend_registry() {
  120|       |#ifdef GGML_USE_CUDA
  121|       |        register_backend(ggml_backend_cuda_reg());
  122|       |#endif
  123|       |#ifdef GGML_USE_METAL
  124|       |        register_backend(ggml_backend_metal_reg());
  125|       |#endif
  126|       |#ifdef GGML_USE_SYCL
  127|       |        register_backend(ggml_backend_sycl_reg());
  128|       |#endif
  129|       |#ifdef GGML_USE_VULKAN
  130|       |    // Add runtime disable check
  131|       |    if (getenv("GGML_DISABLE_VULKAN") == nullptr) {
  132|       |        register_backend(ggml_backend_vk_reg());
  133|       |    } else {
  134|       |        GGML_LOG_DEBUG("Vulkan backend disabled by GGML_DISABLE_VULKAN environment variable\n");
  135|       |    }
  136|       |#endif
  137|       |#ifdef GGML_USE_WEBGPU
  138|       |        register_backend(ggml_backend_webgpu_reg());
  139|       |#endif
  140|       |#ifdef GGML_USE_ZDNN
  141|       |        register_backend(ggml_backend_zdnn_reg());
  142|       |#endif
  143|       |#ifdef GGML_USE_VIRTGPU_FRONTEND
  144|       |        register_backend(ggml_backend_virtgpu_reg());
  145|       |#endif
  146|       |
  147|       |#ifdef GGML_USE_OPENCL
  148|       |        register_backend(ggml_backend_opencl_reg());
  149|       |#endif
  150|       |#ifdef GGML_USE_ZENDNN
  151|       |        register_backend(ggml_backend_zendnn_reg());
  152|       |#endif
  153|       |#ifdef GGML_USE_HEXAGON
  154|       |        register_backend(ggml_backend_hexagon_reg());
  155|       |#endif
  156|       |#ifdef GGML_USE_CANN
  157|       |        register_backend(ggml_backend_cann_reg());
  158|       |#endif
  159|       |#ifdef GGML_USE_BLAS
  160|       |        register_backend(ggml_backend_blas_reg());
  161|       |#endif
  162|       |#ifdef GGML_USE_RPC
  163|       |        register_backend(ggml_backend_rpc_reg());
  164|       |#endif
  165|       |#ifdef GGML_USE_OPENVINO
  166|       |        register_backend(ggml_backend_openvino_reg());
  167|       |#endif
  168|       |#ifdef GGML_USE_ET
  169|       |        register_backend(ggml_backend_et_reg());
  170|       |#endif
  171|      1|#ifdef GGML_USE_CPU
  172|      1|        register_backend(ggml_backend_cpu_reg());
  173|      1|#endif
  174|      1|    }
_ZN21ggml_backend_registryD2Ev:
  176|      1|    ~ggml_backend_registry() {
  177|       |        // FIXME: backends cannot be safely unloaded without a function to destroy all the backend resources,
  178|       |        // since backend threads may still be running and accessing resources from the dynamic library
  179|      1|        for (auto & entry : backends) {
  ------------------
  |  Branch (179:27): [True: 1, False: 1]
  ------------------
  180|      1|            if (entry.handle) {
  ------------------
  |  Branch (180:17): [True: 0, False: 1]
  ------------------
  181|      0|                entry.handle.release(); // NOLINT
  182|      0|            }
  183|      1|        }
  184|      1|    }
_ZN21ggml_backend_registry16register_backendEP16ggml_backend_regNSt3__110unique_ptrIv17dl_handle_deleterEE:
  186|      1|    void register_backend(ggml_backend_reg_t reg, dl_handle_ptr handle = nullptr) {
  187|      1|        if (!reg) {
  ------------------
  |  Branch (187:13): [True: 0, False: 1]
  ------------------
  188|      0|            return;
  189|      0|        }
  190|       |
  191|      1|        for (auto & entry : backends) {
  ------------------
  |  Branch (191:27): [True: 0, False: 1]
  ------------------
  192|      0|            if (entry.reg == reg) {
  ------------------
  |  Branch (192:17): [True: 0, False: 0]
  ------------------
  193|      0|                return;
  194|      0|            }
  195|      0|        }
  196|       |
  197|       |#ifndef NDEBUG
  198|       |        GGML_LOG_DEBUG("%s: registered backend %s (%zu devices)\n",
  199|       |            __func__, ggml_backend_reg_name(reg), ggml_backend_reg_dev_count(reg));
  200|       |#endif
  201|      1|        backends.push_back({ reg, std::move(handle) });
  202|      2|        for (size_t i = 0; i < ggml_backend_reg_dev_count(reg); i++) {
  ------------------
  |  Branch (202:28): [True: 1, False: 1]
  ------------------
  203|      1|            register_device(ggml_backend_reg_dev_get(reg, i));
  204|      1|        }
  205|      1|    }
_ZN21ggml_backend_registry15register_deviceEP19ggml_backend_device:
  207|      1|    void register_device(ggml_backend_dev_t device) {
  208|      1|        for (auto & dev : devices) {
  ------------------
  |  Branch (208:25): [True: 0, False: 1]
  ------------------
  209|      0|            if (dev == device) {
  ------------------
  |  Branch (209:17): [True: 0, False: 0]
  ------------------
  210|      0|                return;
  211|      0|            }
  212|      0|        }
  213|       |
  214|       |#ifndef NDEBUG
  215|       |        GGML_LOG_DEBUG("%s: registered device %s (%s)\n", __func__, ggml_backend_dev_name(device), ggml_backend_dev_description(device));
  216|       |#endif
  217|      1|        devices.push_back(device);
  218|      1|    }

ggml_backend_reg_dev_count:
  649|      2|size_t ggml_backend_reg_dev_count(ggml_backend_reg_t reg) {
  650|      2|    GGML_ASSERT(reg);
  ------------------
  |  |  288|      2|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  651|      2|    return reg->iface.get_device_count(reg);
  652|      2|}
ggml_backend_reg_dev_get:
  654|      1|ggml_backend_dev_t ggml_backend_reg_dev_get(ggml_backend_reg_t reg, size_t index) {
  655|      1|    GGML_ASSERT(reg);
  ------------------
  |  |  288|      1|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  656|      1|    return reg->iface.get_device(reg, index);
  657|      1|}

ggml_cpu_init:
 3795|      1|void ggml_cpu_init(void) {
 3796|       |    // needed to initialize ggml_time
 3797|      1|    {
 3798|      1|        struct ggml_init_params params = { 0, NULL, false };
 3799|      1|        struct ggml_context * ctx = ggml_init(params);
 3800|      1|        ggml_free(ctx);
 3801|      1|    }
 3802|       |
 3803|      1|    ggml_critical_section_start();
 3804|       |
 3805|      1|    static bool is_first_call = true;
 3806|       |
 3807|      1|    if (is_first_call) {
  ------------------
  |  Branch (3807:9): [True: 1, False: 0]
  ------------------
 3808|       |        // initialize GELU, Quick GELU, SILU and EXP F32 tables
 3809|      1|        {
 3810|      1|            const uint64_t t_start = ggml_time_us(); UNUSED(t_start);
  ------------------
  |  |   76|      1|#define UNUSED GGML_UNUSED
  |  |  ------------------
  |  |  |  |  258|      1|#define GGML_UNUSED(x) (void)(x)
  |  |  ------------------
  ------------------
 3811|       |
 3812|  65.5k|            for (int i = 0; i < (1 << 16); ++i) {
  ------------------
  |  Branch (3812:29): [True: 65.5k, False: 1]
  ------------------
 3813|  65.5k|                union {
 3814|  65.5k|                    uint16_t u16;
 3815|  65.5k|                    ggml_fp16_t fp16;
 3816|  65.5k|                } u = {i};
 3817|  65.5k|                float f = GGML_COMPUTE_FP16_TO_FP32(u.fp16);
  ------------------
  |  |  433|  65.5k|#define GGML_COMPUTE_FP16_TO_FP32(x) ggml_compute_fp16_to_fp32(x)
  ------------------
 3818|  65.5k|                ggml_table_f32_f16[i] = f;
 3819|  65.5k|                ggml_table_gelu_f16[i] = GGML_CPU_FP32_TO_FP16(ggml_gelu_f32(f));
  ------------------
  |  |  155|  65.5k|#define GGML_CPU_FP32_TO_FP16(x) GGML_COMPUTE_FP32_TO_FP16(x)
  |  |  ------------------
  |  |  |  |  434|  65.5k|#define GGML_COMPUTE_FP32_TO_FP16(x) ggml_compute_fp32_to_fp16(x)
  |  |  ------------------
  ------------------
 3820|  65.5k|                ggml_table_gelu_quick_f16[i] = GGML_CPU_FP32_TO_FP16(ggml_gelu_quick_f32(f));
  ------------------
  |  |  155|  65.5k|#define GGML_CPU_FP32_TO_FP16(x) GGML_COMPUTE_FP32_TO_FP16(x)
  |  |  ------------------
  |  |  |  |  434|  65.5k|#define GGML_COMPUTE_FP32_TO_FP16(x) ggml_compute_fp32_to_fp16(x)
  |  |  ------------------
  ------------------
 3821|  65.5k|            }
 3822|       |
 3823|       |            // initialize E8M0 half table (256 entries)
 3824|    257|            for (int i = 0; i < (1 << 8); ++i) {
  ------------------
  |  Branch (3824:29): [True: 256, False: 1]
  ------------------
 3825|    256|                ggml_table_f32_e8m0_half[i] = GGML_E8M0_TO_FP32_HALF(i);
  ------------------
  |  |  498|    256|#define GGML_E8M0_TO_FP32_HALF(x) ggml_e8m0_to_fp32_half(x)
  ------------------
 3826|    256|            }
 3827|       |
 3828|       |            // initialize UE4M3 table (256 entries)
 3829|    257|            for (int i = 0; i < (1 << 8); ++i) {
  ------------------
  |  Branch (3829:29): [True: 256, False: 1]
  ------------------
 3830|    256|                ggml_table_f32_ue4m3[i] = ggml_ue4m3_to_fp32(i);
 3831|    256|            }
 3832|       |
 3833|      1|            const uint64_t t_end = ggml_time_us(); UNUSED(t_end);
  ------------------
  |  |   76|      1|#define UNUSED GGML_UNUSED
  |  |  ------------------
  |  |  |  |  258|      1|#define GGML_UNUSED(x) (void)(x)
  |  |  ------------------
  ------------------
 3834|       |
 3835|      1|            GGML_PRINT_DEBUG("%s: GELU, Quick GELU, SILU and EXP tables initialized in %f ms\n", __func__, (t_end - t_start)/1000.0);
 3836|       |
 3837|       |#ifdef GGML_USE_OPENMP
 3838|       |            //if (!getenv("OMP_WAIT_POLICY")) {
 3839|       |            //    // set the wait policy to active, so that OpenMP threads don't sleep
 3840|       |            //    setenv("OMP_WAIT_POLICY", "active", 0)
 3841|       |            //}
 3842|       |
 3843|       |            if (!getenv("KMP_BLOCKTIME")) {
 3844|       |                // set the time to wait before sleeping a thread
 3845|       |                // this is less aggressive than setting the wait policy to active, but should achieve similar results in most cases
 3846|       |#ifdef _WIN32
 3847|       |                _putenv_s("KMP_BLOCKTIME", "200"); // 200ms
 3848|       |#else
 3849|       |                setenv("KMP_BLOCKTIME", "200", 0); // 200ms
 3850|       |#endif
 3851|       |            }
 3852|       |#endif
 3853|      1|        }
 3854|       |
 3855|       |#if defined(__ARM_ARCH)
 3856|       |        ggml_init_arm_arch_features();
 3857|       |#endif
 3858|       |
 3859|       |#if defined(__riscv)
 3860|       |        ggml_init_riscv_arch_features();
 3861|       |#endif
 3862|       |
 3863|      1|        {
 3864|      1|            const char * env = getenv("GGML_CPU_DISABLE_FUSION");
 3865|      1|            ggml_cpu_disable_fusion = (env != NULL && atoi(env) == 1);
  ------------------
  |  Branch (3865:40): [True: 0, False: 1]
  |  Branch (3865:55): [True: 0, False: 0]
  ------------------
 3866|      1|        }
 3867|       |
 3868|      1|        is_first_call = false;
 3869|      1|    }
 3870|       |
 3871|      1|    ggml_critical_section_end();
 3872|      1|}

ggml_backend_cpu_reg:
  691|      1|ggml_backend_reg_t ggml_backend_cpu_reg(void) {
  692|       |    // init CPU feature detection
  693|      1|    ggml_cpu_init();
  694|       |
  695|      1|    static struct ggml_backend_reg ggml_backend_cpu_reg = {
  696|      1|        /* .api_version = */ GGML_BACKEND_API_VERSION,
  ------------------
  |  |   11|      1|    #define GGML_BACKEND_API_VERSION 2
  ------------------
  697|      1|        /* .iface       = */ ggml_backend_cpu_reg_i,
  698|      1|        /* .context     = */ NULL,
  699|      1|    };
  700|       |
  701|      1|    return &ggml_backend_cpu_reg;
  702|      1|}
ggml-cpu.cpp:_ZL37ggml_backend_cpu_reg_get_device_countP16ggml_backend_reg:
  508|      2|static size_t ggml_backend_cpu_reg_get_device_count(ggml_backend_reg_t reg) {
  509|      2|    return 1;
  510|       |
  511|      0|    GGML_UNUSED(reg);
  ------------------
  |  |  258|      0|#define GGML_UNUSED(x) (void)(x)
  ------------------
  512|      0|}
ggml-cpu.cpp:_ZL31ggml_backend_cpu_reg_get_deviceP16ggml_backend_regm:
  514|      1|static ggml_backend_dev_t ggml_backend_cpu_reg_get_device(ggml_backend_reg_t reg, size_t index) {
  515|      1|    GGML_ASSERT(index == 0);
  ------------------
  |  |  288|      1|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  516|       |
  517|      1|    static ggml_backend_cpu_device_context ctx;
  518|      1|    static ggml_backend_device ggml_backend_cpu_device = {
  519|      1|        /* .iface   = */ ggml_backend_cpu_device_i,
  520|      1|        /* .reg     = */ reg,
  521|      1|        /* .context = */ &ctx,
  522|      1|    };
  523|       |
  524|      1|    return &ggml_backend_cpu_device;
  525|      1|}
_ZN31ggml_backend_cpu_device_contextC2Ev:
  292|      1|    ggml_backend_cpu_device_context() {
  293|       |#ifdef __APPLE__
  294|       |        size_t len = 0;
  295|       |        if (!sysctlbyname("machdep.cpu.brand_string", NULL, &len, NULL, 0)) {
  296|       |            description.resize(len);
  297|       |            sysctlbyname("machdep.cpu.brand_string", &description[0], &len, NULL, 0); // NOLINT
  298|       |        }
  299|       |#elif defined(__linux__)
  300|       |        FILE * f = fopen("/proc/cpuinfo", "r");
  301|      1|        if (f) {
  ------------------
  |  Branch (301:13): [True: 1, False: 0]
  ------------------
  302|      1|            char buf[1024];
  303|      5|            while (fgets(buf, sizeof(buf), f)) {
  ------------------
  |  Branch (303:20): [True: 5, False: 0]
  ------------------
  304|      5|                if (strncmp(buf, "model name", 10) == 0) {
  ------------------
  |  Branch (304:21): [True: 1, False: 4]
  ------------------
  305|      1|                    char * p = strchr(buf, ':');
  306|      1|                    if (p) {
  ------------------
  |  Branch (306:25): [True: 1, False: 0]
  ------------------
  307|      1|                        p++;
  308|      2|                        while (std::isspace(*p)) {
  ------------------
  |  Branch (308:32): [True: 1, False: 1]
  ------------------
  309|      1|                            p++;
  310|      1|                        }
  311|      2|                        while (std::isspace(p[strlen(p) - 1])) {
  ------------------
  |  Branch (311:32): [True: 1, False: 1]
  ------------------
  312|      1|                            p[strlen(p) - 1] = '\0';
  313|      1|                        }
  314|      1|                        description = p;
  315|      1|                        break;
  316|      1|                    }
  317|      1|                }
  318|      5|            }
  319|      1|            fclose(f);
  320|      1|        }
  321|       |#elif defined(_WIN32)
  322|       |        HKEY hKey;
  323|       |        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  324|       |                        TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
  325|       |                        0,
  326|       |                        KEY_READ,
  327|       |                        &hKey) == ERROR_SUCCESS) {
  328|       |            DWORD cpu_brand_size = 0;
  329|       |            if (RegQueryValueExA(hKey,
  330|       |                                "ProcessorNameString",
  331|       |                                NULL,
  332|       |                                NULL,
  333|       |                                NULL,
  334|       |                                &cpu_brand_size) == ERROR_SUCCESS) {
  335|       |                description.resize(cpu_brand_size);
  336|       |                if (RegQueryValueExA(hKey,
  337|       |                                    "ProcessorNameString",
  338|       |                                    NULL,
  339|       |                                    NULL,
  340|       |                                    (LPBYTE)&description[0], // NOLINT
  341|       |                                    &cpu_brand_size) == ERROR_SUCCESS) {
  342|       |                    if (description.find('\0') != std::string::npos) {
  343|       |                        description.resize(description.find('\0'));
  344|       |                    }
  345|       |                }
  346|       |            }
  347|       |            RegCloseKey(hKey);
  348|       |        }
  349|       |#endif
  350|      1|    }

ggml-cpu.c:ggml_gelu_f32:
  968|  65.5k|inline static float ggml_gelu_f32(float x) {
  969|  65.5k|    return 0.5f*x*(1.0f + tanhf(SQRT_2_OVER_PI*x*(1.0f + GELU_COEF_A*x*x)));
  970|  65.5k|}
ggml-cpu.c:ggml_gelu_quick_f32:
 1017|  65.5k|inline static float ggml_gelu_quick_f32(float x) {
 1018|  65.5k|    return x*(1.0f/(1.0f+expf(GELU_QUICK_COEF*x)));
 1019|  65.5k|}

ggml-cpu.c:ggml_compute_fp32_to_fp16:
  407|   131k|static inline ggml_fp16_t ggml_compute_fp32_to_fp16(float f) {
  408|   131k|#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) || defined(__GNUC__) && !defined(__STRICT_ANSI__)) && (!defined(__cplusplus) || __cplusplus >= 201703L)
  409|   131k|    const float scale_to_inf = 0x1.0p+112f;
  410|   131k|    const float scale_to_zero = 0x1.0p-110f;
  411|       |#else
  412|       |    const float scale_to_inf = fp32_from_bits(UINT32_C(0x77800000));
  413|       |    const float scale_to_zero = fp32_from_bits(UINT32_C(0x08800000));
  414|       |#endif
  415|   131k|    float base = (fabsf(f) * scale_to_inf) * scale_to_zero;
  416|       |
  417|   131k|    const uint32_t w = fp32_to_bits(f);
  418|   131k|    const uint32_t shl1_w = w + w;
  419|   131k|    const uint32_t sign = w & UINT32_C(0x80000000);
  420|   131k|    uint32_t bias = shl1_w & UINT32_C(0xFF000000);
  421|   131k|    if (bias < UINT32_C(0x71000000)) {
  ------------------
  |  Branch (421:9): [True: 36.1k, False: 94.9k]
  ------------------
  422|  36.1k|        bias = UINT32_C(0x71000000);
  423|  36.1k|    }
  424|       |
  425|   131k|    base = fp32_from_bits((bias >> 1) + UINT32_C(0x07800000)) + base;
  426|   131k|    const uint32_t bits = fp32_to_bits(base);
  427|   131k|    const uint32_t exp_bits = (bits >> 13) & UINT32_C(0x00007C00);
  428|   131k|    const uint32_t mantissa_bits = bits & UINT32_C(0x00000FFF);
  429|   131k|    const uint32_t nonsign = exp_bits + mantissa_bits;
  430|   131k|    return (sign >> 16) | (shl1_w > UINT32_C(0xFF000000) ? UINT16_C(0x7E00) : nonsign);
  ------------------
  |  Branch (430:28): [True: 4.09k, False: 126k]
  ------------------
  431|   131k|}
ggml-cpu.c:fp32_to_bits:
  375|   327k|static inline uint32_t fp32_to_bits(float f) {
  376|   327k|    union {
  377|   327k|        float as_value;
  378|   327k|        uint32_t as_bits;
  379|   327k|    } fp32;
  380|   327k|    fp32.as_value = f;
  381|   327k|    return fp32.as_bits;
  382|   327k|}
ggml-cpu.c:fp32_from_bits:
  366|   327k|static inline float fp32_from_bits(uint32_t w) {
  367|   327k|    union {
  368|   327k|        uint32_t as_bits;
  369|   327k|        float as_value;
  370|   327k|    } fp32;
  371|   327k|    fp32.as_bits = w;
  372|   327k|    return fp32.as_value;
  373|   327k|}
ggml-cpu.c:ggml_compute_fp16_to_fp32:
  384|  65.5k|static inline float ggml_compute_fp16_to_fp32(ggml_fp16_t h) {
  385|  65.5k|    const uint32_t w = (uint32_t) h << 16;
  386|  65.5k|    const uint32_t sign = w & UINT32_C(0x80000000);
  387|  65.5k|    const uint32_t two_w = w + w;
  388|       |
  389|  65.5k|    const uint32_t exp_offset = UINT32_C(0xE0) << 23;
  390|  65.5k|#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) || defined(__GNUC__) && !defined(__STRICT_ANSI__)) && (!defined(__cplusplus) || __cplusplus >= 201703L)
  391|  65.5k|    const float exp_scale = 0x1.0p-112f;
  392|       |#else
  393|       |    const float exp_scale = fp32_from_bits(UINT32_C(0x7800000));
  394|       |#endif
  395|  65.5k|    const float normalized_value = fp32_from_bits((two_w >> 4) + exp_offset) * exp_scale;
  396|       |
  397|  65.5k|    const uint32_t magic_mask = UINT32_C(126) << 23;
  398|  65.5k|    const float magic_bias = 0.5f;
  399|  65.5k|    const float denormalized_value = fp32_from_bits((two_w >> 17) | magic_mask) - magic_bias;
  400|       |
  401|  65.5k|    const uint32_t denormalized_cutoff = UINT32_C(1) << 27;
  402|  65.5k|    const uint32_t result = sign |
  403|  65.5k|        (two_w < denormalized_cutoff ? fp32_to_bits(denormalized_value) : fp32_to_bits(normalized_value));
  ------------------
  |  Branch (403:10): [True: 2.04k, False: 63.4k]
  ------------------
  404|  65.5k|    return fp32_from_bits(result);
  405|  65.5k|}
ggml-cpu.c:ggml_e8m0_to_fp32_half:
  477|    256|static inline float ggml_e8m0_to_fp32_half(uint8_t x) {
  478|    256|    uint32_t bits;
  479|       |
  480|       |    // For x < 2: use precomputed denormal patterns
  481|    256|    if (x < 2) {
  ------------------
  |  Branch (481:9): [True: 2, False: 254]
  ------------------
  482|       |        // 0x00200000 = 2^(-128), 0x00400000 = 2^(-127)
  483|      2|        bits = 0x00200000 << x;
  484|      2|    }
  485|       |    // For x >= 2: normalized exponent adjustment
  486|    254|    else {
  487|       |        // 0.5 * 2^(x-127) = 2^(x-128) = normalized with exponent (x-1)
  488|    254|        bits = (uint32_t)(x - 1) << 23;
  489|    254|    }
  490|       |    // Note: NaNs are not handled here
  491|       |
  492|    256|    float result;
  493|    256|    memcpy(&result, &bits, sizeof(float));
  494|    256|    return result;
  495|    256|}
ggml-cpu.c:ggml_ue4m3_to_fp32:
  502|    256|static inline float ggml_ue4m3_to_fp32(uint8_t x) {
  503|    256|    if (x == 0 || x == 0x7F) {
  ------------------
  |  Branch (503:9): [True: 1, False: 255]
  |  Branch (503:19): [True: 1, False: 254]
  ------------------
  504|      2|        return 0.0f;
  505|      2|    }
  506|    254|    int   exp = (x >> 3) & 0xF;
  507|    254|    int   man = x & 0x7;
  508|    254|    float raw;
  509|    254|    if (exp == 0) {
  ------------------
  |  Branch (509:9): [True: 15, False: 239]
  ------------------
  510|     15|        raw = ldexpf((float) man, -9);
  511|    239|    } else {
  512|    239|        raw = ldexpf(1.0f + (float) man / 8.0f, exp - 7);
  513|    239|    }
  514|    254|    return raw * 0.5f;
  515|    256|}

iq2xs_free_impl:
 3260|     10|void iq2xs_free_impl(enum ggml_type type) {
 3261|     10|    GGML_ASSERT(type == GGML_TYPE_IQ2_XXS || type == GGML_TYPE_IQ2_XS || type == GGML_TYPE_IQ1_S || type == GGML_TYPE_IQ1_M || type == GGML_TYPE_IQ2_S);
  ------------------
  |  |  288|     60|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:30): [True: 2, False: 8]
  |  |  |  Branch (288:30): [True: 2, False: 6]
  |  |  |  Branch (288:30): [True: 2, False: 4]
  |  |  |  Branch (288:30): [True: 2, False: 2]
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 3262|     10|    const int gindex = iq2_data_index(type);
 3263|     10|    if (iq2_data[gindex].grid) {
  ------------------
  |  Branch (3263:9): [True: 0, False: 10]
  ------------------
 3264|      0|        free(iq2_data[gindex].grid);       iq2_data[gindex].grid = NULL;
 3265|      0|        free(iq2_data[gindex].map);        iq2_data[gindex].map  = NULL;
 3266|       |        free(iq2_data[gindex].neighbours); iq2_data[gindex].neighbours = NULL;
 3267|      0|    }
 3268|     10|}
iq3xs_free_impl:
 3904|      4|void iq3xs_free_impl(int grid_size) {
 3905|      4|    GGML_ASSERT(grid_size == 256 || grid_size == 512);
  ------------------
  |  |  288|      6|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:30): [True: 2, False: 2]
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 3906|      4|    const int gindex = iq3_data_index(grid_size);
 3907|      4|    if (iq3_data[gindex].grid) {
  ------------------
  |  Branch (3907:9): [True: 0, False: 4]
  ------------------
 3908|      0|        free(iq3_data[gindex].grid);       iq3_data[gindex].grid = NULL;
 3909|      0|        free(iq3_data[gindex].map);        iq3_data[gindex].map  = NULL;
 3910|       |        free(iq3_data[gindex].neighbours); iq3_data[gindex].neighbours = NULL;
 3911|      0|    }
 3912|      4|}
ggml-quants.c:iq2_data_index:
 2833|     10|static inline int iq2_data_index(enum ggml_type type) {
 2834|     10|    GGML_ASSERT(type == GGML_TYPE_IQ2_XXS || type == GGML_TYPE_IQ2_XS || type == GGML_TYPE_IQ1_S || type == GGML_TYPE_IQ1_M || type == GGML_TYPE_IQ2_S);
  ------------------
  |  |  288|     60|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:30): [True: 2, False: 8]
  |  |  |  Branch (288:30): [True: 2, False: 6]
  |  |  |  Branch (288:30): [True: 2, False: 4]
  |  |  |  Branch (288:30): [True: 2, False: 2]
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 2835|     10|    return type == GGML_TYPE_IQ2_XXS ? 0 :
  ------------------
  |  Branch (2835:12): [True: 2, False: 8]
  ------------------
 2836|     10|           type == GGML_TYPE_IQ2_XS  ? 1 :
  ------------------
  |  Branch (2836:12): [True: 2, False: 6]
  ------------------
 2837|      8|           type == GGML_TYPE_IQ1_S || type == GGML_TYPE_IQ1_M ? 2 : 3;
  ------------------
  |  Branch (2837:12): [True: 2, False: 4]
  |  Branch (2837:39): [True: 2, False: 2]
  ------------------
 2838|     10|}
ggml-quants.c:iq3_data_index:
 3691|      4|static inline int iq3_data_index(int grid_size) {
 3692|      4|    (void)grid_size;
 3693|      4|    GGML_ASSERT(grid_size == 256 || grid_size == 512);
  ------------------
  |  |  288|      6|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:30): [True: 2, False: 2]
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 3694|      4|    return grid_size == 256 ? 0 : 1;
  ------------------
  |  Branch (3694:12): [True: 2, False: 2]
  ------------------
 3695|      4|}

ggml_critical_section_start:
    6|      7|void ggml_critical_section_start() {
    7|      7|    ggml_critical_section_mutex.lock();
    8|      7|}
ggml_critical_section_end:
   10|      7|void ggml_critical_section_end(void) {
   11|      7|    ggml_critical_section_mutex.unlock();
   12|      7|}

ggml_log_internal:
  306|      4|void ggml_log_internal(enum ggml_log_level level, const char * format, ...) {
  307|      4|    va_list args;
  308|      4|    va_start(args, format);
  309|      4|    ggml_log_internal_v(level, format, args);
  310|       |    va_end(args);
  311|      4|}
ggml_log_callback_default:
  313|      4|void ggml_log_callback_default(enum ggml_log_level level, const char * text, void * user_data) {
  314|      4|    (void) level;
  315|      4|    (void) user_data;
  316|      4|    fputs(text, stderr);
  317|       |    fflush(stderr);
  318|      4|}
ggml_aligned_malloc:
  331|      4|void * ggml_aligned_malloc(size_t size) {
  332|       |#if defined(__s390x__)
  333|       |    const int alignment = 256;
  334|       |#else
  335|      4|    const int alignment = 64;
  336|      4|#endif
  337|       |
  338|       |#if defined(_MSC_VER) || defined(__MINGW32__)
  339|       |    return _aligned_malloc(size, alignment);
  340|       |#else
  341|      4|    if (size == 0) {
  ------------------
  |  Branch (341:9): [True: 0, False: 4]
  ------------------
  342|      0|        GGML_LOG_WARN("Behavior may be unexpected when allocating 0 bytes for ggml_aligned_malloc!\n");
  ------------------
  |  |  120|      0|#define GGML_LOG_WARN(...)  ggml_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  343|      0|        return NULL;
  344|      0|    }
  345|      4|    void * aligned_memory = NULL;
  346|       |  #ifdef GGML_USE_CPU_HBM
  347|       |    int result = hbw_posix_memalign(&aligned_memory, alignment, size);
  348|       |  #elif TARGET_OS_OSX
  349|       |    GGML_UNUSED(alignment);
  350|       |    kern_return_t alloc_status = vm_allocate((vm_map_t) mach_task_self(), (vm_address_t *) &aligned_memory, size, VM_FLAGS_ANYWHERE);
  351|       |    int result = EFAULT;
  352|       |    switch (alloc_status) {
  353|       |        case KERN_SUCCESS:
  354|       |            result = 0;
  355|       |            break;
  356|       |        case KERN_INVALID_ADDRESS:
  357|       |            result = EINVAL;
  358|       |            break;
  359|       |        case KERN_NO_SPACE:
  360|       |            result = ENOMEM;
  361|       |            break;
  362|       |        default:
  363|       |            result = EFAULT;
  364|       |            break;
  365|       |    }
  366|       |  #else
  367|      4|    int result = posix_memalign(&aligned_memory, alignment, size);
  368|      4|  #endif
  369|      4|    if (result != 0) {
  ------------------
  |  Branch (369:9): [True: 0, False: 4]
  ------------------
  370|       |        // Handle allocation failure
  371|      0|        const char *error_desc = "unknown allocation error";
  372|      0|        switch (result) {
  ------------------
  |  Branch (372:17): [True: 0, False: 0]
  ------------------
  373|      0|            case EINVAL:
  ------------------
  |  Branch (373:13): [True: 0, False: 0]
  ------------------
  374|      0|                error_desc = "invalid alignment value";
  375|      0|                break;
  376|      0|            case ENOMEM:
  ------------------
  |  Branch (376:13): [True: 0, False: 0]
  ------------------
  377|      0|                error_desc = "insufficient memory";
  378|      0|                break;
  379|      0|        }
  380|      0|        GGML_LOG_ERROR("%s: %s (attempted to allocate %6.2f MB)\n", __func__, error_desc, size/(1024.0*1024.0));
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  381|      0|        return NULL;
  382|      0|    }
  383|      4|    return aligned_memory;
  384|      4|#endif
  385|      4|}
ggml_aligned_free:
  387|      4|void ggml_aligned_free(void * ptr, size_t size) {
  388|      4|    GGML_UNUSED(size);
  ------------------
  |  |  258|      4|#define GGML_UNUSED(x) (void)(x)
  ------------------
  389|       |#if defined(_MSC_VER) || defined(__MINGW32__)
  390|       |    _aligned_free(ptr);
  391|       |#elif GGML_USE_CPU_HBM
  392|       |    if (ptr != NULL) {
  393|       |        hbw_free(ptr);
  394|       |    }
  395|       |#elif TARGET_OS_OSX
  396|       |    if (ptr != NULL) {
  397|       |        vm_deallocate((vm_map_t)mach_task_self(), (vm_address_t)ptr, size);
  398|       |    }
  399|       |#else
  400|      4|    free(ptr);
  401|      4|#endif
  402|      4|}
ggml_time_init:
  562|      9|void ggml_time_init(void) {}
ggml_time_us:
  569|      2|int64_t ggml_time_us(void) {
  570|      2|    struct timespec ts;
  571|       |    clock_gettime(CLOCK_MONOTONIC, &ts);
  572|      2|    return (int64_t)ts.tv_sec*1000000 + (int64_t)ts.tv_nsec/1000;
  573|      2|}
ggml_fopen:
  608|      2|FILE * ggml_fopen(const char * fname, const char * mode) {
  609|       |#ifdef _WIN32
  610|       |    FILE * file = NULL;
  611|       |
  612|       |    // convert fname (UTF-8)
  613|       |    wchar_t * wfname = ggml_mbstowcs(fname);
  614|       |    if (wfname) {
  615|       |        // convert mode (UTF-8)
  616|       |        wchar_t * wmode = ggml_mbstowcs(mode);
  617|       |        if (wmode) {
  618|       |            // open file
  619|       |            file = _wfopen(wfname, wmode);
  620|       |            GGML_FREE(wmode);
  621|       |        }
  622|       |
  623|       |        GGML_FREE(wfname);
  624|       |    }
  625|       |
  626|       |    return file;
  627|       |#else
  628|      2|    return fopen(fname, mode);
  629|      2|#endif
  630|       |
  631|      2|}
ggml_init:
 1606|      4|struct ggml_context * ggml_init(struct ggml_init_params params) {
 1607|      4|    bool is_first_call = true;
 1608|       |
 1609|      4|    ggml_critical_section_start();
 1610|       |
 1611|      4|    if (is_first_call) {
  ------------------
  |  Branch (1611:9): [True: 4, False: 0]
  ------------------
 1612|       |        // initialize time system (required on Windows)
 1613|      4|        ggml_time_init();
 1614|       |
 1615|      4|        is_first_call = false;
 1616|      4|    }
 1617|       |
 1618|      4|    ggml_critical_section_end();
 1619|       |
 1620|      4|    struct ggml_context * ctx = GGML_MALLOC(sizeof(struct ggml_context));
  ------------------
  |  |  434|      4|#define GGML_MALLOC(size)      ggml_malloc(size)
  ------------------
 1621|       |
 1622|       |    // allow to call ggml_init with 0 size
 1623|      4|    if (params.mem_size == 0) {
  ------------------
  |  Branch (1623:9): [True: 4, False: 0]
  ------------------
 1624|      4|        params.mem_size = GGML_MEM_ALIGN;
  ------------------
  |  |  243|      4|    #define GGML_MEM_ALIGN 16
  ------------------
 1625|      4|    }
 1626|       |
 1627|      4|    const size_t mem_size = params.mem_buffer ? params.mem_size : GGML_PAD(params.mem_size, GGML_MEM_ALIGN);
  ------------------
  |  |  267|      4|#define GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
  ------------------
  |  Branch (1627:29): [True: 0, False: 4]
  ------------------
 1628|       |
 1629|      4|    *ctx = (struct ggml_context) {
 1630|      4|        /*.mem_size           =*/ mem_size,
 1631|      4|        /*.mem_buffer         =*/ params.mem_buffer ? params.mem_buffer : ggml_aligned_malloc(mem_size),
  ------------------
  |  Branch (1631:35): [True: 0, False: 4]
  ------------------
 1632|      4|        /*.mem_buffer_owned   =*/ params.mem_buffer ? false : true,
  ------------------
  |  Branch (1632:35): [True: 0, False: 4]
  ------------------
 1633|      4|        /*.no_alloc           =*/ params.no_alloc,
 1634|      4|        /*.n_objects          =*/ 0,
 1635|      4|        /*.objects_begin      =*/ NULL,
 1636|      4|        /*.objects_end        =*/ NULL,
 1637|      4|    };
 1638|       |
 1639|      4|    GGML_ASSERT(ctx->mem_buffer != NULL);
  ------------------
  |  |  288|      4|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 1640|       |
 1641|      4|    GGML_ASSERT_ALIGNED(ctx->mem_buffer);
  ------------------
  |  | 1602|      4|    GGML_ASSERT(((uintptr_t) (ptr))%GGML_MEM_ALIGN == 0)
  |  |  ------------------
  |  |  |  |  288|      4|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (288:28): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1642|       |
 1643|      4|    GGML_PRINT_DEBUG("%s: context initialized\n", __func__);
 1644|       |
 1645|      4|    return ctx;
 1646|      4|}
ggml_free:
 1658|      4|void ggml_free(struct ggml_context * ctx) {
 1659|      4|    if (ctx == NULL) {
  ------------------
  |  Branch (1659:9): [True: 0, False: 4]
  ------------------
 1660|      0|        return;
 1661|      0|    }
 1662|       |
 1663|      4|    if (ctx->mem_buffer_owned) {
  ------------------
  |  Branch (1663:9): [True: 4, False: 0]
  ------------------
 1664|      4|        ggml_aligned_free(ctx->mem_buffer, ctx->mem_size);
 1665|      4|    }
 1666|       |
 1667|      4|    GGML_FREE(ctx);
  ------------------
  |  |  437|      4|#define GGML_FREE(ptr) free(ptr)
  ------------------
 1668|      4|}
ggml_quantize_free:
 7760|      2|void ggml_quantize_free(void) {
 7761|      2|    ggml_critical_section_start();
 7762|       |
 7763|      2|    iq2xs_free_impl(GGML_TYPE_IQ2_XXS);
 7764|      2|    iq2xs_free_impl(GGML_TYPE_IQ2_XS);
 7765|      2|    iq2xs_free_impl(GGML_TYPE_IQ2_S);
 7766|      2|    iq2xs_free_impl(GGML_TYPE_IQ1_S);
 7767|      2|    iq2xs_free_impl(GGML_TYPE_IQ1_M);
 7768|      2|    iq3xs_free_impl(256);
 7769|      2|    iq3xs_free_impl(512);
 7770|       |
 7771|      2|    ggml_critical_section_end();
 7772|      2|}
ggml.c:ggml_log_internal_v:
  286|      4|static void ggml_log_internal_v(enum ggml_log_level level, const char * format, va_list args) {
  287|      4|    if (format == NULL) {
  ------------------
  |  Branch (287:9): [True: 0, False: 4]
  ------------------
  288|      0|        return;
  289|      0|    }
  290|      4|    va_list args_copy;
  291|      4|    va_copy(args_copy, args);
  292|      4|    char buffer[128];
  293|      4|    int len = vsnprintf(buffer, 128, format, args);
  294|      4|    if (len < 128) {
  ------------------
  |  Branch (294:9): [True: 4, False: 0]
  ------------------
  295|      4|        g_logger_state.log_callback(level, buffer, g_logger_state.log_callback_user_data);
  296|      4|    } else {
  297|      0|        char * buffer2 = (char *) calloc(len + 1, sizeof(char));
  298|      0|        vsnprintf(buffer2, len + 1, format, args_copy);
  299|      0|        buffer2[len] = 0;
  300|      0|        g_logger_state.log_callback(level, buffer2, g_logger_state.log_callback_user_data);
  301|      0|        free(buffer2);
  302|      0|    }
  303|       |    va_end(args_copy);
  304|      4|}
ggml.c:ggml_malloc:
  405|      4|inline static void * ggml_malloc(size_t size) {
  406|      4|    if (size == 0) {
  ------------------
  |  Branch (406:9): [True: 0, False: 4]
  ------------------
  407|      0|        GGML_LOG_WARN("Behavior may be unexpected when allocating 0 bytes for ggml_malloc!\n");
  ------------------
  |  |  120|      0|#define GGML_LOG_WARN(...)  ggml_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  408|      0|        return NULL;
  409|      0|    }
  410|      4|    void * result = malloc(size);
  411|      4|    if (result == NULL) {
  ------------------
  |  Branch (411:9): [True: 0, False: 4]
  ------------------
  412|      0|        GGML_LOG_ERROR("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0));
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  413|      0|        GGML_ABORT("fatal error");
  ------------------
  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  ------------------
  414|      0|    }
  415|      4|    return result;
  416|      4|}

gguf_init_from_file_ptr:
  932|      2|struct gguf_context * gguf_init_from_file_ptr(FILE * file, struct gguf_init_params params) {
  933|      2|    if (!file) {
  ------------------
  |  Branch (933:9): [True: 0, False: 2]
  ------------------
  934|      0|        return nullptr;
  935|      0|    }
  936|       |
  937|      2|    const int64_t cur = gguf_ftell(file);
  ------------------
  |  |   25|      2|#    define gguf_ftell ftello
  ------------------
  938|      2|    if (cur < 0) {
  ------------------
  |  Branch (938:9): [True: 0, False: 2]
  ------------------
  939|      0|        return nullptr;
  940|      0|    }
  941|       |
  942|      2|    gguf_file_reader reader = {
  943|      2|        /*.file   = */ file,
  944|      2|        /*.offset = */ static_cast<uint64_t>(cur),
  945|      2|    };
  946|       |    const struct gguf_reader gr(gguf_file_reader_callback, &reader, SIZE_MAX, reader.offset, gguf_reader::file_remain(file));
  947|      2|    return gguf_init_from_reader(gr, params);
  948|      2|}
gguf_init_from_file:
  983|      2|struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_params params) {
  984|      2|    FILE * file = ggml_fopen(fname, "rb");
  985|       |
  986|      2|    if (!file) {
  ------------------
  |  Branch (986:9): [True: 0, False: 2]
  ------------------
  987|      0|        GGML_LOG_ERROR("%s: failed to open GGUF file '%s' (%s)\n", __func__, fname, strerror(errno));
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  988|      0|        return nullptr;
  989|      0|    }
  990|       |
  991|      2|    struct gguf_context * result = gguf_init_from_file_ptr(file, params);
  992|      2|    fclose(file);
  993|      2|    return result;
  994|      2|}
gguf_free:
  996|      2|void gguf_free(struct gguf_context * ctx) {
  997|      2|    if (ctx == nullptr) {
  ------------------
  |  Branch (997:9): [True: 0, False: 2]
  ------------------
  998|      0|        return;
  999|      0|    }
 1000|      2|    delete ctx;
 1001|      2|}
_ZN11gguf_readerC2EPFmPvS0_mmES0_mmm:
  237|      2|        : callback(callback),
  238|      2|          userdata(userdata),
  239|      2|          max_chunk_read(max_chunk_read),
  240|      2|          data_offset(data_offset),
  241|      2|          nbytes_remain(nbytes_remain) {
  242|      2|        GGML_ASSERT(max_chunk_read > 0);
  ------------------
  |  |  288|      2|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  243|      2|    }
gguf.cpp:_ZL21gguf_init_from_readerRK11gguf_reader16gguf_init_params:
  451|      2|static struct gguf_context * gguf_init_from_reader(const struct gguf_reader & gr, struct gguf_init_params params) {
  452|      2|    struct gguf_context * ctx = new gguf_context;
  453|       |
  454|      2|    bool ok = true;
  455|       |
  456|       |    // file magic
  457|      2|    {
  458|      2|        std::vector<char> magic;
  459|      2|        ok = ok && gr.read(magic, 4);
  ------------------
  |  Branch (459:14): [True: 2, False: 0]
  |  Branch (459:20): [True: 2, False: 0]
  ------------------
  460|       |
  461|      2|        if (!ok) {
  ------------------
  |  Branch (461:13): [True: 0, False: 2]
  ------------------
  462|      0|            GGML_LOG_ERROR("%s: failed to read magic\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  463|      0|            gguf_free(ctx);
  464|      0|            return nullptr;
  465|      0|        }
  466|       |
  467|     10|        for (uint32_t i = 0; i < magic.size(); i++) {
  ------------------
  |  Branch (467:30): [True: 8, False: 2]
  ------------------
  468|      8|            if (magic[i] != GGUF_MAGIC[i]) {
  ------------------
  |  |   41|      8|#define GGUF_MAGIC   "GGUF"
  ------------------
  |  Branch (468:17): [True: 0, False: 8]
  ------------------
  469|      0|                char c0 = isprint(magic[0]) ? magic[0] : '?';
  ------------------
  |  Branch (469:27): [True: 0, False: 0]
  ------------------
  470|      0|                char c1 = isprint(magic[1]) ? magic[1] : '?';
  ------------------
  |  Branch (470:27): [True: 0, False: 0]
  ------------------
  471|      0|                char c2 = isprint(magic[2]) ? magic[2] : '?';
  ------------------
  |  Branch (471:27): [True: 0, False: 0]
  ------------------
  472|      0|                char c3 = isprint(magic[3]) ? magic[3] : '?';
  ------------------
  |  Branch (472:27): [True: 0, False: 0]
  ------------------
  473|      0|                GGML_LOG_ERROR("%s: invalid magic characters: '%c%c%c%c', expected 'GGUF'\n", __func__, c0, c1, c2, c3);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  474|      0|                gguf_free(ctx);
  475|      0|                return nullptr;
  476|      0|            }
  477|      8|        }
  478|      2|    }
  479|       |
  480|       |    // header
  481|      2|    int64_t n_kv      = 0;
  482|      2|    int64_t n_tensors = 0;
  483|       |
  484|      2|    if (ok && gr.read(ctx->version)) {
  ------------------
  |  Branch (484:9): [True: 2, False: 0]
  |  Branch (484:15): [True: 2, False: 0]
  ------------------
  485|      2|        if (ok && ctx->version == 0) {
  ------------------
  |  Branch (485:13): [True: 2, False: 0]
  |  Branch (485:19): [True: 1, False: 1]
  ------------------
  486|      1|            GGML_LOG_ERROR("%s: bad GGUF version: %" PRIu32 "\n", __func__, ctx->version);
  ------------------
  |  |  121|      1|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  487|      1|            ok = false;
  488|      1|        }
  489|       |
  490|       |        /*
  491|       |         * bit layout is different when reading non-native endian models.
  492|       |         * assuming that the GGUF version is 3, the non-native endian model
  493|       |         * would read it as 0x30000000. we can use the AND operation against
  494|       |         * the last 4 hexadecimal digits to check if the model is the same
  495|       |         * endianness as the host system.
  496|       |        */
  497|      2|        if (ok && (ctx->version & 0x0000FFFF) == 0x00000000) {
  ------------------
  |  Branch (497:13): [True: 1, False: 1]
  |  Branch (497:19): [True: 0, False: 1]
  ------------------
  498|      0|            GGML_LOG_ERROR("%s: failed to load model: this GGUF file version %" PRIu32 " is extremely large, is there a mismatch between the host and model endianness?\n", __func__, ctx->version);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  499|      0|            ok = false;
  500|      0|        }
  501|       |
  502|      2|        if (ok && ctx->version == 1) {
  ------------------
  |  Branch (502:13): [True: 1, False: 1]
  |  Branch (502:19): [True: 0, False: 1]
  ------------------
  503|      0|            GGML_LOG_ERROR("%s: GGUFv1 is no longer supported, please use a more up-to-date version\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  504|      0|            ok = false;
  505|      0|        }
  506|      2|        if (ok && ctx->version > GGUF_VERSION) {
  ------------------
  |  |   42|      1|#define GGUF_VERSION 3
  ------------------
  |  Branch (506:13): [True: 1, False: 1]
  |  Branch (506:19): [True: 1, False: 0]
  ------------------
  507|      1|            GGML_LOG_ERROR("%s: this GGUF file is version %" PRIu32 " but this software only supports up to version %d\n",
  ------------------
  |  |  121|      1|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  508|      1|                __func__, ctx->version, GGUF_VERSION);
  509|      1|            ok = false;
  510|      1|        }
  511|      2|    } else {
  512|      0|        ok = false;
  513|      0|    }
  514|       |
  515|      2|    if (ok && gr.read(n_tensors)) {
  ------------------
  |  Branch (515:9): [True: 0, False: 2]
  |  Branch (515:15): [True: 0, False: 0]
  ------------------
  516|      0|        static_assert(sizeof(size_t) <= 8 && sizeof(gguf_tensor_info) >= 2, "int64_t insufficient for indexing");
  517|      0|        if (n_tensors < 0 || n_tensors > int64_t(SIZE_MAX/sizeof(gguf_tensor_info))) {
  ------------------
  |  Branch (517:13): [True: 0, False: 0]
  |  Branch (517:30): [True: 0, False: 0]
  ------------------
  518|      0|            GGML_LOG_ERROR("%s: number of tensors is %" PRIi64 " but must be in [0, %zu]\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  519|      0|                __func__, n_tensors, SIZE_MAX/sizeof(gguf_tensor_info));
  520|      0|            ok = false;
  521|      0|        }
  522|      2|    } else {
  523|      2|        ok = false;
  524|      2|    }
  525|       |
  526|      2|    if (ok && gr.read(n_kv)) {
  ------------------
  |  Branch (526:9): [True: 0, False: 2]
  |  Branch (526:15): [True: 0, False: 0]
  ------------------
  527|      0|        static_assert(sizeof(size_t) <= 8 && sizeof(gguf_tensor_info) >= 2, "int64_t insufficient for indexing");
  528|      0|        if (n_kv < 0 || n_kv > int64_t(SIZE_MAX/sizeof(gguf_kv))) {
  ------------------
  |  Branch (528:13): [True: 0, False: 0]
  |  Branch (528:25): [True: 0, False: 0]
  ------------------
  529|      0|            GGML_LOG_ERROR("%s: number of key value pairs is %" PRIi64 " but must be in [0, %zu]\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  530|      0|                    __func__, n_kv, SIZE_MAX/sizeof(gguf_kv));
  531|      0|            ok = false;
  532|      0|        }
  533|      2|    } else {
  534|      2|        ok = false;
  535|      2|    }
  536|       |
  537|      2|    if (!ok) {
  ------------------
  |  Branch (537:9): [True: 2, False: 0]
  ------------------
  538|      2|        GGML_LOG_ERROR("%s: failed to read header\n", __func__);
  ------------------
  |  |  121|      2|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  539|      2|        gguf_free(ctx);
  540|      2|        return nullptr;
  541|      2|    }
  542|       |
  543|       |    // KV pairs
  544|      0|    {
  545|      0|        for (int64_t i = 0; ok && i < n_kv; ++i) {
  ------------------
  |  Branch (545:29): [True: 0, False: 0]
  |  Branch (545:35): [True: 0, False: 0]
  ------------------
  546|      0|            std::string key;
  547|      0|            gguf_type   type     = gguf_type(-1);
  548|      0|            bool        is_array = false;
  549|      0|            uint64_t    n        = 1;
  550|       |
  551|      0|            try {
  552|      0|                ok = ok && gr.read(key);
  ------------------
  |  Branch (552:22): [True: 0, False: 0]
  |  Branch (552:28): [True: 0, False: 0]
  ------------------
  553|      0|            } catch (std::length_error &) {
  554|      0|                GGML_LOG_ERROR("%s: encountered length_error while reading key %" PRIi64 "\n", __func__, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  555|      0|                ok = false;
  556|      0|            } catch (std::bad_alloc &) {
  557|      0|                GGML_LOG_ERROR("%s: encountered bad_alloc error while reading key %" PRIi64 "\n", __func__, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  558|      0|                ok = false;
  559|      0|            }
  560|      0|            if (ok && key.empty()) {
  ------------------
  |  Branch (560:17): [True: 0, False: 0]
  |  Branch (560:23): [True: 0, False: 0]
  ------------------
  561|      0|                GGML_LOG_ERROR("%s: key %" PRIi64 " is empty\n", __func__, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  562|      0|                ok = false;
  563|      0|            }
  564|      0|            for (size_t j = 0; ok && j < ctx->kv.size(); ++j) {
  ------------------
  |  Branch (564:32): [True: 0, False: 0]
  |  Branch (564:38): [True: 0, False: 0]
  ------------------
  565|      0|                if (key == ctx->kv[j].key) {
  ------------------
  |  Branch (565:21): [True: 0, False: 0]
  ------------------
  566|      0|                    GGML_LOG_ERROR("%s: duplicate key '%s' for tensors %zu and %" PRIi64 " \n", __func__, key.c_str(), j, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  567|      0|                    ok = false;
  568|      0|                }
  569|      0|            }
  570|      0|            if (!ok) {
  ------------------
  |  Branch (570:17): [True: 0, False: 0]
  ------------------
  571|      0|                break;
  572|      0|            }
  573|       |
  574|      0|            ok = ok && gr.read(type);
  ------------------
  |  Branch (574:18): [True: 0, False: 0]
  |  Branch (574:24): [True: 0, False: 0]
  ------------------
  575|      0|            if (type == GGUF_TYPE_ARRAY) {
  ------------------
  |  Branch (575:17): [True: 0, False: 0]
  ------------------
  576|      0|                is_array = true;
  577|      0|                ok = ok && gr.read(type);
  ------------------
  |  Branch (577:22): [True: 0, False: 0]
  |  Branch (577:28): [True: 0, False: 0]
  ------------------
  578|      0|                ok = ok && gr.read(n);
  ------------------
  |  Branch (578:22): [True: 0, False: 0]
  |  Branch (578:28): [True: 0, False: 0]
  ------------------
  579|      0|            }
  580|      0|            if (!ok) {
  ------------------
  |  Branch (580:17): [True: 0, False: 0]
  ------------------
  581|      0|                break;
  582|      0|            }
  583|       |
  584|      0|            switch (type) {
  585|      0|                case GGUF_TYPE_UINT8:   ok = ok && gguf_read_emplace_helper<uint8_t>    (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (585:17): [True: 0, False: 0]
  |  Branch (585:46): [True: 0, False: 0]
  |  Branch (585:52): [True: 0, False: 0]
  ------------------
  586|      0|                case GGUF_TYPE_INT8:    ok = ok && gguf_read_emplace_helper<int8_t>     (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (586:17): [True: 0, False: 0]
  |  Branch (586:46): [True: 0, False: 0]
  |  Branch (586:52): [True: 0, False: 0]
  ------------------
  587|      0|                case GGUF_TYPE_UINT16:  ok = ok && gguf_read_emplace_helper<uint16_t>   (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (587:17): [True: 0, False: 0]
  |  Branch (587:46): [True: 0, False: 0]
  |  Branch (587:52): [True: 0, False: 0]
  ------------------
  588|      0|                case GGUF_TYPE_INT16:   ok = ok && gguf_read_emplace_helper<int16_t>    (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (588:17): [True: 0, False: 0]
  |  Branch (588:46): [True: 0, False: 0]
  |  Branch (588:52): [True: 0, False: 0]
  ------------------
  589|      0|                case GGUF_TYPE_UINT32:  ok = ok && gguf_read_emplace_helper<uint32_t>   (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (589:17): [True: 0, False: 0]
  |  Branch (589:46): [True: 0, False: 0]
  |  Branch (589:52): [True: 0, False: 0]
  ------------------
  590|      0|                case GGUF_TYPE_INT32:   ok = ok && gguf_read_emplace_helper<int32_t>    (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (590:17): [True: 0, False: 0]
  |  Branch (590:46): [True: 0, False: 0]
  |  Branch (590:52): [True: 0, False: 0]
  ------------------
  591|      0|                case GGUF_TYPE_FLOAT32: ok = ok && gguf_read_emplace_helper<float>      (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (591:17): [True: 0, False: 0]
  |  Branch (591:46): [True: 0, False: 0]
  |  Branch (591:52): [True: 0, False: 0]
  ------------------
  592|      0|                case GGUF_TYPE_BOOL:    ok = ok && gguf_read_emplace_helper<bool>       (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (592:17): [True: 0, False: 0]
  |  Branch (592:46): [True: 0, False: 0]
  |  Branch (592:52): [True: 0, False: 0]
  ------------------
  593|      0|                case GGUF_TYPE_STRING:  ok = ok && gguf_read_emplace_helper<std::string>(gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (593:17): [True: 0, False: 0]
  |  Branch (593:46): [True: 0, False: 0]
  |  Branch (593:52): [True: 0, False: 0]
  ------------------
  594|      0|                case GGUF_TYPE_UINT64:  ok = ok && gguf_read_emplace_helper<uint64_t>   (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (594:17): [True: 0, False: 0]
  |  Branch (594:46): [True: 0, False: 0]
  |  Branch (594:52): [True: 0, False: 0]
  ------------------
  595|      0|                case GGUF_TYPE_INT64:   ok = ok && gguf_read_emplace_helper<int64_t>    (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (595:17): [True: 0, False: 0]
  |  Branch (595:46): [True: 0, False: 0]
  |  Branch (595:52): [True: 0, False: 0]
  ------------------
  596|      0|                case GGUF_TYPE_FLOAT64: ok = ok && gguf_read_emplace_helper<double>     (gr, ctx->kv, key, is_array, n); break;
  ------------------
  |  Branch (596:17): [True: 0, False: 0]
  |  Branch (596:46): [True: 0, False: 0]
  |  Branch (596:52): [True: 0, False: 0]
  ------------------
  597|      0|                case GGUF_TYPE_ARRAY:
  ------------------
  |  Branch (597:17): [True: 0, False: 0]
  ------------------
  598|      0|                default:
  ------------------
  |  Branch (598:17): [True: 0, False: 0]
  ------------------
  599|      0|                    {
  600|      0|                        GGML_LOG_ERROR("%s: key '%s' has invalid GGUF type %d\n", __func__, key.c_str(), type);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  601|      0|                        ok = false;
  602|      0|                    } break;
  603|      0|            }
  604|      0|        }
  605|       |
  606|      0|        if (!ok) {
  ------------------
  |  Branch (606:13): [True: 0, False: 0]
  ------------------
  607|      0|            GGML_LOG_ERROR("%s: failed to read key-value pairs\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  608|      0|            gguf_free(ctx);
  609|      0|            return nullptr;
  610|      0|        }
  611|      0|        GGML_ASSERT(int64_t(ctx->kv.size()) == n_kv);
  ------------------
  |  |  288|      0|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  612|       |
  613|      0|        const int alignment_idx = gguf_find_key(ctx, GGUF_KEY_GENERAL_ALIGNMENT);
  ------------------
  |  |   44|      0|#define GGUF_KEY_GENERAL_ALIGNMENT "general.alignment"
  ------------------
  614|      0|        ctx->alignment = alignment_idx == -1 ? GGUF_DEFAULT_ALIGNMENT : gguf_get_val_u32(ctx, alignment_idx);
  ------------------
  |  |   46|      0|#define GGUF_DEFAULT_ALIGNMENT 32
  ------------------
  |  Branch (614:26): [True: 0, False: 0]
  ------------------
  615|       |
  616|      0|        if (ctx->alignment == 0 || (ctx->alignment & (ctx->alignment - 1)) != 0) {
  ------------------
  |  Branch (616:13): [True: 0, False: 0]
  |  Branch (616:36): [True: 0, False: 0]
  ------------------
  617|      0|            GGML_LOG_ERROR("%s: alignment %zu is not a power of 2\n", __func__, ctx->alignment);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  618|      0|            gguf_free(ctx);
  619|      0|            return nullptr;
  620|      0|        }
  621|      0|    }
  622|       |
  623|       |    // read the tensor info
  624|      0|    for (int64_t i = 0; ok && i < n_tensors; ++i) {
  ------------------
  |  Branch (624:25): [True: 0, False: 0]
  |  Branch (624:31): [True: 0, False: 0]
  ------------------
  625|      0|        struct gguf_tensor_info info;
  626|       |
  627|       |        // tensor name
  628|      0|        {
  629|      0|            std::string name;
  630|      0|            try {
  631|      0|                ok = ok && gr.read(name);
  ------------------
  |  Branch (631:22): [True: 0, False: 0]
  |  Branch (631:28): [True: 0, False: 0]
  ------------------
  632|      0|            } catch (std::length_error &) {
  633|      0|                GGML_LOG_ERROR("%s: encountered length_error while reading tensor name %" PRIi64 "\n", __func__, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  634|      0|                ok = false;
  635|      0|            } catch (std::bad_alloc &) {
  636|      0|                GGML_LOG_ERROR("%s: encountered bad_alloc error while reading tensor name %" PRIi64 "\n", __func__, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  637|      0|                ok = false;
  638|      0|            }
  639|      0|            if (name.length() >= GGML_MAX_NAME) {
  ------------------
  |  |  229|      0|#   define GGML_MAX_NAME        64
  ------------------
  |  Branch (639:17): [True: 0, False: 0]
  ------------------
  640|      0|                GGML_LOG_ERROR("%s: tensor name %" PRIi64 " is too long: %zu >= %d\n", __func__, i, name.length(), GGML_MAX_NAME);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  641|      0|                ok = false;
  642|      0|                break;
  643|      0|            }
  644|      0|            ggml_set_name(&info.t, name.c_str());
  645|       |
  646|       |            // make sure there are no duplicate tensor names
  647|      0|            for (int64_t j = 0; ok && j < i; ++j) {
  ------------------
  |  Branch (647:33): [True: 0, False: 0]
  |  Branch (647:39): [True: 0, False: 0]
  ------------------
  648|      0|                if (strcmp(info.t.name, ctx->info[j].t.name) == 0) {
  ------------------
  |  Branch (648:21): [True: 0, False: 0]
  ------------------
  649|      0|                    GGML_LOG_ERROR("%s: duplicate tensor name '%s' for tensors %" PRIi64 " and %" PRIi64 "\n", __func__, info.t.name, j, i);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  650|      0|                    ok = false;
  651|      0|                    break;
  652|      0|                }
  653|      0|            }
  654|      0|        }
  655|      0|        if (!ok) {
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            break;
  657|      0|        }
  658|       |
  659|       |        // tensor shape
  660|      0|        {
  661|      0|            uint32_t n_dims = 0;
  662|      0|            ok = ok && gr.read(n_dims);
  ------------------
  |  Branch (662:18): [True: 0, False: 0]
  |  Branch (662:24): [True: 0, False: 0]
  ------------------
  663|      0|            if (n_dims > GGML_MAX_DIMS) {
  ------------------
  |  |  222|      0|#define GGML_MAX_DIMS           4
  ------------------
  |  Branch (663:17): [True: 0, False: 0]
  ------------------
  664|      0|                GGML_LOG_ERROR("%s: tensor '%s' has invalid number of dimensions: %" PRIu32 " > %" PRIu32 "\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  665|      0|                    __func__, info.t.name, n_dims, GGML_MAX_DIMS);
  666|      0|                ok = false;
  667|      0|                break;
  668|      0|            }
  669|      0|            for (uint32_t j = 0; ok && j < GGML_MAX_DIMS; ++j) {
  ------------------
  |  |  222|      0|#define GGML_MAX_DIMS           4
  ------------------
  |  Branch (669:34): [True: 0, False: 0]
  |  Branch (669:40): [True: 0, False: 0]
  ------------------
  670|      0|                info.t.ne[j] = 1;
  671|      0|                if (j < n_dims) {
  ------------------
  |  Branch (671:21): [True: 0, False: 0]
  ------------------
  672|      0|                    ok = ok && gr.read(info.t.ne[j]);
  ------------------
  |  Branch (672:26): [True: 0, False: 0]
  |  Branch (672:32): [True: 0, False: 0]
  ------------------
  673|      0|                }
  674|       |
  675|       |                // check that all ne are non-negative
  676|      0|                if (info.t.ne[j] < 0) {
  ------------------
  |  Branch (676:21): [True: 0, False: 0]
  ------------------
  677|      0|                    GGML_LOG_ERROR("%s: tensor '%s' dimension %" PRIu32 " has invalid number of elements: %" PRIi64 " < 0\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  678|      0|                        __func__, info.t.name, j, info.t.ne[j]);
  679|      0|                    ok = false;
  680|      0|                    break;
  681|      0|                }
  682|      0|            }
  683|       |
  684|       |            // check that the total number of elements is representable
  685|      0|            if (ok && ((INT64_MAX/info.t.ne[1] <= info.t.ne[0]) ||
  ------------------
  |  Branch (685:17): [True: 0, False: 0]
  |  Branch (685:24): [True: 0, False: 0]
  ------------------
  686|      0|                       (INT64_MAX/info.t.ne[2] <= info.t.ne[0]*info.t.ne[1]) ||
  ------------------
  |  Branch (686:24): [True: 0, False: 0]
  ------------------
  687|      0|                       (INT64_MAX/info.t.ne[3] <= info.t.ne[0]*info.t.ne[1]*info.t.ne[2]))) {
  ------------------
  |  Branch (687:24): [True: 0, False: 0]
  ------------------
  688|       |
  689|      0|                GGML_LOG_ERROR("%s: total number of elements in tensor '%s' with shape "
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  690|      0|                    "(%" PRIi64 ", %" PRIi64 ", %" PRIi64 ", %" PRIi64 ") is >= %" PRIi64 "\n",
  691|      0|                    __func__, info.t.name, info.t.ne[0], info.t.ne[1], info.t.ne[2], info.t.ne[3], INT64_MAX);
  692|      0|                ok = false;
  693|      0|                break;
  694|      0|            }
  695|      0|        }
  696|      0|        if (!ok) {
  ------------------
  |  Branch (696:13): [True: 0, False: 0]
  ------------------
  697|      0|            break;
  698|      0|        }
  699|       |
  700|       |        // tensor type
  701|      0|        {
  702|      0|            ok = ok && gr.read(info.t.type);
  ------------------
  |  Branch (702:18): [True: 0, False: 0]
  |  Branch (702:24): [True: 0, False: 0]
  ------------------
  703|       |
  704|       |            // check that tensor type is within defined range
  705|      0|            if (info.t.type < 0 || info.t.type >= GGML_TYPE_COUNT) {
  ------------------
  |  Branch (705:17): [True: 0, False: 0]
  |  Branch (705:36): [True: 0, False: 0]
  ------------------
  706|      0|                GGML_LOG_ERROR("%s: tensor '%s' has invalid ggml type %d. should be in [0, %d)\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  707|      0|                    __func__, info.t.name, info.t.type, GGML_TYPE_COUNT);
  708|      0|                ok = false;
  709|      0|                break;
  710|      0|            }
  711|      0|            const size_t  type_size = ggml_type_size(info.t.type);
  712|      0|            const int64_t blck_size = ggml_blck_size(info.t.type);
  713|       |
  714|       |            // check that row size is divisible by block size
  715|      0|            if (blck_size == 0 || info.t.ne[0] % blck_size != 0) {
  ------------------
  |  Branch (715:17): [True: 0, False: 0]
  |  Branch (715:35): [True: 0, False: 0]
  ------------------
  716|      0|                GGML_LOG_ERROR("%s: tensor '%s' of type %d (%s) has %" PRId64 " elements per row, "
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  717|      0|                    "not a multiple of block size (%" PRId64 ")\n",
  718|      0|                    __func__, info.t.name, (int) info.t.type, ggml_type_name(info.t.type), info.t.ne[0], blck_size);
  719|      0|                ok = false;
  720|      0|                break;
  721|      0|            }
  722|       |
  723|       |            // check that the size of the tensor in bytes is representable
  724|      0|            if (ok && uint64_t(ggml_nelements(&info.t)/ggml_blck_size(info.t.type)) > SIZE_MAX/ggml_type_size(info.t.type)) {
  ------------------
  |  Branch (724:17): [True: 0, False: 0]
  |  Branch (724:23): [True: 0, False: 0]
  ------------------
  725|      0|                GGML_LOG_ERROR("%s: tensor '%s' with shape (%" PRIi64 ", %" PRIi64 ", %" PRIi64 ", %" PRIi64 ") has a size in bytes > %zu\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  726|      0|                    __func__, info.t.name, info.t.ne[0], info.t.ne[1], info.t.ne[2], info.t.ne[3], SIZE_MAX);
  727|      0|                ok = false;
  728|      0|                break;
  729|      0|            }
  730|       |
  731|       |            // calculate byte offsets given the tensor shape and type
  732|      0|            info.t.nb[0] = type_size;
  733|      0|            info.t.nb[1] = info.t.nb[0]*(info.t.ne[0]/blck_size);
  734|      0|            for (int j = 2; j < GGML_MAX_DIMS; ++j) {
  ------------------
  |  |  222|      0|#define GGML_MAX_DIMS           4
  ------------------
  |  Branch (734:29): [True: 0, False: 0]
  ------------------
  735|      0|                info.t.nb[j] = info.t.nb[j - 1]*info.t.ne[j - 1];
  736|      0|            }
  737|      0|        }
  738|      0|        if (!ok) {
  ------------------
  |  Branch (738:13): [True: 0, False: 0]
  ------------------
  739|      0|            break;
  740|      0|        }
  741|       |
  742|       |        // tensor data offset within buffer
  743|      0|        ok = ok && gr.read(info.offset);
  ------------------
  |  Branch (743:14): [True: 0, False: 0]
  |  Branch (743:20): [True: 0, False: 0]
  ------------------
  744|       |
  745|      0|        ctx->info.push_back(info);
  746|      0|    }
  747|       |
  748|      0|    if (!ok) {
  ------------------
  |  Branch (748:9): [True: 0, False: 0]
  ------------------
  749|      0|        GGML_LOG_ERROR("%s: failed to read tensor info\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  750|      0|        gguf_free(ctx);
  751|      0|        return nullptr;
  752|      0|    }
  753|      0|    GGML_ASSERT(int64_t(ctx->info.size()) == n_tensors);
  ------------------
  |  |  288|      0|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  754|       |
  755|       |    // we require the data section to be aligned, so take into account any padding
  756|      0|    if (n_tensors > 0 && !gr.seek(GGML_PAD(gr.tell(), ctx->alignment))) {
  ------------------
  |  |  267|      0|#define GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
  ------------------
  |  Branch (756:9): [True: 0, False: 0]
  |  Branch (756:26): [True: 0, False: 0]
  ------------------
  757|      0|        GGML_LOG_ERROR("%s: failed to seek to beginning of data section\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  758|      0|        gguf_free(ctx);
  759|      0|        return nullptr;
  760|      0|    }
  761|       |
  762|       |    // store the current file offset - this is where the data section starts
  763|      0|    ctx->offset = gr.tell();
  764|       |
  765|       |    // compute the total size of the data section, taking into account the alignment
  766|      0|    {
  767|      0|        ctx->size = 0;
  768|      0|        for (size_t i = 0; i < ctx->info.size(); ++i) {
  ------------------
  |  Branch (768:28): [True: 0, False: 0]
  ------------------
  769|      0|            const gguf_tensor_info & ti = ctx->info[i];
  770|      0|            if (ti.offset != ctx->size) {
  ------------------
  |  Branch (770:17): [True: 0, False: 0]
  ------------------
  771|      0|                GGML_LOG_ERROR("%s: tensor '%s' has offset %" PRIu64 ", expected %zu\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  772|      0|                    __func__, ti.t.name, ti.offset, ctx->size);
  773|      0|                GGML_LOG_ERROR("%s: failed to read tensor data\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  774|      0|                gguf_free(ctx);
  775|      0|                return nullptr;
  776|      0|            }
  777|      0|            size_t padded_size = GGML_PAD(ggml_nbytes(&ti.t), ctx->alignment);
  ------------------
  |  |  267|      0|#define GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
  ------------------
  778|      0|            if (SIZE_MAX - ctx->size < padded_size) {
  ------------------
  |  Branch (778:17): [True: 0, False: 0]
  ------------------
  779|      0|                GGML_LOG_ERROR("%s: tensor '%s' size overflow, cannot accumulate size %zu + %zu\n",
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  780|      0|                    __func__, ti.t.name, ctx->size, padded_size);
  781|      0|                gguf_free(ctx);
  782|      0|                return nullptr;
  783|      0|            }
  784|      0|            ctx->size += padded_size;
  785|      0|        }
  786|      0|    }
  787|       |
  788|       |    // load the tensor data only if requested
  789|      0|    if (params.ctx != nullptr) {
  ------------------
  |  Branch (789:9): [True: 0, False: 0]
  ------------------
  790|       |        // if the provided gguf_context is no_alloc, then we create "empty" tensors and do not read the binary blob
  791|       |        // otherwise, we load the binary blob into the created ggml_context as well, and point the "data" members of
  792|       |        //   the ggml_tensor structs to the appropriate locations in the binary blob
  793|       |
  794|       |        // compute the exact size needed for the new ggml_context
  795|      0|        size_t mem_size = 0;
  796|      0|        if (params.no_alloc) {
  ------------------
  |  Branch (796:13): [True: 0, False: 0]
  ------------------
  797|      0|            if (n_tensors != 0 && SIZE_MAX / n_tensors < ggml_tensor_overhead()) {
  ------------------
  |  Branch (797:17): [True: 0, False: 0]
  |  Branch (797:35): [True: 0, False: 0]
  ------------------
  798|      0|                GGML_LOG_ERROR("%s: memory size overflow while allocating ggml context\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  799|      0|                gguf_free(ctx);
  800|      0|                return nullptr;
  801|      0|            }
  802|       |
  803|      0|            const size_t overhead = n_tensors * ggml_tensor_overhead();
  804|       |
  805|      0|            mem_size = overhead;
  806|      0|        } else {
  807|      0|            if ((n_tensors + 1) != 0 && SIZE_MAX / (n_tensors + 1) < ggml_tensor_overhead()) {
  ------------------
  |  Branch (807:17): [True: 0, False: 0]
  |  Branch (807:41): [True: 0, False: 0]
  ------------------
  808|      0|                GGML_LOG_ERROR("%s: memory size overflow while allocating ggml context\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  809|      0|                gguf_free(ctx);
  810|      0|                return nullptr;
  811|      0|            }
  812|       |
  813|      0|            const size_t overhead = (n_tensors + 1) * ggml_tensor_overhead();
  814|       |
  815|      0|            if (SIZE_MAX - overhead < ctx->size) {
  ------------------
  |  Branch (815:17): [True: 0, False: 0]
  ------------------
  816|      0|                GGML_LOG_ERROR("%s: memory size overflow while allocating ggml context\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  817|      0|                gguf_free(ctx);
  818|      0|                return nullptr;
  819|      0|            }
  820|       |
  821|      0|            mem_size = overhead + ctx->size;
  822|      0|        }
  823|       |
  824|      0|        struct ggml_init_params pdata = {
  825|      0|            /*mem_size   =*/ mem_size,
  826|      0|            /*mem_buffer =*/ nullptr,
  827|      0|            /*no_alloc   =*/ params.no_alloc,
  828|      0|        };
  829|       |
  830|      0|        *params.ctx = ggml_init(pdata);
  831|      0|        if (*params.ctx == nullptr) {
  ------------------
  |  Branch (831:13): [True: 0, False: 0]
  ------------------
  832|      0|            GGML_LOG_ERROR("%s: failed to initialize ggml context for storing tensors\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  833|      0|            gguf_free(ctx);
  834|      0|            return nullptr;
  835|      0|        }
  836|       |
  837|      0|        struct ggml_context * ctx_data = *params.ctx;
  838|       |
  839|      0|        struct ggml_tensor * data = nullptr;
  840|       |
  841|      0|        if (!params.no_alloc) {
  ------------------
  |  Branch (841:13): [True: 0, False: 0]
  ------------------
  842|      0|            data = ggml_new_tensor_1d(ctx_data, GGML_TYPE_I8, ctx->size);
  843|       |
  844|      0|            ok = ok && data != nullptr;
  ------------------
  |  Branch (844:18): [True: 0, False: 0]
  |  Branch (844:24): [True: 0, False: 0]
  ------------------
  845|       |
  846|      0|            if (ok) {
  ------------------
  |  Branch (846:17): [True: 0, False: 0]
  ------------------
  847|      0|                ggml_set_name(data, "GGUF tensor data binary blob");
  848|      0|            }
  849|       |
  850|       |            // read the binary blob with the tensor data
  851|      0|            ok = ok && gr.read(data->data, ctx->size);
  ------------------
  |  Branch (851:18): [True: 0, False: 0]
  |  Branch (851:24): [True: 0, False: 0]
  ------------------
  852|       |
  853|      0|            if (!ok) {
  ------------------
  |  Branch (853:17): [True: 0, False: 0]
  ------------------
  854|      0|                GGML_LOG_ERROR("%s: failed to read tensor data binary blob\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  855|      0|                ggml_free(ctx_data);
  856|      0|                *params.ctx = nullptr;
  857|      0|                gguf_free(ctx);
  858|      0|                return nullptr;
  859|      0|            }
  860|       |
  861|      0|            ctx->data = data->data;
  862|      0|        }
  863|       |
  864|      0|        ggml_set_no_alloc(ctx_data, true);
  865|       |
  866|       |        // create the tensors
  867|      0|        for (size_t i = 0; i < ctx->info.size(); ++i) {
  ------------------
  |  Branch (867:28): [True: 0, False: 0]
  ------------------
  868|      0|            const struct gguf_tensor_info & info = ctx->info[i];
  869|       |
  870|      0|            struct ggml_tensor * cur = ggml_new_tensor(ctx_data, info.t.type, GGML_MAX_DIMS, info.t.ne);
  ------------------
  |  |  222|      0|#define GGML_MAX_DIMS           4
  ------------------
  871|       |
  872|      0|            ok = ok && cur != nullptr;
  ------------------
  |  Branch (872:18): [True: 0, False: 0]
  |  Branch (872:24): [True: 0, False: 0]
  ------------------
  873|       |
  874|      0|            if (!ok) {
  ------------------
  |  Branch (874:17): [True: 0, False: 0]
  ------------------
  875|      0|                break;
  876|      0|            }
  877|       |
  878|      0|            ggml_set_name(cur, info.t.name);
  879|       |
  880|       |            // point the data member to the appropriate location in the binary blob using the tensor info
  881|      0|            if (!params.no_alloc) {
  ------------------
  |  Branch (881:17): [True: 0, False: 0]
  ------------------
  882|      0|                cur->data = (char *) data->data + info.offset;
  883|      0|            }
  884|      0|        }
  885|       |
  886|      0|        if (!ok) {
  ------------------
  |  Branch (886:13): [True: 0, False: 0]
  ------------------
  887|      0|            GGML_LOG_ERROR("%s: failed to create tensors\n", __func__);
  ------------------
  |  |  121|      0|#define GGML_LOG_ERROR(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  888|      0|            ggml_free(ctx_data);
  889|      0|            *params.ctx = nullptr;
  890|      0|            gguf_free(ctx);
  891|      0|            return nullptr;
  892|      0|        }
  893|       |
  894|      0|        ggml_set_no_alloc(ctx_data, params.no_alloc);
  895|      0|    }
  896|       |
  897|      0|    return ctx;
  898|      0|}
_ZNK11gguf_reader4readIcEEbRNSt3__16vectorIT_NS1_9allocatorIS3_EEEEm:
  276|      2|    bool read(std::vector<T> & dst, const size_t n) const {
  277|      2|        if (n > GGUF_MAX_ARRAY_ELEMENTS) {
  ------------------
  |  |   19|      2|#define GGUF_MAX_ARRAY_ELEMENTS (1024*1024*1024)
  ------------------
  |  Branch (277:13): [True: 0, False: 2]
  ------------------
  278|      0|            return false;
  279|      0|        }
  280|       |        if constexpr (std::is_same<T, std::string>::value) {
  281|       |            // strings are prefixed with their length, so we need to account for that
  282|       |            if (n > SIZE_MAX / sizeof(uint64_t)) {
  283|       |                return false;
  284|       |            }
  285|       |            if (nbytes_remain < n * sizeof(uint64_t)) {
  286|       |                return false;
  287|       |            }
  288|      2|        } else {
  289|      2|            if (n > SIZE_MAX / sizeof(T)) {
  ------------------
  |  Branch (289:17): [True: 0, False: 2]
  ------------------
  290|      0|                return false;
  291|      0|            }
  292|      2|            if (nbytes_remain < n * sizeof(T)) {
  ------------------
  |  Branch (292:17): [True: 0, False: 2]
  ------------------
  293|      0|                return false;
  294|      0|            }
  295|      2|        }
  296|      2|        dst.resize(n);
  297|     10|        for (size_t i = 0; i < dst.size(); ++i) {
  ------------------
  |  Branch (297:28): [True: 8, False: 2]
  ------------------
  298|       |            if constexpr (std::is_same<T, bool>::value) {
  299|       |                bool tmp;
  300|       |                if (!read(tmp)) {
  301|       |                    return false;
  302|       |                }
  303|       |                dst[i] = tmp;
  304|      8|            } else {
  305|      8|                if (!read(dst[i])) {
  ------------------
  |  Branch (305:21): [True: 0, False: 8]
  ------------------
  306|      0|                    return false;
  307|      0|                }
  308|      8|            }
  309|      8|        }
  310|      2|        return true;
  311|      2|    }
_ZNK11gguf_reader4readIcEEbRT_:
  267|      8|    bool read(T & dst) const {
  268|      8|        const size_t size = sizeof(dst);
  269|      8|        if (size > nbytes_remain) {
  ------------------
  |  Branch (269:13): [True: 0, False: 8]
  ------------------
  270|      0|            return false;
  271|      0|        }
  272|      8|        return read_raw(&dst, size) == size;
  273|      8|    }
_ZNK11gguf_reader8read_rawEPvm:
  381|     10|    size_t read_raw(void * dst, size_t size) const {
  382|     10|        if (callback == nullptr || size == 0) {
  ------------------
  |  Branch (382:13): [True: 0, False: 10]
  |  Branch (382:36): [True: 0, False: 10]
  ------------------
  383|      0|            return 0;
  384|      0|        }
  385|       |
  386|     10|        uint8_t * data = static_cast<uint8_t *>(dst);
  387|     10|        size_t total_nread = 0;
  388|     10|        bool reached_eof = false;
  389|       |
  390|     20|        while (total_nread < size) {
  ------------------
  |  Branch (390:16): [True: 10, False: 10]
  ------------------
  391|     10|            const size_t chunk_size = std::min(max_chunk_read, size - total_nread);
  392|     10|            if (data_offset + total_nread < data_offset) {
  ------------------
  |  Branch (392:17): [True: 0, False: 10]
  ------------------
  393|      0|                break;
  394|      0|            }
  395|     10|            const size_t nread = callback(userdata, static_cast<void *>(data + total_nread), data_offset + total_nread, chunk_size);
  396|     10|            total_nread += nread;
  397|     10|            if (nread != chunk_size) {
  ------------------
  |  Branch (397:17): [True: 0, False: 10]
  ------------------
  398|      0|                reached_eof = true;
  399|      0|                break;
  400|      0|            }
  401|     10|        }
  402|       |
  403|     10|        data_offset += total_nread;
  404|     10|        GGML_ASSERT(total_nread <= nbytes_remain);
  ------------------
  |  |  288|     10|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 10]
  |  |  ------------------
  ------------------
  405|     10|        nbytes_remain -= total_nread;
  406|       |
  407|     10|        if (reached_eof) {
  ------------------
  |  Branch (407:13): [True: 0, False: 10]
  ------------------
  408|      0|            nbytes_remain = 0;
  409|      0|        }
  410|       |
  411|     10|        return total_nread;
  412|     10|    }
_ZNK11gguf_reader4readIjEEbRT_:
  267|      2|    bool read(T & dst) const {
  268|      2|        const size_t size = sizeof(dst);
  269|      2|        if (size > nbytes_remain) {
  ------------------
  |  Branch (269:13): [True: 0, False: 2]
  ------------------
  270|      0|            return false;
  271|      0|        }
  272|      2|        return read_raw(&dst, size) == size;
  273|      2|    }
gguf.cpp:_ZL25gguf_file_reader_callbackPvS_mm:
  914|     10|static size_t gguf_file_reader_callback(void * userdata, void * output, uint64_t offset, size_t len) {
  915|     10|    GGML_ASSERT(len > 0);
  ------------------
  |  |  288|     10|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 10]
  |  |  ------------------
  ------------------
  916|       |
  917|     10|    gguf_file_reader & reader = *static_cast<gguf_file_reader *>(userdata);
  918|       |
  919|     10|    if (reader.offset != offset) {
  ------------------
  |  Branch (919:9): [True: 0, False: 10]
  ------------------
  920|      0|        if (offset > INT64_MAX || gguf_fseek(reader.file, static_cast<int64_t>(offset), SEEK_SET) != 0) {
  ------------------
  |  |   26|      0|#    define gguf_fseek fseeko
  ------------------
  |  Branch (920:13): [True: 0, False: 0]
  |  Branch (920:35): [True: 0, False: 0]
  ------------------
  921|      0|            return 0;
  922|      0|        }
  923|       |
  924|      0|        reader.offset = offset;
  925|      0|    }
  926|       |
  927|     10|    const size_t nread = fread(static_cast<uint8_t *>(output), 1, len, reader.file);
  928|     10|    reader.offset += nread;
  929|     10|    return nread;
  930|     10|}
_ZN11gguf_reader11file_remainEP8_IO_FILE:
  246|      2|    static uint64_t file_remain(FILE * file) {
  247|      2|        const int64_t cur = gguf_ftell(file);
  ------------------
  |  |   25|      2|#    define gguf_ftell ftello
  ------------------
  248|      2|        if (cur < 0) {
  ------------------
  |  Branch (248:13): [True: 0, False: 2]
  ------------------
  249|      0|            return 0;
  250|      0|        }
  251|      2|        if (gguf_fseek(file, 0, SEEK_END) != 0) {
  ------------------
  |  |   26|      2|#    define gguf_fseek fseeko
  ------------------
  |  Branch (251:13): [True: 0, False: 2]
  ------------------
  252|      0|            gguf_fseek(file, cur, SEEK_SET);
  ------------------
  |  |   26|      0|#    define gguf_fseek fseeko
  ------------------
  253|       |
  254|      0|            return 0;
  255|      0|        }
  256|      2|        const int64_t end = gguf_ftell(file);
  ------------------
  |  |   25|      2|#    define gguf_ftell ftello
  ------------------
  257|      2|        if (end < 0) {
  ------------------
  |  Branch (257:13): [True: 0, False: 2]
  ------------------
  258|      0|            gguf_fseek(file, cur, SEEK_SET);
  ------------------
  |  |   26|      0|#    define gguf_fseek fseeko
  ------------------
  259|       |
  260|      0|            return 0;
  261|      0|        }
  262|      2|        gguf_fseek(file, cur, SEEK_SET);
  ------------------
  |  |   26|      2|#    define gguf_fseek fseeko
  ------------------
  263|      2|        return static_cast<uint64_t>(end - cur);
  264|      2|    }

_ZN6LLM_KVC2E8llm_archPKc:
  860|      2|LLM_KV::LLM_KV(llm_arch arch, const char * suffix) : arch(arch), suffix(suffix) {}

_Z18llama_log_internal14ggml_log_levelPKcz:
   55|      4|void llama_log_internal(ggml_log_level level, const char * format, ...) {
   56|      4|    va_list args;
   57|      4|    va_start(args, format);
   58|      4|    llama_log_internal_v(level, format, args);
   59|       |    va_end(args);
   60|      4|}
_Z26llama_log_callback_default14ggml_log_levelPKcPv:
   62|      4|void llama_log_callback_default(ggml_log_level level, const char * text, void * user_data) {
   63|      4|    (void) level;
   64|      4|    (void) user_data;
   65|      4|    fputs(text, stderr);
   66|       |    fflush(stderr);
   67|      4|}
_Z6formatPKcz:
   86|      2|std::string format(const char * fmt, ...) {
   87|      2|    va_list ap;
   88|      2|    va_list ap2;
   89|      2|    va_start(ap, fmt);
   90|      2|    va_copy(ap2, ap);
   91|      2|    int size = vsnprintf(NULL, 0, fmt, ap);
   92|      2|    GGML_ASSERT(size >= 0 && size < INT_MAX); // NOLINT
  ------------------
  |  |  288|      4|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  |  Branch (288:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
   93|      2|    std::vector<char> buf(size + 1);
   94|      2|    int size2 = vsnprintf(buf.data(), size + 1, fmt, ap2);
   95|      2|    GGML_ASSERT(size2 == size);
  ------------------
  |  |  288|      2|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 2]
  |  |  ------------------
  ------------------
   96|      2|    va_end(ap2);
   97|       |    va_end(ap);
   98|      2|    return std::string(buf.data(), size);
   99|      2|}
llama-impl.cpp:_ZL20llama_log_internal_v14ggml_log_levelPKcP13__va_list_tag:
   38|      4|static void llama_log_internal_v(ggml_log_level level, const char * format, va_list args) {
   39|      4|    va_list args_copy;
   40|      4|    va_copy(args_copy, args);
   41|      4|    char buffer[128];
   42|      4|    int len = vsnprintf(buffer, 128, format, args);
   43|      4|    if (len < 128) {
  ------------------
  |  Branch (43:9): [True: 4, False: 0]
  ------------------
   44|      4|        g_logger_state.log_callback(level, buffer, g_logger_state.log_callback_user_data);
   45|      4|    } else {
   46|      0|        char * buffer2 = new char[len + 1];
   47|      0|        vsnprintf(buffer2, len + 1, format, args_copy);
   48|      0|        buffer2[len] = 0;
   49|      0|        g_logger_state.log_callback(level, buffer2, g_logger_state.log_callback_user_data);
   50|      0|        delete[] buffer2;
   51|      0|    }
   52|       |    va_end(args_copy);
   53|      4|}

_ZN18llama_model_loaderC2EP12gguf_contextPFvP11ggml_tensorPvES4_RKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERNS7_6vectorISD_NSB_ISD_EEEEP8_IO_FILEbbbbPK23llama_model_kv_overridePK32llama_model_tensor_buft_override:
  531|      2|        : metadata(meta), set_tensor_data(set_tensor_data), set_tensor_data_ud(set_tensor_data_ud) {
  532|      2|    int trace = 0;
  533|      2|    if (getenv("LLAMA_TRACE")) {
  ------------------
  |  Branch (533:9): [True: 0, False: 2]
  ------------------
  534|      0|        trace = atoi(getenv("LLAMA_TRACE"));
  535|      0|    }
  536|       |
  537|      2|    if (param_overrides_p != nullptr) {
  ------------------
  |  Branch (537:9): [True: 2, False: 0]
  ------------------
  538|    152|        for (const struct llama_model_kv_override * p = param_overrides_p; p->key[0] != 0; p++) {
  ------------------
  |  Branch (538:76): [True: 150, False: 2]
  ------------------
  539|    150|            kv_overrides.insert({std::string(p->key), *p});
  540|    150|        }
  541|      2|    }
  542|       |
  543|      2|    tensor_buft_overrides = param_tensor_buft_overrides_p;
  544|       |
  545|      2|    if (!fname.empty()) {
  ------------------
  |  Branch (545:9): [True: 2, False: 0]
  ------------------
  546|       |        // Load the main GGUF
  547|      2|        struct ggml_context * ctx = NULL;
  548|      2|        struct gguf_init_params params = {
  549|      2|            /*.no_alloc = */ true,
  550|      2|            /*.ctx      = */ &ctx,
  551|      2|        };
  552|       |
  553|      2|        metadata_ptr.reset(gguf_init_from_file(fname.c_str(), params));
  554|      2|        metadata = metadata_ptr.get();
  555|      2|        if (metadata == nullptr) {
  ------------------
  |  Branch (555:13): [True: 2, False: 0]
  ------------------
  556|      2|            throw std::runtime_error(format("%s: failed to load model from %s", __func__, fname.c_str()));
  557|      2|        }
  558|       |
  559|      0|        get_key(llm_kv(LLM_KV_GENERAL_ARCHITECTURE), arch_name, false);
  560|      0|        llm_kv = LLM_KV(llm_arch_from_string(arch_name));
  561|       |
  562|      0|        files.emplace_back(new llama_file(fname.c_str(), "rb", use_direct_io));
  563|      0|        contexts.emplace_back(ctx);
  564|       |
  565|      0|        if (use_mmap && use_direct_io) {
  ------------------
  |  Branch (565:13): [True: 0, False: 0]
  |  Branch (565:25): [True: 0, False: 0]
  ------------------
  566|      0|            if (files.back()->has_direct_io()) {
  ------------------
  |  Branch (566:17): [True: 0, False: 0]
  ------------------
  567|      0|                LLAMA_LOG_WARN("%s: direct I/O is enabled, disabling mmap\n", __func__);
  ------------------
  |  |   29|      0|#define LLAMA_LOG_WARN(...)  llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  568|      0|                use_mmap = false;
  569|      0|            } else {
  570|      0|                LLAMA_LOG_WARN("%s: direct I/O is not available, using mmap\n", __func__);
  ------------------
  |  |   29|      0|#define LLAMA_LOG_WARN(...)  llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  571|      0|                use_direct_io = false;
  572|       |
  573|       |                // reopen file using std::fopen for mmap
  574|      0|                files.pop_back();
  575|      0|                files.emplace_back(new llama_file(fname.c_str(), "rb", false));
  576|      0|            }
  577|      0|        }
  578|       |
  579|       |        // Save tensors data offset of the main file.
  580|       |        // For subsidiary files, `meta` tensor data offset must not be used,
  581|       |        // so we build a unified tensors index for weights.
  582|      0|        for (ggml_tensor * cur = ggml_get_first_tensor(ctx); cur; cur = ggml_get_next_tensor(ctx, cur)) {
  ------------------
  |  Branch (582:62): [True: 0, False: 0]
  ------------------
  583|      0|            std::string tensor_name = std::string(cur->name);
  584|       |            // make sure there is no duplicated tensor names
  585|      0|            if (weights_map.find(tensor_name) != weights_map.end()) {
  ------------------
  |  Branch (585:17): [True: 0, False: 0]
  ------------------
  586|      0|                throw std::runtime_error(format("invalid model: tensor '%s' is duplicated", ggml_get_name(cur)));
  587|      0|            }
  588|      0|            n_elements += ggml_nelements(cur);
  589|      0|            n_bytes    += ggml_nbytes(cur);
  590|      0|            weights_map.emplace(tensor_name, llama_tensor_weight(files.back().get(), 0, metadata, cur));
  591|      0|        }
  592|      0|        uint16_t n_split = 0;
  593|      0|        get_key(llm_kv(LLM_KV_SPLIT_COUNT), n_split, false);
  594|       |
  595|       |        // Load additional GGML contexts
  596|      0|        if (n_split > 1) {
  ------------------
  |  Branch (596:13): [True: 0, False: 0]
  ------------------
  597|       |            // make sure the main file is loaded first
  598|      0|            uint16_t idx = 0;
  599|      0|            const std::string kv_split_no = llm_kv(LLM_KV_SPLIT_NO);
  600|      0|            get_key(kv_split_no, idx);
  601|      0|            if (idx != 0) {
  ------------------
  |  Branch (601:17): [True: 0, False: 0]
  ------------------
  602|      0|                throw std::runtime_error(format("illegal split file idx: %d (file: %s), model must be loaded with the first split", idx, fname.c_str()));
  603|      0|            }
  604|       |
  605|       |            // generate list of splits if needed
  606|      0|            if (splits.empty()) {
  ------------------
  |  Branch (606:17): [True: 0, False: 0]
  ------------------
  607|      0|                splits = llama_get_list_splits(fname, idx, n_split);
  608|      0|            }
  609|       |
  610|       |            // in case user give a custom list of splits, check if it matches the expected number
  611|      0|            if (n_split != (uint16_t)splits.size()) {
  ------------------
  |  Branch (611:17): [True: 0, False: 0]
  ------------------
  612|      0|                throw std::runtime_error(format("invalid split count, given: %zu splits, but expected %d", splits.size(), n_split));
  613|      0|            }
  614|       |
  615|      0|            if (trace > 0) {
  ------------------
  |  Branch (615:17): [True: 0, False: 0]
  ------------------
  616|      0|                LLAMA_LOG_INFO("%s: loading additional %d GGUFs\n", __func__, n_split);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  617|      0|            }
  618|       |
  619|       |            // load other splits
  620|      0|            for (idx = 1; idx < n_split; idx++) {
  ------------------
  |  Branch (620:27): [True: 0, False: 0]
  ------------------
  621|      0|                const char * fname_split = splits[idx].c_str();
  622|       |
  623|      0|                struct gguf_init_params split_params = {
  624|      0|                    /*.no_alloc = */ true,
  625|      0|                    /*.ctx      = */ &ctx,
  626|      0|                };
  627|      0|                gguf_context_ptr ctx_gguf { gguf_init_from_file(fname_split, split_params) };
  628|      0|                if (!ctx_gguf) {
  ------------------
  |  Branch (628:21): [True: 0, False: 0]
  ------------------
  629|      0|                    throw std::runtime_error(format("%s: failed to load GGUF split from %s", __func__, fname_split));
  630|      0|                }
  631|       |
  632|       |                // check idx
  633|      0|                {
  634|      0|                    const int kid = gguf_find_key(ctx_gguf.get(), kv_split_no.c_str());
  635|      0|                    if (kid < 0) {
  ------------------
  |  Branch (635:25): [True: 0, False: 0]
  ------------------
  636|      0|                        throw std::runtime_error(format("missing key %s in GGUF split %s", kv_split_no.c_str(), fname_split));
  637|      0|                    }
  638|      0|                    int idx_gguf = gguf_get_val_u16(ctx_gguf.get(), kid);
  639|      0|                    if (idx_gguf != idx) {
  ------------------
  |  Branch (639:25): [True: 0, False: 0]
  ------------------
  640|      0|                        throw std::runtime_error(format("invalid split file idx: %d (file: %s), expected %d", idx_gguf, fname_split, idx));
  641|      0|                    }
  642|      0|                }
  643|       |
  644|      0|                files.emplace_back(new llama_file(fname_split, "rb", use_direct_io));
  645|      0|                contexts.emplace_back(ctx);
  646|       |
  647|       |                // Save tensors data offset info of the shard.
  648|      0|                for (ggml_tensor * cur = ggml_get_first_tensor(ctx); cur; cur = ggml_get_next_tensor(ctx, cur)) {
  ------------------
  |  Branch (648:70): [True: 0, False: 0]
  ------------------
  649|      0|                    std::string tensor_name = std::string(cur->name);
  650|       |                    // make sure there is no duplicated tensor names
  651|      0|                    if (weights_map.find(tensor_name) != weights_map.end()) {
  ------------------
  |  Branch (651:25): [True: 0, False: 0]
  ------------------
  652|      0|                        throw std::runtime_error(format("invalid model: tensor '%s' is duplicated", ggml_get_name(cur)));
  653|      0|                    }
  654|      0|                    n_elements += ggml_nelements(cur);
  655|      0|                    n_bytes    += ggml_nbytes(cur);
  656|      0|                    weights_map.emplace(tensor_name, llama_tensor_weight(files.back().get(), idx, ctx_gguf.get(), cur));
  657|      0|                }
  658|      0|            }
  659|       |
  660|      0|            get_key(llm_kv(LLM_KV_SPLIT_TENSORS_COUNT), n_tensors);
  661|       |
  662|       |            // sanity check
  663|      0|            {
  664|      0|                const int n_tensors_loaded = (int) weights_map.size();
  665|      0|                if (n_tensors != n_tensors_loaded) {
  ------------------
  |  Branch (665:21): [True: 0, False: 0]
  ------------------
  666|      0|                    throw std::runtime_error(format("corrupted model: %d tensors expected but %d found", n_tensors, n_tensors_loaded));
  667|      0|                }
  668|      0|            }
  669|       |
  670|      0|            LLAMA_LOG_INFO("%s: additional %d GGUFs metadata loaded.\n",  __func__, n_split - 1);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  671|      0|        }
  672|      0|    } else if (file != nullptr) {
  ------------------
  |  Branch (672:16): [True: 0, False: 0]
  ------------------
  673|      0|        struct ggml_context * ctx = NULL;
  674|      0|        struct gguf_init_params params = {
  675|      0|            /*.no_alloc = */ true,
  676|      0|            /*.ctx      = */ &ctx,
  677|      0|        };
  678|       |
  679|      0|        metadata_ptr.reset(gguf_init_from_file_ptr(file, params));
  680|      0|        metadata = metadata_ptr.get();
  681|      0|        if (metadata == nullptr) {
  ------------------
  |  Branch (681:13): [True: 0, False: 0]
  ------------------
  682|      0|            throw std::runtime_error(format("%s: failed to load model from file pointer", __func__));
  683|      0|        }
  684|       |
  685|      0|        get_key(llm_kv(LLM_KV_GENERAL_ARCHITECTURE), arch_name, false);
  686|      0|        llm_kv = LLM_KV(llm_arch_from_string(arch_name));
  687|       |
  688|      0|        files.emplace_back(new llama_file(file));
  689|      0|        contexts.emplace_back(ctx);
  690|       |
  691|       |        // Save tensors data offset info of the main file.
  692|      0|        for (ggml_tensor * cur = ggml_get_first_tensor(ctx); cur; cur = ggml_get_next_tensor(ctx, cur)) {
  ------------------
  |  Branch (692:62): [True: 0, False: 0]
  ------------------
  693|      0|            std::string tensor_name = std::string(cur->name);
  694|       |            // make sure there is no duplicated tensor names
  695|      0|            if (weights_map.find(tensor_name) != weights_map.end()) {
  ------------------
  |  Branch (695:17): [True: 0, False: 0]
  ------------------
  696|      0|                throw std::runtime_error(format("invalid model: tensor '%s' is duplicated", ggml_get_name(cur)));
  697|      0|            }
  698|      0|            n_elements += ggml_nelements(cur);
  699|      0|            n_bytes    += ggml_nbytes(cur);
  700|      0|            weights_map.emplace(tensor_name, llama_tensor_weight(files.back().get(), 0, metadata, cur));
  701|      0|        }
  702|      0|    } else {
  703|      0|        get_key(llm_kv(LLM_KV_GENERAL_ARCHITECTURE), arch_name, false);
  704|      0|        llm_kv = LLM_KV(llm_arch_from_string(arch_name));
  705|      0|    }
  706|       |
  707|      0|    n_kv      = gguf_get_n_kv(metadata);
  708|      0|    n_tensors = weights_map.size();
  709|       |
  710|      0|    fver = (enum llama_fver) gguf_get_version(metadata);
  711|       |
  712|      0|    LLAMA_LOG_INFO("%s: loaded meta data with %d key-value pairs and %d tensors from %s (version %s)\n",
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (28:71): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  713|      0|            __func__, n_kv, n_tensors, fname.empty() ? "(file*)" : fname.c_str(), llama_file_version_name(fver));
  714|       |
  715|       |    // determine file type based on the number of tensors for each quantization and print meta data
  716|       |    // TODO: make optional
  717|      0|    {
  718|      0|        std::map<enum ggml_type, uint32_t> n_type;
  719|       |
  720|      0|        uint32_t n_type_max = 0;
  721|      0|        enum ggml_type type_max = GGML_TYPE_F32;
  722|       |
  723|      0|        for (const auto & it : weights_map) {
  ------------------
  |  Branch (723:30): [True: 0, False: 0]
  ------------------
  724|      0|            const llama_tensor_weight & w = it.second;
  725|      0|            const ggml_tensor * tensor = w.tensor;
  726|       |
  727|      0|            enum ggml_type type = tensor->type;
  728|       |
  729|      0|            n_type[type]++;
  730|       |
  731|      0|            if (n_type_max < n_type[type]) {
  ------------------
  |  Branch (731:17): [True: 0, False: 0]
  ------------------
  732|      0|                n_type_max = n_type[type];
  733|      0|                type_max   = type;
  734|      0|            }
  735|       |
  736|      0|            if (trace > 0) {
  ------------------
  |  Branch (736:17): [True: 0, False: 0]
  ------------------
  737|      0|                const uint16_t sid = w.idx;
  738|      0|                LLAMA_LOG_INFO("%s: - tensor split %2d: %32s %-8s [ %s ] %8.2f MiB\n", __func__,
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  739|      0|                        sid, ggml_get_name(tensor), ggml_type_name(type), llama_format_tensor_shape(tensor).c_str(),
  740|      0|                        ggml_nbytes(tensor)/1024.0f/1024.0f);
  741|      0|            }
  742|      0|        }
  743|       |
  744|      0|        switch (type_max) {
  745|      0|            case GGML_TYPE_F32:     ftype = LLAMA_FTYPE_ALL_F32;        break;
  ------------------
  |  Branch (745:13): [True: 0, False: 0]
  ------------------
  746|      0|            case GGML_TYPE_F16:     ftype = LLAMA_FTYPE_MOSTLY_F16;     break;
  ------------------
  |  Branch (746:13): [True: 0, False: 0]
  ------------------
  747|      0|            case GGML_TYPE_BF16:    ftype = LLAMA_FTYPE_MOSTLY_BF16;    break;
  ------------------
  |  Branch (747:13): [True: 0, False: 0]
  ------------------
  748|      0|            case GGML_TYPE_Q4_0:    ftype = LLAMA_FTYPE_MOSTLY_Q4_0;    break;
  ------------------
  |  Branch (748:13): [True: 0, False: 0]
  ------------------
  749|      0|            case GGML_TYPE_Q4_1:    ftype = LLAMA_FTYPE_MOSTLY_Q4_1;    break;
  ------------------
  |  Branch (749:13): [True: 0, False: 0]
  ------------------
  750|      0|            case GGML_TYPE_Q5_0:    ftype = LLAMA_FTYPE_MOSTLY_Q5_0;    break;
  ------------------
  |  Branch (750:13): [True: 0, False: 0]
  ------------------
  751|      0|            case GGML_TYPE_Q5_1:    ftype = LLAMA_FTYPE_MOSTLY_Q5_1;    break;
  ------------------
  |  Branch (751:13): [True: 0, False: 0]
  ------------------
  752|      0|            case GGML_TYPE_Q8_0:    ftype = LLAMA_FTYPE_MOSTLY_Q8_0;    break;
  ------------------
  |  Branch (752:13): [True: 0, False: 0]
  ------------------
  753|      0|            case GGML_TYPE_Q2_K:    ftype = LLAMA_FTYPE_MOSTLY_Q2_K;    break;
  ------------------
  |  Branch (753:13): [True: 0, False: 0]
  ------------------
  754|      0|            case GGML_TYPE_Q3_K:    ftype = LLAMA_FTYPE_MOSTLY_Q3_K_M;  break;
  ------------------
  |  Branch (754:13): [True: 0, False: 0]
  ------------------
  755|      0|            case GGML_TYPE_Q4_K:    ftype = LLAMA_FTYPE_MOSTLY_Q4_K_M;  break;
  ------------------
  |  Branch (755:13): [True: 0, False: 0]
  ------------------
  756|      0|            case GGML_TYPE_Q5_K:    ftype = LLAMA_FTYPE_MOSTLY_Q5_K_M;  break;
  ------------------
  |  Branch (756:13): [True: 0, False: 0]
  ------------------
  757|      0|            case GGML_TYPE_Q6_K:    ftype = LLAMA_FTYPE_MOSTLY_Q6_K;    break;
  ------------------
  |  Branch (757:13): [True: 0, False: 0]
  ------------------
  758|      0|            case GGML_TYPE_TQ1_0:   ftype = LLAMA_FTYPE_MOSTLY_TQ1_0;   break;
  ------------------
  |  Branch (758:13): [True: 0, False: 0]
  ------------------
  759|      0|            case GGML_TYPE_TQ2_0:   ftype = LLAMA_FTYPE_MOSTLY_TQ2_0;   break;
  ------------------
  |  Branch (759:13): [True: 0, False: 0]
  ------------------
  760|      0|            case GGML_TYPE_IQ2_XXS: ftype = LLAMA_FTYPE_MOSTLY_IQ2_XXS; break;
  ------------------
  |  Branch (760:13): [True: 0, False: 0]
  ------------------
  761|      0|            case GGML_TYPE_IQ2_XS:  ftype = LLAMA_FTYPE_MOSTLY_IQ2_XS;  break;
  ------------------
  |  Branch (761:13): [True: 0, False: 0]
  ------------------
  762|      0|            case GGML_TYPE_IQ2_S:   ftype = LLAMA_FTYPE_MOSTLY_IQ2_S;   break;
  ------------------
  |  Branch (762:13): [True: 0, False: 0]
  ------------------
  763|      0|            case GGML_TYPE_IQ3_XXS: ftype = LLAMA_FTYPE_MOSTLY_IQ3_XXS; break;
  ------------------
  |  Branch (763:13): [True: 0, False: 0]
  ------------------
  764|      0|            case GGML_TYPE_IQ1_S:   ftype = LLAMA_FTYPE_MOSTLY_IQ1_S;   break;
  ------------------
  |  Branch (764:13): [True: 0, False: 0]
  ------------------
  765|      0|            case GGML_TYPE_IQ1_M:   ftype = LLAMA_FTYPE_MOSTLY_IQ1_M;   break;
  ------------------
  |  Branch (765:13): [True: 0, False: 0]
  ------------------
  766|      0|            case GGML_TYPE_IQ4_NL:  ftype = LLAMA_FTYPE_MOSTLY_IQ4_NL;  break;
  ------------------
  |  Branch (766:13): [True: 0, False: 0]
  ------------------
  767|      0|            case GGML_TYPE_IQ4_XS:  ftype = LLAMA_FTYPE_MOSTLY_IQ4_XS;  break;
  ------------------
  |  Branch (767:13): [True: 0, False: 0]
  ------------------
  768|      0|            case GGML_TYPE_IQ3_S:   ftype = LLAMA_FTYPE_MOSTLY_IQ3_S;   break;
  ------------------
  |  Branch (768:13): [True: 0, False: 0]
  ------------------
  769|      0|            case GGML_TYPE_NVFP4:   ftype = LLAMA_FTYPE_MOSTLY_NVFP4;   break;
  ------------------
  |  Branch (769:13): [True: 0, False: 0]
  ------------------
  770|      0|            case GGML_TYPE_Q1_0:    ftype = LLAMA_FTYPE_MOSTLY_Q1_0;    break;
  ------------------
  |  Branch (770:13): [True: 0, False: 0]
  ------------------
  771|      0|            case GGML_TYPE_Q2_0:    ftype = LLAMA_FTYPE_MOSTLY_Q2_0;    break;
  ------------------
  |  Branch (771:13): [True: 0, False: 0]
  ------------------
  772|      0|            default:
  ------------------
  |  Branch (772:13): [True: 0, False: 0]
  ------------------
  773|      0|                {
  774|      0|                    LLAMA_LOG_WARN("%s: unknown type %s\n", __func__, ggml_type_name(type_max));
  ------------------
  |  |   29|      0|#define LLAMA_LOG_WARN(...)  llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  775|      0|                    ftype = LLAMA_FTYPE_ALL_F32;
  776|      0|                } break;
  777|      0|        }
  778|       |
  779|       |        // this is a way to mark that we have "guessed" the file type
  780|      0|        ftype = (llama_ftype) (ftype | LLAMA_FTYPE_GUESSED);
  781|       |
  782|      0|        {
  783|      0|            uint32_t ftype_val = 0;
  784|      0|            if (get_key(LLM_KV_GENERAL_FILE_TYPE, ftype_val, false)) {
  ------------------
  |  Branch (784:17): [True: 0, False: 0]
  ------------------
  785|      0|                ftype = (llama_ftype) ftype_val;
  786|      0|            }
  787|      0|        }
  788|       |
  789|      0|        LLAMA_LOG_INFO("%s: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n", __func__);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  790|       |
  791|      0|        for (int i = 0; i < n_kv; i++) {
  ------------------
  |  Branch (791:25): [True: 0, False: 0]
  ------------------
  792|      0|            const char * name           = gguf_get_key(metadata, i);
  793|      0|            const enum gguf_type type   = gguf_get_kv_type(metadata, i);
  794|      0|            const std::string type_name =
  795|      0|                type == GGUF_TYPE_ARRAY
  ------------------
  |  Branch (795:17): [True: 0, False: 0]
  ------------------
  796|      0|                ? format("%s[%s,%zu]", gguf_type_name(type), gguf_type_name(gguf_get_arr_type(metadata, i)), gguf_get_arr_n(metadata, i))
  797|      0|                : gguf_type_name(type);
  798|       |
  799|      0|            std::string value          = gguf_kv_to_str(metadata, i);
  800|      0|            const size_t MAX_VALUE_LEN = 40;
  801|      0|            if (value.size() > MAX_VALUE_LEN) {
  ------------------
  |  Branch (801:17): [True: 0, False: 0]
  ------------------
  802|      0|                value = format("%s...", value.substr(0, MAX_VALUE_LEN - 3).c_str());
  803|      0|            }
  804|      0|            replace_all(value, "\n", "\\n");
  805|       |
  806|      0|            LLAMA_LOG_INFO("%s: - kv %3d: %42s %-16s = %s\n", __func__, i, name, type_name.c_str(), value.c_str());
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  807|      0|        }
  808|       |
  809|       |        // print type counts
  810|      0|        for (auto & kv : n_type) {
  ------------------
  |  Branch (810:24): [True: 0, False: 0]
  ------------------
  811|      0|            if (kv.second == 0) {
  ------------------
  |  Branch (811:17): [True: 0, False: 0]
  ------------------
  812|      0|                continue;
  813|      0|            }
  814|       |
  815|      0|            LLAMA_LOG_INFO("%s: - type %4s: %4d tensors\n", __func__, ggml_type_name(kv.first), kv.second);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  816|      0|        }
  817|      0|    }
  818|       |
  819|      0|    if (!llama_mmap::SUPPORTED) {
  ------------------
  |  Branch (819:9): [True: 0, False: 0]
  ------------------
  820|      0|        LLAMA_LOG_WARN("%s: mmap is not supported on this platform\n", __func__);
  ------------------
  |  |   29|      0|#define LLAMA_LOG_WARN(...)  llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
  ------------------
  821|      0|        use_mmap = false;
  822|      0|    }
  823|       |
  824|      0|    this->use_mmap = use_mmap;
  825|      0|    this->use_direct_io = use_direct_io;
  826|      0|    this->check_tensors = check_tensors;
  827|      0|    this->no_alloc = no_alloc;
  828|      0|}

llama_backend_init:
   89|      3|void llama_backend_init(void) {
   90|      3|    ggml_time_init();
   91|       |
   92|       |    // needed to initialize f16 tables
   93|      3|    {
   94|      3|        struct ggml_init_params params = { 0, NULL, false };
   95|      3|        struct ggml_context * ctx = ggml_init(params);
   96|      3|        ggml_free(ctx);
   97|      3|    }
   98|       |
   99|      3|    if (!ggml_backend_reg_count()) {
  ------------------
  |  Branch (99:9): [True: 0, False: 3]
  ------------------
  100|      0|        ggml_backend_load_all();
  101|      0|    }
  102|      3|}
llama_backend_free:
  116|      2|void llama_backend_free(void) {
  117|      2|    ggml_quantize_free();
  118|      2|}
llama_load_model_from_file:
  422|      2|        struct llama_model_params params) {
  423|      2|    return llama_model_load_from_file(path_model, params);
  424|      2|}
llama_model_load_from_file:
  428|      2|        struct llama_model_params params) {
  429|      2|    std::vector<std::string> splits = {};
  430|      2|    return llama_model_load_from_file_impl(nullptr, nullptr, nullptr, path_model, splits, /*file*/ nullptr, params);
  431|      2|}
llama.cpp:_ZL31llama_model_load_from_file_implP12gguf_contextPFvP11ggml_tensorPvES3_RKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEERNS6_6vectorISC_NSA_ISC_EEEEP8_IO_FILE18llama_model_params:
  348|      2|        struct llama_model_params params) {
  349|      2|    {
  350|      2|        int n_sources_defined = 0;
  351|      2|        if (metadata != nullptr) {
  ------------------
  |  Branch (351:13): [True: 0, False: 2]
  ------------------
  352|      0|            n_sources_defined++;
  353|      0|        }
  354|      2|        if (!path_model.empty()) {
  ------------------
  |  Branch (354:13): [True: 2, False: 0]
  ------------------
  355|      2|            n_sources_defined++;
  356|      2|        }
  357|      2|        if (file != nullptr) {
  ------------------
  |  Branch (357:13): [True: 0, False: 2]
  ------------------
  358|      0|            n_sources_defined++;
  359|      0|        }
  360|      2|        if (n_sources_defined != 1) {
  ------------------
  |  Branch (360:13): [True: 0, False: 2]
  ------------------
  361|      0|            LLAMA_LOG_ERROR("%s: exactly one out metadata, path_model, and file must be defined\n", __func__);
  ------------------
  |  |   30|      0|#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  362|      0|            return nullptr;
  363|      0|        }
  364|      2|    }
  365|      2|    ggml_time_init();
  366|       |
  367|      2|    if (!params.vocab_only && ggml_backend_reg_count() == 0) {
  ------------------
  |  Branch (367:9): [True: 2, False: 0]
  |  Branch (367:31): [True: 0, False: 2]
  ------------------
  368|      0|        LLAMA_LOG_ERROR("%s: no backends are loaded. hint: use ggml_backend_load() or ggml_backend_load_all() to load a backend before calling this function\n", __func__);
  ------------------
  |  |   30|      0|#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  369|      0|        return nullptr;
  370|      0|    }
  371|       |
  372|      2|    unsigned cur_percentage = 0;
  373|      2|    if (params.progress_callback == NULL) {
  ------------------
  |  Branch (373:9): [True: 0, False: 2]
  ------------------
  374|      0|        params.progress_callback_user_data = &cur_percentage;
  375|      0|        params.progress_callback = [](float progress, void * ctx) {
  376|      0|            unsigned * cur_percentage_p = (unsigned *) ctx;
  377|      0|            unsigned percentage = (unsigned) (100 * progress);
  378|      0|            while (percentage > *cur_percentage_p) {
  379|      0|                *cur_percentage_p = percentage;
  380|      0|                LLAMA_LOG_CONT(".");
  381|      0|                if (percentage >= 100) {
  382|      0|                    LLAMA_LOG_CONT("\n");
  383|      0|                }
  384|      0|            }
  385|      0|            return true;
  386|      0|        };
  387|      0|    }
  388|       |
  389|      2|    const auto [status, model] = llama_model_load(metadata, set_tensor_data, set_tensor_data_ud, path_model, splits, file, params);
  390|      2|    GGML_ASSERT(status <= 0);
  ------------------
  |  |  288|      2|#define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
  |  |  ------------------
  |  |  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (288:28): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  391|      2|    if (status < 0) {
  ------------------
  |  Branch (391:9): [True: 2, False: 0]
  ------------------
  392|      2|        if (status == -1) {
  ------------------
  |  Branch (392:13): [True: 2, False: 0]
  ------------------
  393|      2|            LLAMA_LOG_ERROR("%s: failed to load model\n", __func__);
  ------------------
  |  |   30|      2|#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  394|      2|        } else if (status == -2) {
  ------------------
  |  Branch (394:20): [True: 0, False: 0]
  ------------------
  395|      0|            LLAMA_LOG_INFO("%s: cancelled model load\n", __func__);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  396|      0|        }
  397|       |
  398|      2|        if (model) {
  ------------------
  |  Branch (398:13): [True: 0, False: 2]
  ------------------
  399|      0|            llama_model_free(model);
  400|      0|        }
  401|      2|        return nullptr;
  402|      2|    }
  403|       |
  404|      0|    return model;
  405|      2|}
llama.cpp:_ZL16llama_model_loadP12gguf_contextPFvP11ggml_tensorPvES3_RKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEERNS6_6vectorISC_NSA_ISC_EEEEP8_IO_FILER18llama_model_params:
  280|      2|        const std::string & fname, std::vector<std::string> & splits, FILE * file, llama_model_params & params) {
  281|      2|    try {
  282|      2|        llama_model_loader ml(metadata, set_tensor_data, set_tensor_data_ud, fname, splits, file, params.use_mmap, params.use_direct_io,
  283|      2|            params.check_tensors, params.no_alloc, params.kv_overrides, params.tensor_buft_overrides);
  284|       |
  285|      2|        ml.print_info();
  286|      2|        std::unique_ptr<llama_model> model_ptr(llama_model_create(ml, params));
  287|       |
  288|      2|        bool ok = llama_prepare_model_devices(params, model_ptr.get());
  289|      2|        if (!ok) {
  ------------------
  |  Branch (289:13): [True: 0, False: 2]
  ------------------
  290|      0|            return {-1, nullptr};
  291|      0|        }
  292|       |
  293|      2|        auto * model = dynamic_cast<llama_model_base *>(model_ptr.get());
  294|      2|        if (model == nullptr) {
  ------------------
  |  Branch (294:13): [True: 0, False: 2]
  ------------------
  295|      0|            GGML_ABORT("fatal error: model does not implement llama_model_base");
  ------------------
  |  |  287|      0|#define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
  ------------------
  296|      0|        }
  297|       |
  298|       |        // loading time will be recalculated after the first eval, so
  299|       |        // we take page faults deferred by mmap() into consideration
  300|      2|        model->t_load_us = 0;
  301|      2|        time_meas tm(model->t_load_us);
  302|       |
  303|      2|        model->t_start_us = tm.t_start_us;
  304|       |
  305|      2|        model->hparams.vocab_only = params.vocab_only;
  306|      2|        model->hparams.no_alloc   = params.no_alloc;
  307|       |
  308|      2|        try {
  309|      2|            model->load_hparams(ml);
  310|      2|        } catch(const std::exception & e) {
  311|      0|            throw std::runtime_error("error loading model hyperparameters: " + std::string(e.what()));
  312|      0|        }
  313|      0|        if (model->arch == LLM_ARCH_CLIP) {
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  ------------------
  314|      0|            throw std::runtime_error("CLIP cannot be used as main model, use it with --mmproj instead");
  315|      0|        }
  316|      0|        try {
  317|      0|            model->load_vocab(ml);
  318|      0|        } catch(const std::exception & e) {
  319|      0|            throw std::runtime_error("error loading model vocabulary: " + std::string(e.what()));
  320|      0|        }
  321|       |
  322|      0|        model->load_stats(ml);
  323|      0|        model->print_info();
  324|       |
  325|      0|        if (params.vocab_only) {
  ------------------
  |  Branch (325:13): [True: 0, False: 0]
  ------------------
  326|      0|            LLAMA_LOG_INFO("%s: vocab only - skipping tensors\n", __func__);
  ------------------
  |  |   28|      0|#define LLAMA_LOG_INFO(...)  llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
  ------------------
  327|      0|            return {0, model_ptr.release()};
  328|      0|        }
  329|       |
  330|      0|        if (!model->load_tensors(ml)) {
  ------------------
  |  Branch (330:13): [True: 0, False: 0]
  ------------------
  331|      0|            return {-2, nullptr};
  332|      0|        }
  333|       |
  334|      0|        return {0, model_ptr.release()};
  335|      2|    } catch (const std::exception & err) {
  336|      2|        LLAMA_LOG_ERROR("%s: error loading model: %s\n", __func__, err.what());
  ------------------
  |  |   30|      2|#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
  ------------------
  337|      2|        return {-1, nullptr};
  338|      2|    }
  339|      2|}

