char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
082b326fc
char/aliceai-t5-moe
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 8struct ggml_et_cpu_compare_config { 9bool enabled ;// Whether to enable CPU comparison 10bool use_cpu_result ;// Whether to replace ET result with CPU result 11bool log_differences ;// Whether to log detailed element differences 12float tolerance ;// Relative tolerance for comparison (default: 1e-5f) 13size_t max_log_elements ;// Maximum number of elements to log (default: 10) 14}; 15 16// Default configuration 17static 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 26struct ggml_et_cpu_compare_ctx { 27ggml_backend_t cpu_backend ; 28ggml_context * ggml_ctx ; 29ggml_tensor * cpu_src0 ; 30ggml_tensor * cpu_src1 ; 31ggml_tensor * cpu_src2 ; 32ggml_tensor * cpu_dst ; 33ggml_cgraph * cpu_graph ; 34void * cpu_src0_data ; 35void * cpu_src1_data ; 36void * cpu_src2_data ; 37void * cpu_dst_data ; 38void * et_dst_data ; 39size_t src0_size ; 40size_t src1_size ; 41size_t src2_size ; 42size_t dst_size ; 43}; 44 45// Phase 1: Initialize CPU comparison context and copy source buffers (call before ET kernel) 46bool 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) 49bool ggml_et_cpu_compare_compute_and_check (ggml_et_cpu_compare_ctx * ctx , 50const ggml_tensor * node , 51const ggml_et_cpu_compare_config * config ); 52 53// Free CPU comparison context resources 54void ggml_et_cpu_compare_free (ggml_et_cpu_compare_ctx * ctx );