Skip to content

Commit 1b5a868

Browse files
authored
fix: flushes after printf (leejet#38)
1 parent c8f85a4 commit 1b5a868

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stable-diffusion.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ static SDLogLevel log_level = SDLogLevel::INFO;
2626
} \
2727
if (level == SDLogLevel::DEBUG) { \
2828
printf("[DEBUG] %s:%-4d - " format "\n", __FILENAME__, __LINE__, ##__VA_ARGS__); \
29+
fflush(stdout); \
2930
} else if (level == SDLogLevel::INFO) { \
3031
printf("[INFO] %s:%-4d - " format "\n", __FILENAME__, __LINE__, ##__VA_ARGS__); \
32+
fflush(stdout); \
3133
} else if (level == SDLogLevel::WARN) { \
3234
fprintf(stderr, "[WARN] %s:%-4d - " format "\n", __FILENAME__, __LINE__, ##__VA_ARGS__); \
35+
fflush(stdout); \
3336
} else if (level == SDLogLevel::ERROR) { \
3437
fprintf(stderr, "[ERROR] %s:%-4d - " format "\n", __FILENAME__, __LINE__, ##__VA_ARGS__); \
38+
fflush(stdout); \
3539
} \
3640
} while (0)
3741

@@ -135,6 +139,7 @@ float ggml_tensor_get_f32(const ggml_tensor* tensor, int l, int k = 0, int j = 0
135139

136140
void print_ggml_tensor(struct ggml_tensor* tensor, bool shape_only = false) {
137141
printf("shape(%zu, %zu, %zu, %zu)\n", tensor->ne[0], tensor->ne[1], tensor->ne[2], tensor->ne[3]);
142+
fflush(stdout);
138143
if (shape_only) {
139144
return;
140145
}
@@ -156,6 +161,7 @@ void print_ggml_tensor(struct ggml_tensor* tensor, bool shape_only = false) {
156161
continue;
157162
}
158163
printf(" [%d, %d, %d, %d] = %f\n", i, j, k, l, ggml_tensor_get_f32(tensor, l, k, j, i));
164+
fflush(stdout);
159165
}
160166
}
161167
}

0 commit comments

Comments
 (0)