-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgguf_parser_test.cpp
More file actions
78 lines (63 loc) · 2.57 KB
/
Copy pathgguf_parser_test.cpp
File metadata and controls
78 lines (63 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "gguf_parser.h"
#include "logger.h"
#include <iostream>
using namespace ash;
int main() {
std::cout << "📦 Testing GGUF Parser...\n\n";
Logger::instance().set_min_level(LogLevel::INFO);
// Check if we have a test GGUF file
std::string test_file = "C:/Users/admin/gemma-4-e4b-it.bin";
std::cout << "Looking for test model: " << test_file << "\n";
// Try to parse
GGUFParser parser;
if (!parser.parse(test_file)) {
std::cout << "❌ Failed to parse GGUF file\n";
std::cout << " (This is expected if no model file exists yet)\n";
std::cout << "\nGGUF parser is ready to load models once you have one.\n";
return 0;
}
std::cout << "\n✅ GGUF parsed successfully!\n\n";
// Print metadata
std::cout << "Model Info:\n";
std::cout << " Architecture: " << parser.get_architecture() << "\n";
std::cout << " Context length: " << parser.get_context_length() << "\n";
std::cout << " Embedding dim: " << parser.get_embedding_dim() << "\n";
std::cout << " Num layers: " << parser.get_num_layers() << "\n";
std::cout << " Num heads: " << parser.get_num_heads() << "\n";
std::cout << " Num KV heads: " << parser.get_num_kv_heads() << "\n";
std::cout << " Vocab size: " << parser.get_vocab_size() << "\n\n";
// List tensors
const auto& tensors = parser.get_tensors();
std::cout << "Tensors (" << tensors.size() << " total):\n";
int count = 0;
for (const auto& t : tensors) {
if (count < 10) {
std::cout << " " << t.name;
std::cout << " [";
for (size_t i = 0; i < t.dimensions.size(); ++i) {
if (i > 0) std::cout << ", ";
std::cout << t.dimensions[i];
}
std::cout << "]";
std::cout << " (" << static_cast<int>(t.type) << ")\n";
count++;
}
}
if (tensors.size() > 10) {
std::cout << " ... and " << (tensors.size() - 10) << " more\n";
}
std::cout << "\n";
// Try to load a small tensor
std::cout << "Attempting to load first tensor...\n";
if (!tensors.empty()) {
try {
auto tensor = parser.load_tensor(tensors[0].name);
std::cout << "✅ Loaded: " << tensor.info() << "\n";
} catch (const std::exception& e) {
std::cout << "❌ Failed to load tensor: " << e.what() << "\n";
}
}
std::cout << "\n🔥 GGUF parser working!\n";
std::cout << "Ready to load full models for inference.\n";
return 0;
}