helper to handle gguf constants usage: const auto tn = LLM_TN(LLM_ARCH_LLAMA); std::string name = tn(LLM_TENSOR_OUTPUT); -> "output" std::string name = tn(LLM_TENSOR_TOKEN_EMBD, "bias"); -> "token_embd.bias" std::string name = tn(LLM_TENSOR_ATTN_NORM, "weight", 3); -> "blk.3.attn_norm.weight"
| 686 | // std::string name = tn(LLM_TENSOR_ATTN_NORM, "weight", 3); -> "blk.3.attn_norm.weight" |
| 687 | // |
| 688 | struct LLM_TN { |
| 689 | LLM_TN(llm_arch arch) : arch(arch) {} |
| 690 | |
| 691 | llm_arch arch; |
| 692 | |
| 693 | std::pair<std::string, llm_tensor> operator()(llm_tensor tensor) const { |
| 694 | return std::make_pair(LLM_TENSOR_NAMES[arch].at(tensor), tensor); |
| 695 | } |
| 696 | |
| 697 | std::pair<std::string, llm_tensor> operator()(llm_tensor tensor, const std::string & suffix) const { |
| 698 | return std::make_pair(LLM_TENSOR_NAMES[arch].at(tensor) + "." + suffix, tensor); |
| 699 | } |
| 700 | |
| 701 | std::pair<std::string, llm_tensor> operator()(llm_tensor tensor, int bid) const { |
| 702 | return std::make_pair(::format(LLM_TENSOR_NAMES[arch].at(tensor).c_str(), bid), tensor); |
| 703 | } |
| 704 | |
| 705 | std::pair<std::string, llm_tensor> operator()(llm_tensor tensor, const std::string & suffix, int bid) const { |
| 706 | return std::make_pair(::format(LLM_TENSOR_NAMES[arch].at(tensor).c_str(), bid) + "." + suffix, tensor); |
| 707 | } |
| 708 | }; |
| 709 | |
| 710 | // |
| 711 | // gguf helpers |
no outgoing calls
no test coverage detected