MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / check_tensor_dims

Method check_tensor_dims

src/llama-model-loader.cpp:863–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

861}
862
863const struct ggml_tensor * llama_model_loader::check_tensor_dims(const std::string & name, const std::vector<int64_t> & ne, bool required) const {
864 const struct ggml_tensor * cur = get_tensor_meta(name.c_str());
865
866 if (cur == NULL) {
867 if (!required) {
868 return NULL;
869 }
870 throw std::runtime_error(format("%s: tensor '%s' not found", __func__, name.c_str()));
871 }
872
873 {
874 bool is_ok = true;
875 for (size_t i = 0; i < GGML_MAX_DIMS; ++i) {
876 if ((i < ne.size() && ne[i] != cur->ne[i]) || (i >= ne.size() && cur->ne[i] != 1)) {
877 is_ok = false;
878 break;
879 }
880 }
881 if (!is_ok) {
882 throw std::runtime_error(
883 format("%s: tensor '%s' has wrong shape; expected %s, got %s",
884 __func__, name.c_str(),
885 llama_format_tensor_shape(ne).c_str(),
886 llama_format_tensor_shape(cur).c_str()));
887 }
888 }
889
890 return cur;
891}
892
893// checks if the weight tensor can be used with the specified buffer type and device
894static bool weight_buft_supported(const llama_hparams & hparams, ggml_tensor * w, ggml_op op, ggml_backend_buffer_type_t buft, ggml_backend_dev_t dev) {

Callers

nothing calls this directly

Calls 3

formatFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected