MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / LLM_TN

Class LLM_TN

llama.cpp:688–708  ·  view source on GitHub ↗

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"

Source from the content-addressed store, hash-verified

686// std::string name = tn(LLM_TENSOR_ATTN_NORM, "weight", 3); -> "blk.3.attn_norm.weight"
687//
688struct 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

Callers 3

llm_load_tensorsFunction · 0.70
get_k_quant_typeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected