@@ -2190,6 +2190,11 @@ struct llama_model_loader {
2190
2190
LLM_KV llm_kv = LLM_KV(LLM_ARCH_UNKNOWN);
2191
2191
2192
2192
llama_model_loader (const std::string & fname, bool use_mmap, const struct llama_model_kv_override * param_overrides_p) : file(fname.c_str(), " rb" ) {
2193
+ int trace = 0 ;
2194
+ if (getenv (" LLAMA_TRACE" )) {
2195
+ trace = atoi (getenv (" LLAMA_TRACE" ));
2196
+ }
2197
+
2193
2198
struct gguf_init_params params = {
2194
2199
/* .no_alloc = */ true ,
2195
2200
/* .ctx = */ &ctx_meta,
@@ -2242,11 +2247,10 @@ struct llama_model_loader {
2242
2247
type_max = type;
2243
2248
}
2244
2249
2245
- // TODO: make runtime configurable
2246
- #if 0
2247
- struct ggml_tensor * meta = ggml_get_tensor(ctx_meta, gguf_get_tensor_name(ctx_gguf, i));
2248
- LLAMA_LOG_INFO("%s: - tensor %4d: %32s %-8s [ %s ]\n", __func__, i, ggml_get_name(meta), ggml_type_name(type), llama_format_tensor_shape(meta).c_str());
2249
- #endif
2250
+ if (trace > 0 ) {
2251
+ struct ggml_tensor * meta = ggml_get_tensor (ctx_meta, gguf_get_tensor_name (ctx_gguf, i));
2252
+ LLAMA_LOG_INFO (" %s: - tensor %4d: %32s %-8s [ %s ]\n " , __func__, i, ggml_get_name (meta), ggml_type_name (type), llama_format_tensor_shape (meta).c_str ());
2253
+ }
2250
2254
}
2251
2255
2252
2256
switch (type_max) {
@@ -6451,15 +6455,15 @@ static uint8_t llama_token_to_byte(const llama_vocab& vocab, llama_token id) {
6451
6455
static llama_token llama_byte_to_token (const llama_vocab & vocab, uint8_t ch) {
6452
6456
static const char * hex = " 0123456789ABCDEF" ;
6453
6457
switch (llama_vocab_get_type (vocab)) {
6454
- case LLAMA_VOCAB_TYPE_SPM: {
6455
- const char buf[7 ] = { ' <' , ' 0' , ' x' , hex[ch >> 4 ], hex[ch & 15 ], ' >' , 0 };
6456
- return vocab.token_to_id .at (buf);
6457
- }
6458
- case LLAMA_VOCAB_TYPE_BPE: {
6459
- return vocab.token_to_id .at (bytes_to_unicode_bpe (ch));
6460
- }
6461
- default :
6462
- GGML_ASSERT (false );
6458
+ case LLAMA_VOCAB_TYPE_SPM: {
6459
+ const char buf[7 ] = { ' <' , ' 0' , ' x' , hex[ch >> 4 ], hex[ch & 15 ], ' >' , 0 };
6460
+ return vocab.token_to_id .at (buf);
6461
+ }
6462
+ case LLAMA_VOCAB_TYPE_BPE: {
6463
+ return vocab.token_to_id .at (bytes_to_unicode_bpe (ch));
6464
+ }
6465
+ default :
6466
+ GGML_ASSERT (false );
6463
6467
}
6464
6468
}
6465
6469
0 commit comments