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/CUDApp/blob/main/tests/gpu_dnn_rows_ref.h # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / gpu_dnn_rows_ref.h` 34 lines · 1527 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #ifndef GPU_DNN_ROWS_REF_H 3 #define GPU_DNN_ROWS_REF_H 4 #include 5 #include 6 #include 7 static double dr_input(const void *p, size_t i, unsigned dtype) { 8 if (dtype == 0) return ((const float*)p)[i]; 9 uint16_t h=((const uint16_t*)p)[i]; 10 if (dtype == 1) { uint32_t b=(uint32_t)h<<16; float f; memcpy(&f,&b,4); return f; } 11 _Float16 f; memcpy(&f,&h,2); return (double)f; 12 } 13 static void dr_reference(const OmegaGpuDnnRowsShape *s,const void *p,double *o) { 14 for (unsigned r=0;rrows;++r) { 15 size_t base=(size_t)r*s->length; 16 double mean=0, v=0, mx=-INFINITY; 17 for (unsigned j=0;jlength;++j) { double x=dr_input(p,base+j,s->dtype); mean+=x; if(x>mx) mx=x; } 18 mean/=s->length; 19 for (unsigned j=0;jlength;++j) { 20 double x=dr_input(p,base+j,s->dtype); 21 if(s->op==0) v+=exp(x-mx); 22 else { double d=s->op==1?x-mean:x; v+=d*d; } 23 } 24 if(s->op) v=sqrt(v/s->length+(double)s->epsilon); 25 for(unsigned j=0;jlength;++j) { double x=dr_input(p,base+j,s->dtype); o[base+j]=s->op==0?exp(x-mx)/v:(s->op==1?x-mean:x)/v; } 26 } 27 } 28 static int dr_equal(const float *o,const double *r,size_t n) { 29 /* MODELED 16 gamma_2053 envelope; README records Wolfram derivation. */ 30 const double tol=16.0*(2053.0/`16775163`.0); 31 for(size_t i=0;itol*(1+fabs(r[i]))) return 0; 32 return 1; 33 } 34 #endif