Spaces:
Running
Running
ggml : fix some compile warnings
Browse files- ggml-cuda.cu +9 -0
- ggml-metal.m +5 -4
- whisper.cpp +9 -15
ggml-cuda.cu
CHANGED
|
@@ -7962,6 +7962,15 @@ bool ggml_cuda_compute_forward(struct ggml_compute_params * params, struct ggml_
|
|
| 7962 |
return false;
|
| 7963 |
}
|
| 7964 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7965 |
switch (tensor->op) {
|
| 7966 |
case GGML_OP_REPEAT:
|
| 7967 |
func = ggml_cuda_repeat;
|
|
|
|
| 7962 |
return false;
|
| 7963 |
}
|
| 7964 |
|
| 7965 |
+
if (tensor->op == GGML_OP_MUL_MAT) {
|
| 7966 |
+
if (tensor->src[0]->ne[3] != tensor->src[1]->ne[3]) {
|
| 7967 |
+
#ifndef NDEBUG
|
| 7968 |
+
fprintf(stderr, "%s: cannot compute %s: src0->ne[3] = %d, src1->ne[3] = %d - fallback to CPU\n", __func__, tensor->name, tensor->src[0]->ne[3], tensor->src[1]->ne[3]);
|
| 7969 |
+
#endif
|
| 7970 |
+
return false;
|
| 7971 |
+
}
|
| 7972 |
+
}
|
| 7973 |
+
|
| 7974 |
switch (tensor->op) {
|
| 7975 |
case GGML_OP_REPEAT:
|
| 7976 |
func = ggml_cuda_repeat;
|
ggml-metal.m
CHANGED
|
@@ -128,7 +128,7 @@ struct ggml_metal_context {
|
|
| 128 |
// MSL code
|
| 129 |
// TODO: move the contents here when ready
|
| 130 |
// for now it is easier to work in a separate file
|
| 131 |
-
static NSString * const msl_library_source = @"see metal.metal";
|
| 132 |
|
| 133 |
// Here to assist with NSBundle Path Hack
|
| 134 |
@interface GGMLMetalClass : NSObject
|
|
@@ -144,7 +144,8 @@ void ggml_metal_log_set_callback(ggml_log_callback log_callback, void * user_dat
|
|
| 144 |
ggml_metal_log_user_data = user_data;
|
| 145 |
}
|
| 146 |
|
| 147 |
-
|
|
|
|
| 148 |
if (ggml_metal_log_callback != NULL) {
|
| 149 |
va_list args;
|
| 150 |
va_start(args, format);
|
|
@@ -339,7 +340,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
|
|
| 339 |
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
|
| 340 |
for (int i = MTLGPUFamilyApple1 + 20; i >= MTLGPUFamilyApple1; --i) {
|
| 341 |
if ([ctx->device supportsFamily:i]) {
|
| 342 |
-
GGML_METAL_LOG_INFO("%s: GPU family: MTLGPUFamilyApple%d (%d)\n", __func__, i - MTLGPUFamilyApple1 + 1, i);
|
| 343 |
break;
|
| 344 |
}
|
| 345 |
}
|
|
@@ -583,7 +584,7 @@ bool ggml_metal_add_buffer(
|
|
| 583 |
ctx->device.recommendedMaxWorkingSetSize / 1024.0 / 1024.0);
|
| 584 |
|
| 585 |
if (ctx->device.currentAllocatedSize > ctx->device.recommendedMaxWorkingSetSize) {
|
| 586 |
-
GGML_METAL_LOG_WARN("
|
| 587 |
} else {
|
| 588 |
GGML_METAL_LOG_INFO("\n");
|
| 589 |
}
|
|
|
|
| 128 |
// MSL code
|
| 129 |
// TODO: move the contents here when ready
|
| 130 |
// for now it is easier to work in a separate file
|
| 131 |
+
//static NSString * const msl_library_source = @"see metal.metal";
|
| 132 |
|
| 133 |
// Here to assist with NSBundle Path Hack
|
| 134 |
@interface GGMLMetalClass : NSObject
|
|
|
|
| 144 |
ggml_metal_log_user_data = user_data;
|
| 145 |
}
|
| 146 |
|
| 147 |
+
GGML_ATTRIBUTE_FORMAT(2, 3)
|
| 148 |
+
static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){
|
| 149 |
if (ggml_metal_log_callback != NULL) {
|
| 150 |
va_list args;
|
| 151 |
va_start(args, format);
|
|
|
|
| 340 |
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
|
| 341 |
for (int i = MTLGPUFamilyApple1 + 20; i >= MTLGPUFamilyApple1; --i) {
|
| 342 |
if ([ctx->device supportsFamily:i]) {
|
| 343 |
+
GGML_METAL_LOG_INFO("%s: GPU family: MTLGPUFamilyApple%d (%d)\n", __func__, i - (int) MTLGPUFamilyApple1 + 1, i);
|
| 344 |
break;
|
| 345 |
}
|
| 346 |
}
|
|
|
|
| 584 |
ctx->device.recommendedMaxWorkingSetSize / 1024.0 / 1024.0);
|
| 585 |
|
| 586 |
if (ctx->device.currentAllocatedSize > ctx->device.recommendedMaxWorkingSetSize) {
|
| 587 |
+
GGML_METAL_LOG_WARN("%s: warning: current allocated size is greater than the recommended max working set size\n", __func__);
|
| 588 |
} else {
|
| 589 |
GGML_METAL_LOG_INFO("\n");
|
| 590 |
}
|
whisper.cpp
CHANGED
|
@@ -118,7 +118,7 @@ static void byteswap_tensor(ggml_tensor * tensor) {
|
|
| 118 |
//
|
| 119 |
|
| 120 |
WHISPER_ATTRIBUTE_FORMAT(2, 3)
|
| 121 |
-
static void whisper_log_internal (ggml_log_level level, const char* format, ...);
|
| 122 |
static void whisper_log_callback_default(ggml_log_level level, const char * text, void * user_data);
|
| 123 |
|
| 124 |
#define WHISPER_LOG_INFO(...) whisper_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
|
|
@@ -5848,27 +5848,21 @@ void whisper_log_set(ggml_log_callback log_callback, void * user_data) {
|
|
| 5848 |
g_state.log_callback_user_data = user_data;
|
| 5849 |
}
|
| 5850 |
|
| 5851 |
-
|
| 5852 |
-
|
| 5853 |
-
|
| 5854 |
-
|
| 5855 |
-
|
| 5856 |
-
|
|
|
|
| 5857 |
g_state.log_callback(level, buffer, g_state.log_callback_user_data);
|
| 5858 |
} else {
|
| 5859 |
char* buffer2 = new char[len+1];
|
| 5860 |
-
vsnprintf(buffer2, len+1, format,
|
| 5861 |
buffer2[len] = 0;
|
| 5862 |
g_state.log_callback(level, buffer2, g_state.log_callback_user_data);
|
| 5863 |
delete[] buffer2;
|
| 5864 |
}
|
| 5865 |
-
va_end(args_copy);
|
| 5866 |
-
}
|
| 5867 |
-
|
| 5868 |
-
static void whisper_log_internal(ggml_log_level level, const char * format, ...) {
|
| 5869 |
-
va_list args;
|
| 5870 |
-
va_start(args, format);
|
| 5871 |
-
whisper_log_internal_v(level, format, args);
|
| 5872 |
va_end(args);
|
| 5873 |
}
|
| 5874 |
|
|
|
|
| 118 |
//
|
| 119 |
|
| 120 |
WHISPER_ATTRIBUTE_FORMAT(2, 3)
|
| 121 |
+
static void whisper_log_internal (ggml_log_level level, const char * format, ...);
|
| 122 |
static void whisper_log_callback_default(ggml_log_level level, const char * text, void * user_data);
|
| 123 |
|
| 124 |
#define WHISPER_LOG_INFO(...) whisper_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
|
|
|
|
| 5848 |
g_state.log_callback_user_data = user_data;
|
| 5849 |
}
|
| 5850 |
|
| 5851 |
+
GGML_ATTRIBUTE_FORMAT(2, 3)
|
| 5852 |
+
static void whisper_log_internal(ggml_log_level level, const char * format, ...) {
|
| 5853 |
+
va_list args;
|
| 5854 |
+
va_start(args, format);
|
| 5855 |
+
char buffer[1024];
|
| 5856 |
+
int len = vsnprintf(buffer, 1024, format, args);
|
| 5857 |
+
if (len < 1024) {
|
| 5858 |
g_state.log_callback(level, buffer, g_state.log_callback_user_data);
|
| 5859 |
} else {
|
| 5860 |
char* buffer2 = new char[len+1];
|
| 5861 |
+
vsnprintf(buffer2, len+1, format, args);
|
| 5862 |
buffer2[len] = 0;
|
| 5863 |
g_state.log_callback(level, buffer2, g_state.log_callback_user_data);
|
| 5864 |
delete[] buffer2;
|
| 5865 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5866 |
va_end(args);
|
| 5867 |
}
|
| 5868 |
|