try to fix ci compile errors (+1 squashed commits)

Squashed commits:

[d0d49663] fixed log multiline (+1 squashed commits)

Squashed commits:

[81a8befe] try to fix linux build error (+1 squashed commits)

Squashed commits:

[22850dda] try to fix build (+1 squashed commits)

Squashed commits:

[b8294611] missing type
This commit is contained in:
Concedo 2024-03-01 18:15:20 +08:00
parent 040de7d899
commit 2d9a90b652
6 changed files with 52 additions and 38 deletions

View file

@ -1437,7 +1437,7 @@ bool gpttype_generate_abort()
{ {
if(kcpp_params==nullptr) if(kcpp_params==nullptr)
{ {
printf("\nWarning: KCPP not initialized!\n"); printf("\nWarning: KCPP text generation not initialized!\n");
} }
stopper_unused_tokens = remaining_tokens; stopper_unused_tokens = remaining_tokens;
remaining_tokens = 0; remaining_tokens = 0;
@ -1449,7 +1449,7 @@ std::vector<int> gpttype_get_token_arr(const std::string & input)
std::vector<int> toks; std::vector<int> toks;
if(kcpp_params==nullptr) if(kcpp_params==nullptr)
{ {
printf("\nWarning: KCPP not initialized!\n"); printf("\nWarning: KCPP text generation not initialized!\n");
return toks; return toks;
} }
if(debugmode==1) if(debugmode==1)
@ -1469,7 +1469,7 @@ const std::string & gpttype_get_pending_output()
{ {
if(kcpp_params==nullptr) if(kcpp_params==nullptr)
{ {
printf("\nWarning: KCPP not initialized!\n"); printf("\nWarning: KCPP text generation not initialized!\n");
return concat_output_reader_copy_poll; return concat_output_reader_copy_poll;
} }
concat_output_mtx.lock(); concat_output_mtx.lock();
@ -1500,7 +1500,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
if(kcpp_params==nullptr) if(kcpp_params==nullptr)
{ {
printf("\nWarning: KCPP not initialized!\n"); printf("\nWarning: KCPP text generation not initialized!\n");
output.text = nullptr; output.text = nullptr;
output.status = 0; output.status = 0;
generation_finished = true; generation_finished = true;

View file

@ -3509,7 +3509,7 @@ Current version: 118
image_styles: "", image_styles: "",
image_negprompt: "", image_negprompt: "",
grammar:"", grammar:"",
tokenstreammode: (localflag?1:0), //0=off,1=pollstream,2=sse tokenstreammode: (localflag?2:0), //0=off,1=pollstream,2=sse
generate_images_mode: (localflag?0:1), //0=off, 1=horde, 2=a1111, 3=dalle generate_images_mode: (localflag?0:1), //0=off, 1=horde, 2=a1111, 3=dalle
generate_images_model: "stable_diffusion", //"" is disabled and "*" is all, anything else is the model name pulled from stable horde generate_images_model: "stable_diffusion", //"" is disabled and "*" is all, anything else is the model name pulled from stable horde
img_autogen: false, img_autogen: false,
@ -13989,10 +13989,10 @@ Current version: 118
<div class="settingitem"> <div class="settingitem">
<div class="settinglabel"> <div class="settinglabel">
<div class="justifyleft settingsmall" id="tokenstreaminglabel" title="">Token Streaming <span class="helpicon">?<span <div class="justifyleft settingsmall" id="tokenstreaminglabel" title="">Token Streaming <span class="helpicon">?<span
class="helptext">Attempts to use token streaming if supported. Not available on Horde.</span></span></div> class="helptext">Use token streaming for partial responses. SSE is smoother but less well-supported. Poll is chunkier but more reliable. Not available on Horde.</span></span></div>
<select style="padding:1px; height:auto; width: 34px; appearance: none; font-size: 7pt; margin:0px 0px 0px auto;" class="form-control" id="tokenstreammode"> <select style="padding:1px; height:auto; width: 34px; appearance: none; font-size: 7pt; margin:0px 0px 0px auto;" class="form-control" id="tokenstreammode">
<option value="0">Off</option> <option value="0">Off</option>
<option value="1">On</option> <option value="1">Poll</option>
<option value="2">SSE</option> <option value="2">SSE</option>
</select> </select>
</div> </div>

View file

@ -6,6 +6,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <inttypes.h>
#include <cinttypes>
#include "model_adapter.h" #include "model_adapter.h"
#include "stable-diffusion.cpp" #include "stable-diffusion.cpp"
@ -135,24 +138,10 @@ std::string base64_encode(const unsigned char* data, unsigned int data_length) {
return encoded; return encoded;
} }
static void sd_logger_callback(enum sd_log_level_t level, const char* log, void* data) {
SDParams* params = (SDParams*)data;
if (!params->verbose && level <= SD_LOG_DEBUG) {
return;
}
if (level <= SD_LOG_INFO) {
fputs(log, stdout);
fflush(stdout);
} else {
fputs(log, stderr);
fflush(stderr);
}
}
static std::string sdplatformenv, sddeviceenv, sdvulkandeviceenv; static std::string sdplatformenv, sddeviceenv, sdvulkandeviceenv;
bool sdtype_load_model(const sd_load_model_inputs inputs) { bool sdtype_load_model(const sd_load_model_inputs inputs) {
printf("\nImage Gen - Load Safetensors Image Model: %s\n",inputs.model_filename); printf("\nImage Generation Init - Load Safetensors Model: %s\n",inputs.model_filename);
//duplicated from expose.cpp //duplicated from expose.cpp
int cl_parseinfo = inputs.clblast_info; //first digit is whether configured, second is platform, third is devices int cl_parseinfo = inputs.clblast_info; //first digit is whether configured, second is platform, third is devices
@ -189,10 +178,7 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
sddebugmode = inputs.debugmode; sddebugmode = inputs.debugmode;
if(sddebugmode==1) set_log_message(sddebugmode==1);
{
sd_set_log_callback(sd_logger_callback, (void*)sd_params);
}
bool vae_decode_only = false; bool vae_decode_only = false;
bool free_param = false; bool free_param = false;
@ -245,7 +231,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
if(sd_ctx == nullptr || sd_params == nullptr) if(sd_ctx == nullptr || sd_params == nullptr)
{ {
printf("\nError: KCPP SD is not initialized!\n"); printf("\nWarning: KCPP image generation not initialized!\n");
output.data = ""; output.data = "";
output.status = 0; output.status = 0;
return output; return output;

View file

@ -15,6 +15,9 @@
#include "unet.hpp" #include "unet.hpp"
#include "vae.hpp" #include "vae.hpp"
#include <inttypes.h>
#include <cinttypes>
const char* model_version_to_str[] = { const char* model_version_to_str[] = {
"1.x", "1.x",
"2.x", "2.x",
@ -487,7 +490,7 @@ public:
// } // }
int64_t t1 = ggml_time_ms(); int64_t t1 = ggml_time_ms();
LOG_DEBUG("computing condition graph completed, taking %" PRId64 " ms", t1 - t0); LOG_DEBUG("computing condition graph completed, taking %d ms", (int)(t1 - t0));
ggml_tensor* result = ggml_dup_tensor(work_ctx, hidden_states); ggml_tensor* result = ggml_dup_tensor(work_ctx, hidden_states);
{ {
float original_mean = ggml_tensor_mean(hidden_states); float original_mean = ggml_tensor_mean(hidden_states);
@ -628,7 +631,7 @@ public:
print_ggml_tensor(y); print_ggml_tensor(y);
} }
int64_t t1 = ggml_time_ms(); int64_t t1 = ggml_time_ms();
LOG_DEBUG("computing svd condition graph completed, taking %" PRId64 " ms", t1 - t0); LOG_DEBUG("computing svd condition graph completed, taking %d ms",(int)(t1 - t0));
return {c_crossattn, c_concat, y}; return {c_crossattn, c_concat, y};
} }
@ -1392,7 +1395,7 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
uc_vector = uncond_pair.second; // [adm_in_channels, ] uc_vector = uncond_pair.second; // [adm_in_channels, ]
} }
t1 = ggml_time_ms(); t1 = ggml_time_ms();
LOG_INFO("get_learned_condition completed, taking %" PRId64 " ms", t1 - t0); LOG_INFO("get_learned_condition completed, taking %d ms", (int)(t1 - t0));
if (sd_ctx->sd->free_params_immediately) { if (sd_ctx->sd->free_params_immediately) {
sd_ctx->sd->cond_stage_model->free_params_buffer(); sd_ctx->sd->cond_stage_model->free_params_buffer();
@ -1446,7 +1449,7 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
sd_ctx->sd->diffusion_model->free_params_buffer(); sd_ctx->sd->diffusion_model->free_params_buffer();
} }
int64_t t3 = ggml_time_ms(); int64_t t3 = ggml_time_ms();
LOG_INFO("generating %" PRId64 " latent images completed, taking %.2fs", final_latents.size(), (t3 - t1) * 1.0f / 1000); LOG_INFO("generating %d latent images completed, taking %.2fs", final_latents.size(), (t3 - t1) * 1.0f / 1000);
LOG_INFO("decoding %zu latents", final_latents.size()); LOG_INFO("decoding %zu latents", final_latents.size());
std::vector<struct ggml_tensor*> decoded_images; // collect decoded images std::vector<struct ggml_tensor*> decoded_images; // collect decoded images
@ -1458,7 +1461,7 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
decoded_images.push_back(img); decoded_images.push_back(img);
} }
int64_t t2 = ggml_time_ms(); int64_t t2 = ggml_time_ms();
LOG_INFO("latent %" PRId64 " decoded, taking %.2fs", i + 1, (t2 - t1) * 1.0f / 1000); LOG_INFO("latent %d decoded, taking %.2fs", i + 1, (t2 - t1) * 1.0f / 1000);
} }
int64_t t4 = ggml_time_ms(); int64_t t4 = ggml_time_ms();
@ -1577,7 +1580,7 @@ sd_image_t* img2img(sd_ctx_t* sd_ctx,
uc_vector = uncond_pair.second; // [adm_in_channels, ] uc_vector = uncond_pair.second; // [adm_in_channels, ]
} }
int64_t t2 = ggml_time_ms(); int64_t t2 = ggml_time_ms();
LOG_INFO("get_learned_condition completed, taking %" PRId64 " ms", t2 - t1); LOG_INFO("get_learned_condition completed, taking %d ms", (int)(t2 - t1));
if (sd_ctx->sd->free_params_immediately) { if (sd_ctx->sd->free_params_immediately) {
sd_ctx->sd->cond_stage_model->free_params_buffer(); sd_ctx->sd->cond_stage_model->free_params_buffer();
} }
@ -1710,7 +1713,7 @@ SD_API sd_image_t* img2vid(sd_ctx_t* sd_ctx,
uc_vector = ggml_dup_tensor(work_ctx, c_vector); uc_vector = ggml_dup_tensor(work_ctx, c_vector);
int64_t t1 = ggml_time_ms(); int64_t t1 = ggml_time_ms();
LOG_INFO("get_learned_condition completed, taking %" PRId64 " ms", t1 - t0); LOG_INFO("get_learned_condition completed, taking %d ms", (int)(t1 - t0));
if (sd_ctx->sd->free_params_immediately) { if (sd_ctx->sd->free_params_immediately) {
sd_ctx->sd->clip_vision->free_params_buffer(); sd_ctx->sd->clip_vision->free_params_buffer();
} }

View file

@ -12,6 +12,9 @@
#include <vector> #include <vector>
#include "preprocessing.hpp" #include "preprocessing.hpp"
#include <inttypes.h>
#include <cinttypes>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/types.h> #include <sys/types.h>
@ -253,6 +256,22 @@ void* sd_log_cb_data = NULL;
#define LOG_BUFFER_SIZE 1024 #define LOG_BUFFER_SIZE 1024
static bool do_log = true;
void log_message(const char* format, ...) {
if (do_log) {
printf("\n");
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
fflush(stdout);
}
}
void set_log_message(bool log)
{
do_log = log;
}
void log_printf(sd_log_level_t level, const char* file, int line, const char* format, ...) { void log_printf(sd_log_level_t level, const char* file, int line, const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);

View file

@ -44,8 +44,14 @@ void log_printf(sd_log_level_t level, const char* file, int line, const char* fo
std::string trim(const std::string& s); std::string trim(const std::string& s);
#define LOG_DEBUG(format, ...) log_printf(SD_LOG_DEBUG, __FILE__, __LINE__, format, ##__VA_ARGS__) void log_message(const char* format, ...);
#define LOG_INFO(format, ...) log_printf(SD_LOG_INFO, __FILE__, __LINE__, format, ##__VA_ARGS__) void set_log_message(bool log);
#define LOG_WARN(format, ...) log_printf(SD_LOG_WARN, __FILE__, __LINE__, format, ##__VA_ARGS__) #define LOG_DEBUG(...) log_message(__VA_ARGS__)
#define LOG_ERROR(format, ...) log_printf(SD_LOG_ERROR, __FILE__, __LINE__, format, ##__VA_ARGS__) #define LOG_INFO(...) log_message(__VA_ARGS__)
#define LOG_WARN(...) log_message(__VA_ARGS__)
#define LOG_ERROR(...) log_message(__VA_ARGS__)
// #define LOG_DEBUG(format, ...) log_printf(SD_LOG_DEBUG, __FILE__, __LINE__, format, ##__VA_ARGS__)
// #define LOG_INFO(format, ...) log_printf(SD_LOG_INFO, __FILE__, __LINE__, format, ##__VA_ARGS__)
// #define LOG_WARN(format, ...) log_printf(SD_LOG_WARN, __FILE__, __LINE__, format, ##__VA_ARGS__)
// #define LOG_ERROR(format, ...) log_printf(SD_LOG_ERROR, __FILE__, __LINE__, format, ##__VA_ARGS__)
#endif // __UTIL_H__ #endif // __UTIL_H__