check ctx and model before calling sampler
This commit is contained in:
parent
207eb94a51
commit
3c4b093e80
|
|
@ -1195,9 +1195,6 @@ llama_context * common_init_result::context() {
|
|||
}
|
||||
|
||||
common_sampler * common_init_result::sampler(llama_seq_id seq_id) {
|
||||
if (pimpl->samplers.size() <= (size_t) seq_id) {
|
||||
return nullptr;
|
||||
}
|
||||
return pimpl->samplers[seq_id].get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,16 +143,13 @@ int main(int argc, char ** argv) {
|
|||
|
||||
ctx = llama_init->context();
|
||||
model = llama_init->model();
|
||||
smpl = llama_init->sampler(0);
|
||||
if (smpl == NULL) {
|
||||
LOG_ERR("%s: error: unable to create sampler\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctx == NULL) {
|
||||
LOG_ERR("%s: error: unable to create context\n", __func__);
|
||||
if (model == nullptr || ctx == nullptr) {
|
||||
LOG_ERR("%s : failed to init\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
smpl = llama_init->sampler(0);
|
||||
|
||||
llama_memory_t mem = llama_get_memory(ctx);
|
||||
const llama_vocab * vocab = llama_model_get_vocab(model);
|
||||
|
|
|
|||
Loading…
Reference in New Issue