Use default scheduler and sampler if not specified

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-11-29 18:47:14 +01:00
parent ba20cd7ff4
commit 7cca1b2124
2 changed files with 9 additions and 5 deletions

View file

@ -181,6 +181,7 @@ void print_params(SDParams params) {
sd_ctx_t* sd_c;
int load_model(char *model, char *schedule_selected, int threads) {
fprintf (stderr, "Loading model!\n");
int schedule_found = -1;
for (int d = 0; d < N_SCHEDULES; d++) {
@ -189,9 +190,11 @@ int load_model(char *model, char *schedule_selected, int threads) {
}
}
if (schedule_found == -1) {
printf("invalid scheduler\n");
return 1;
fprintf (stderr, "Invalid scheduler! using DEFAULT\n");
schedule_found = DEFAULT;
}
schedule_t schedule = (schedule_t)schedule_found;
sd_ctx_t* sd_ctx = new_sd_ctx(model,
@ -218,7 +221,7 @@ int load_model(char *model, char *schedule_selected, int threads) {
false);
if (sd_ctx == NULL) {
printf("new_sd_ctx_t failed\n");
fprintf (stderr, "Null context!\n");
return 1;
}
@ -239,7 +242,8 @@ int gen_image(char *text, char *negativeText, int width, int height, int steps,
}
}
if (sample_method_found == -1) {
printf("generate failed\n");
fprintf(stderr, "Invalid sample method, default to EULER_A!\n");
sample_method_found = EULER_A;
return 1;
}
sample_method_t sample_method = (sample_method_t)sample_method_found;

View file

@ -31,7 +31,7 @@ func (sd *SDGGML) Load(opts *pb.ModelOptions) error {
ret := C.load_model(modelFile, schedulerType, C.int(opts.Threads))
if ret != 0 {
return fmt.Errorf("inference failed")
return fmt.Errorf("could not load model")
}
return nil