okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6a74320ca
main
1// metal/tools/gguf_list.cpp - tensor directory and scalar metadata of a GGUF (name type shape offset), for the 2// Metal window's wiring. clang++ -std=c++20 -I include metal/tools/gguf_list.cpp -o gguf_list 3#include "strata/artifact/gguf_reader.hpp" 4 5#include <cstdio> 6#include <string> 7 8int main (int argc ,char ** argv ) { 9if (argc < 2 ) { std::printf ("usage: gguf_list <file.gguf> [substring]\n" );return 2 ; } 10 strata::GgufFile g (argv [1 ]); 11const std::string f = argc > 2 ?argv [2 ] :"" ; 12for (const auto & [k ,v ] :g .metadata ()) { 13if (!f .empty ()&& k .find (f )== std::string::npos )continue ; 14if (v .is_num ()) std::printf ("META %s = %g\n" ,k .c_str (),v .num ()); 15else if (v .type == strata::MetaType ::STRING ) std::printf ("META %s = %s\n" ,k .c_str (),v .s .substr (0 ,80 ).c_str ()); 16else std::printf ("META %s = [%llu items]\n" ,k .c_str (), (unsigned long long )v .count ); 17 } 18for (const auto & t :g .tensors ()) { 19if (!f .empty ()&& t .name .find (f )== std::string::npos )continue ; 20 std::printf ("%s %s [" ,t .name .c_str (),t .type_name ()); 21for (size_t i = 0 ;i < t .shape .size ();++ i ) std::printf (i ?",%llu" :"%llu" , (unsigned long long )t .shape [i ]); 22 std::printf ("] off %llu\n" , (unsigned long long )t .offset ); 23 } 24return 0 ; 25}