Skip to content

Commit

Permalink
Merge pull request #10 from GilesBathgate/fix-warnings
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
ankan-ban authored Nov 27, 2023
2 parents e3f6986 + 839c217 commit a451b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions llama2_q4.cu
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void malloc_weights(TransformerWeights* w, Config* p) {
}

cudaMalloc((void**)&w->rms_final_weight, p->dim * sizeof(half));
int head_size = p->dim / p->n_heads;
cudaMalloc((void**)&w->wcls, p->vocab_size * p->dim * sizeof(half));

// ensure all mallocs went fine
Expand Down Expand Up @@ -437,7 +436,7 @@ void free_transformer(Transformer* t) {
// ----------------------------------------------------------------------------
// generation loop
void generate(Transformer* transformer, Tokenizer* tokenizer, Sampler* sampler, char* prompt, int steps) {
char* empty_prompt = "";
char empty_prompt[] = "";
if (prompt == NULL) { prompt = empty_prompt; }

// encode the (string) prompt into tokens sequence
Expand Down Expand Up @@ -625,15 +624,17 @@ int main(int argc, char *argv[]) {

// default parameters
char* checkpoint_path = NULL; // e.g. out/model.bin
char* tokenizer_path = "tokenizer.bin";
char default_tokenizer_path[] = "tokenizer.bin";
char* tokenizer_path = default_tokenizer_path;
char* dataset_path = NULL;
int steps = 0; // number of steps to run for
char* prompt = nullptr; // prompt string
bool perplexity = false;
float temperature = 0.5f; // 0.0 = greedy deterministic. 1.0 = original. don't set higher
float topp = 0.6f; // top-p in nucleus sampling. 1.0 = off. 0.9 works well, but slower
unsigned long long rng_seed = 0; // seed rng with time by default
char* mode = "generate"; // generate|chat
char default_mode[] = "generate";
char* mode = default_mode; // generate|chat
char* system_prompt = NULL; // the (optional) system prompt to use in chat mode

// poor man's C argparse
Expand Down
3 changes: 2 additions & 1 deletion tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ void encode(Tokenizer* t, char* text, int8_t bos, int8_t eos, int* tokens, int*
// TODO: pretty sure this isn't correct in the general case but I don't have the
// energy to read more of the sentencepiece code to figure out what it's doing
if (text[0] != '\0') {
int dummy_prefix = str_lookup(" ", t->sorted_vocab, t->vocab_size);
char blank[] = " ";
int dummy_prefix = str_lookup(blank, t->sorted_vocab, t->vocab_size);
tokens[(*n_tokens)++] = dummy_prefix;
}

Expand Down

0 comments on commit a451b21

Please sign in to comment.