@@ -139,7 +139,7 @@ static float ggml_get_float_value(uint8_t * data, ggml_type type, const size_t *
139139}
140140
141141// Function to save a tensor to binary file
142- static void save_tensor (struct ggml_tensor * tensor, const char * filename) {
142+ static void save_tensor (struct ggml_tensor * tensor, uint8_t * data, const char * filename) {
143143 FILE* f = fopen ((std::string (" reference/tensors/conv/" ) + std::string (filename)).c_str (), " wb" );
144144 if (!f) {
145145 fprintf (stderr, " Failed to create file: %s\n " , filename);
@@ -153,13 +153,13 @@ static void save_tensor(struct ggml_tensor* tensor, const char* filename) {
153153 int64_t total_elements = tensor->ne [0 ] * tensor->ne [1 ] * tensor->ne [2 ] * tensor->ne [3 ];
154154
155155 // Write data
156- fwrite (tensor-> data , sizeof (float ), total_elements, f);
156+ fwrite (data, sizeof (float ), total_elements, f);
157157 fclose (f);
158158}
159159
160160static void ggml_print_tensor (uint8_t * data, ggml_type type, const int64_t * ne, const size_t * nb, int64_t n) {
161161 GGML_ASSERT (n > 0 );
162- float sum = 0 ;
162+ double sum = 0 ;
163163 for (int64_t i3 = 0 ; i3 < ne[3 ]; i3++) {
164164 for (int64_t i2 = 0 ; i2 < ne[2 ]; i2++) {
165165 for (int64_t i1 = 0 ; i1 < ne[1 ]; i1++) {
@@ -249,7 +249,7 @@ static bool ggml_debug(struct ggml_tensor * t, bool ask, void * user_data) {
249249 } else {
250250 cb_data->tensors [t->name ]++;
251251 }
252- save_tensor (t, (std::string (t->name ) + " _" + std::to_string (cb_data->tensors [t->name ]) + " .bin" ).c_str ());
252+ save_tensor (t, data, (std::string (t->name ) + " _" + std::to_string (cb_data->tensors [t->name ]) + " .bin" ).c_str ());
253253 }
254254 }
255255
0 commit comments