MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / create_tensor

Method create_tensor

subprojects/llama.cpp/src/llama-model-loader.cpp:841–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841struct ggml_tensor * llama_model_loader::create_tensor(struct ggml_context * ctx, const std::string & name, const std::initializer_list<int64_t> & ne, int flags) {
842 LLAMA_LOG_DEBUG("%s: loading tensor %s\n", __func__, name.c_str());
843 const struct ggml_tensor * cur = check_tensor_dims(name, ne, !(flags & TENSOR_NOT_REQUIRED));
844
845 if (cur == NULL) {
846 return NULL;
847 }
848
849 bool duplicated = flags & TENSOR_DUPLICATED;
850
851 struct ggml_tensor * tensor = ggml_dup_tensor(ctx, cur);
852 ggml_set_name(tensor, ggml_get_name(cur));
853
854 if (duplicated) {
855 size_data += ggml_nbytes(cur);
856 } else {
857 n_created++;
858 }
859
860 return tensor;
861
862}
863
864struct ggml_tensor * llama_model_loader::create_tensor_as_view(struct ggml_context * ctx, struct ggml_tensor * base, const std::string & name, const std::initializer_list<int64_t> & ne, size_t offset, bool required) {
865 const struct ggml_tensor * cur = check_tensor_dims(name, ne, required);

Callers 1

load_tensorsMethod · 0.80

Calls 4

ggml_dup_tensorFunction · 0.85
ggml_set_nameFunction · 0.85
ggml_get_nameFunction · 0.85
ggml_nbytesFunction · 0.85

Tested by

no test coverage detected