Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-openvino/ggml-quants.h # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-openvino / ggml-quants.h` 58 lines ยท 2340 bytes Raw Blame History 1 #pragma once 2 #include "ggml-openvino-extra.h" // For ExtraQuantType 3 #include "ggml.h" 4 5 #include 6 #include 7 #include 8 9 static constexpr size_t GGML_QUANTIZATION_GROUP_SIZE = 32; 10 11 inline const char * extra_quant_type_name(ExtraQuantType t) { 12 switch (t) { 13 case ExtraQuantType::F16: 14 return "F16"; 15 case ExtraQuantType::Q4_0_C: 16 return "Q4_0_C"; 17 case ExtraQuantType::Q4_0_128: 18 return "Q4_0_128"; 19 case ExtraQuantType::Q8_0_C: 20 return "Q8_0_C"; 21 case ExtraQuantType::Q8_0_32: 22 return "Q8_0_32"; 23 case ExtraQuantType::Q8_1_C: 24 return "Q8_1_C"; 25 case ExtraQuantType::Q4_0_64: 26 return "Q4_0_64"; 27 case ExtraQuantType::Q4_1_64: 28 return "Q4_1_64"; 29 default: 30 return "unknown"; 31 } 32 } 33 34 // Result from process_weight_tensor containing the weight node and tensors. 35 // For quantized weights, also contains the extracted layout and scale/zp tensors. 36 struct OvWeight { 37 std::shared_ptr weight_node; 38 ggml_openvino_extracted_layout layout; // Only meaningful for quantized (layout.total_size > 0) 39 ov::Tensor weights; 40 ov::Tensor scales; 41 ov::Tensor zp; 42 43 bool is_quantized() const { return layout.scales_size > 0; } 44 }; 45 46 // Process weight tensor and create an OpenVINO weight node 47 // Handles F16/F32/BF16 and quantized weights, with optional requantization 48 // If output_base_ptr is nullptr, allocates internal buffers (for decoder use) 49 // If output_base_ptr is provided, uses pre-allocated buffers at specified offsets (for backend buffer use) 50 // Returns OvWeight with the weight node and optional quantized tensors 51 OvWeight process_weight_tensor( 52 const ggml_tensor * tensor, 53 const void * data, // Source data pointer (may differ from tensor->data) 54 void * output_base_ptr = nullptr, // Base pointer for output buffers (or nullptr for internal allocation) 55 bool use_bias = false); // Use an exact f16 zero point (vs. a rounded integer one); 56 // always used for for_gather_matmul (3D MoE expert) weights 57 // regardless of this flag, and also settable explicitly for 58 // test-backend-ops.