| 919 | } |
| 920 | |
| 921 | int64_t gguf_find_tensor(const struct gguf_context * ctx, const char * name) { |
| 922 | // return -1 if tensor not found |
| 923 | int64_t tensor_id = -1; |
| 924 | |
| 925 | const int64_t n_tensors = gguf_get_n_tensors(ctx); |
| 926 | |
| 927 | for (int64_t i = 0; i < n_tensors; ++i) { |
| 928 | if (strcmp(name, gguf_get_tensor_name(ctx, i)) == 0) { |
| 929 | tensor_id = i; |
| 930 | break; |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | return tensor_id; |
| 935 | } |
| 936 | |
| 937 | size_t gguf_get_tensor_offset(const struct gguf_context * ctx, int64_t tensor_id) { |
| 938 | GGML_ASSERT(tensor_id >= 0 && tensor_id < gguf_get_n_tensors(ctx)); |