Skip to content

Commit

Permalink
try to fix linux build error (+1 squashed commits)
Browse files Browse the repository at this point in the history
Squashed commits:

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

Squashed commits:

[b829461] missing type
  • Loading branch information
LostRuins committed Mar 1, 2024
1 parent 040de7d commit 81a8bef
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
8 changes: 4 additions & 4 deletions gpttype_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ bool gpttype_generate_abort()
{
if(kcpp_params==nullptr)
{
printf("\nWarning: KCPP not initialized!\n");
printf("\nWarning: KCPP text generation not initialized!\n");
}
stopper_unused_tokens = remaining_tokens;
remaining_tokens = 0;
Expand All @@ -1449,7 +1449,7 @@ std::vector<int> gpttype_get_token_arr(const std::string & input)
std::vector<int> toks;
if(kcpp_params==nullptr)
{
printf("\nWarning: KCPP not initialized!\n");
printf("\nWarning: KCPP text generation not initialized!\n");
return toks;
}
if(debugmode==1)
Expand All @@ -1469,7 +1469,7 @@ const std::string & gpttype_get_pending_output()
{
if(kcpp_params==nullptr)
{
printf("\nWarning: KCPP not initialized!\n");
printf("\nWarning: KCPP text generation not initialized!\n");
return concat_output_reader_copy_poll;
}
concat_output_mtx.lock();
Expand Down Expand Up @@ -1500,7 +1500,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)

if(kcpp_params==nullptr)
{
printf("\nWarning: KCPP not initialized!\n");
printf("\nWarning: KCPP text generation not initialized!\n");
output.text = nullptr;
output.status = 0;
generation_finished = true;
Expand Down
6 changes: 3 additions & 3 deletions klite.embd
Original file line number Diff line number Diff line change
Expand Up @@ -3509,7 +3509,7 @@ Current version: 118
image_styles: "",
image_negprompt: "",
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_model: "stable_diffusion", //"" is disabled and "*" is all, anything else is the model name pulled from stable horde
img_autogen: false,
Expand Down Expand Up @@ -13989,10 +13989,10 @@ Current version: 118
<div class="settingitem">
<div class="settinglabel">
<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">
<option value="0">Off</option>
<option value="1">On</option>
<option value="1">Poll</option>
<option value="2">SSE</option>
</select>
</div>
Expand Down
12 changes: 6 additions & 6 deletions otherarch/sdcpp/sdtype_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <string>
#include <vector>

#include <inttypes.h>
#include <cinttypes>

#include "model_adapter.h"

#include "stable-diffusion.cpp"
Expand Down Expand Up @@ -152,7 +155,7 @@ static void sd_logger_callback(enum sd_log_level_t level, const char* log, void*
static std::string sdplatformenv, sddeviceenv, sdvulkandeviceenv;
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
int cl_parseinfo = inputs.clblast_info; //first digit is whether configured, second is platform, third is devices
Expand Down Expand Up @@ -189,10 +192,7 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {

sddebugmode = inputs.debugmode;

if(sddebugmode==1)
{
sd_set_log_callback(sd_logger_callback, (void*)sd_params);
}
set_log_message(sddebugmode==1);

bool vae_decode_only = false;
bool free_param = false;
Expand Down Expand Up @@ -245,7 +245,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)

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.status = 0;
return output;
Expand Down
3 changes: 3 additions & 0 deletions otherarch/sdcpp/stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "unet.hpp"
#include "vae.hpp"

#include <inttypes.h>
#include <cinttypes>

const char* model_version_to_str[] = {
"1.x",
"2.x",
Expand Down
17 changes: 17 additions & 0 deletions otherarch/sdcpp/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <vector>
#include "preprocessing.hpp"

#include <inttypes.h>
#include <cinttypes>

#if defined(__APPLE__) && defined(__MACH__)
#include <sys/sysctl.h>
#include <sys/types.h>
Expand Down Expand Up @@ -253,6 +256,20 @@ void* sd_log_cb_data = NULL;

#define LOG_BUFFER_SIZE 1024

static bool do_log = true;
void log_message(const char* format, ...) {
if (do_log) {
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
}
}
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, ...) {
va_list args;
va_start(args, format);
Expand Down
14 changes: 10 additions & 4 deletions otherarch/sdcpp/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

#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__)
void log_message(const char* format, ...);
void set_log_message(bool log);
#define LOG_DEBUG(...) log_message(__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__

0 comments on commit 81a8bef

Please sign in to comment.