ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / src / ggml-et / ggml-et-cpu-compare.h
| 1 | #pragma once |
| 2 | |
| 3 | #include "ggml-cpu.h" |
| 4 | #include "ggml-et-common.h" |
| 5 | #include "ggml-impl.h" |
| 6 | |
| 7 | // Configuration for CPU comparison |
| 8 | struct ggml_et_cpu_compare_config { |
| 9 | bool enabled; // Whether to enable CPU comparison |
| 10 | bool use_cpu_result; // Whether to replace ET result with CPU result |
| 11 | bool log_differences; // Whether to log detailed element differences |
| 12 | float tolerance; // Relative tolerance for comparison (default: 1e-5f) |
| 13 | size_t max_log_elements; // Maximum number of elements to log (default: 10) |
| 14 | }; |
| 15 | |
| 16 | // Default configuration |
| 17 | static const ggml_et_cpu_compare_config ggml_et_cpu_compare_default_config = { |
| 18 | /* .enabled = */ false, |
| 19 | /* .use_cpu_result = */ false, |
| 20 | /* .log_differences = */ true, |
| 21 | /* .tolerance = */ 1e-5f, |
| 22 | /* .max_log_elements = */ 10 |
| 23 | }; |
| 24 | |
| 25 | // CPU comparison context for a single operation |
| 26 | struct ggml_et_cpu_compare_ctx { |
| 27 | ggml_backend_t cpu_backend; |
| 28 | ggml_context * ggml_ctx; |
| 29 | ggml_tensor * cpu_src0; |
| 30 | ggml_tensor * cpu_src1; |
| 31 | ggml_tensor * cpu_src2; |
| 32 | ggml_tensor * cpu_dst; |
| 33 | ggml_cgraph * cpu_graph; |
| 34 | void * cpu_src0_data; |
| 35 | void * cpu_src1_data; |
| 36 | void * cpu_src2_data; |
| 37 | void * cpu_dst_data; |
| 38 | void * et_dst_data; |
| 39 | size_t src0_size; |
| 40 | size_t src1_size; |
| 41 | size_t src2_size; |
| 42 | size_t dst_size; |
| 43 | }; |
| 44 | |
| 45 | // Phase 1: Initialize CPU comparison context and copy source buffers (call before ET kernel) |
| 46 | bool ggml_et_cpu_compare_init_pre(ggml_et_cpu_compare_ctx * ctx, const ggml_tensor * node, ggml_op op); |
| 47 | |
| 48 | // Phase 2: Execute CPU computation and compare with ET result (call after ET kernel) |
| 49 | bool ggml_et_cpu_compare_compute_and_check(ggml_et_cpu_compare_ctx * ctx, |
| 50 | const ggml_tensor * node, |
| 51 | const ggml_et_cpu_compare_config * config); |
| 52 | |
| 53 | // Free CPU comparison context resources |
| 54 | void ggml_et_cpu_compare_free(ggml_et_cpu_compare_ctx * ctx); |