| 1025 | } |
| 1026 | |
| 1027 | int64_t gguf_find_tensor(const struct gguf_context * ctx, const char * name) { |
| 1028 | // return -1 if tensor not found |
| 1029 | int64_t tensor_id = -1; |
| 1030 | |
| 1031 | const int64_t n_tensors = gguf_get_n_tensors(ctx); |
| 1032 | |
| 1033 | for (int64_t i = 0; i < n_tensors; ++i) { |
| 1034 | if (strcmp(name, gguf_get_tensor_name(ctx, i)) == 0) { |
| 1035 | tensor_id = i; |
| 1036 | break; |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | return tensor_id; |
| 1041 | } |
| 1042 | |
| 1043 | size_t gguf_get_tensor_offset(const struct gguf_context * ctx, int64_t tensor_id) { |
| 1044 | GGML_ASSERT(tensor_id >= 0 && tensor_id < gguf_get_n_tensors(ctx)); |
no test coverage detected