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/gpu-head-to-head/blob/main/q35-9b/tools/torch-cpu-exp.cpp # gpu-head-to-head aien-dev/gpu-head-to-head 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 `gpu-head-to-head / q35-9b / tools / torch-cpu-exp.cpp` 18 lines ยท 1008 bytes Raw Blame History 1 // Independent verification oracle only. Uses the original converter's pinned 2 // ATen CPU exp, without Python, model code, CUDA computation, or a production dependency. 3 // The pinned library's dependencies include libcudart; no library-absence claim is made. 4 #include 5 #include 6 #include 7 int main(int argc,char **argv) { 8 if(argc!=2||std::strcmp(argv[1],"negexp"))return 2; 9 static_assert(sizeof(float)==4); 10 unsigned char raw[65536];const size_t bytes=std::fread(raw,1,sizeof raw,stdin); 11 if(std::ferror(stdin)||!std::feof(stdin)||!bytes||bytes%4)return 2; 12 float values[16384];std::memcpy(values,raw,bytes);const size_t n=bytes/4; 13 try { 14 auto input=at::from_blob(values,{static_cast(n)},at::TensorOptions().dtype(at::kFloat).device(at::kCPU)); 15 auto result=at::neg(at::exp(input)).contiguous(); 16 return std::fwrite(result.const_data_ptr(),sizeof(float),n,stdout)==n?0:4; 17 }catch(const std::exception &){return 3;} 18 }