| 1099 | }; |
| 1100 | |
| 1101 | static void write_tensor(struct llama_file * file, struct ggml_tensor * tensor, const char * name) { |
| 1102 | if (tensor == NULL) { |
| 1103 | file->write_u32(0); |
| 1104 | file->write_u32(0); |
| 1105 | file->write_u32(GGML_TYPE_F32); |
| 1106 | file->seek((0-file->tell()) & 31, SEEK_CUR); |
| 1107 | return; |
| 1108 | } |
| 1109 | if (name == NULL) { |
| 1110 | name = ggml_get_name(tensor); |
| 1111 | } |
| 1112 | uint32_t name_len = strlen(name); |
| 1113 | uint32_t nd = tensor->n_dims; |
| 1114 | uint32_t ne[4] = { (uint32_t)tensor->ne[0], |
| 1115 | (uint32_t)tensor->ne[1], |
| 1116 | (uint32_t)tensor->ne[2], |
| 1117 | (uint32_t)tensor->ne[3] }; |
| 1118 | file->write_u32(nd); |
| 1119 | file->write_u32(name_len); |
| 1120 | file->write_u32(tensor->type); |
| 1121 | file->write_raw(ne, sizeof(ne[0]) * nd); |
| 1122 | file->write_raw(name, name_len); |
| 1123 | file->seek((0-file->tell()) & 31, SEEK_CUR); |
| 1124 | file->write_raw(tensor->data, ggml_nbytes(tensor)); |
| 1125 | } |
| 1126 | |
| 1127 | static void save_as_llama_lora(const char * filename, struct my_llama_lora * lora) { |
| 1128 | printf("%s: saving to %s\n", __func__, filename); |
no test coverage detected