diff --git a/common/sampling.cpp b/common/sampling.cpp index 711d647f8..62e636669 100644 --- a/common/sampling.cpp +++ b/common/sampling.cpp @@ -197,7 +197,7 @@ static llama_token llama_sampling_sample_impl( } // apply params.logit_bias map - for (auto logit_bia : params.logit_bias) { + for (const auto & logit_bia : params.logit_bias) { logits[logit_bia.first] += logit_bia.second; } diff --git a/common/train.cpp b/common/train.cpp index c51a1839a..59be89ce9 100644 --- a/common/train.cpp +++ b/common/train.cpp @@ -46,21 +46,21 @@ void free_train_state(struct train_state * state) { struct random_normal_distribution * init_random_normal_distribution( int seed, float mean, float std, float min, float max ) { - auto rnd = new random_normal_distribution{ std::mt19937(seed), std::normal_distribution{mean, std}, min, max}; + auto rnd = new random_normal_distribution{std::mt19937(seed), std::normal_distribution{mean, std}, min, max}; return rnd; } struct random_uniform_distribution * init_random_uniform_distribution(int seed, float min, float max) { - auto rnd = new random_uniform_distribution{ std::mt19937(seed), std::uniform_real_distribution{min, max} }; + auto rnd = new random_uniform_distribution{std::mt19937(seed), std::uniform_real_distribution{min, max}}; return rnd; } void free_random_normal_distribution (struct random_normal_distribution * rnd) { - free(rnd); + delete rnd; } void free_random_uniform_distribution(struct random_uniform_distribution * rnd) { - free(rnd); + delete rnd; } struct ggml_tensor * randomize_tensor_normal(struct ggml_tensor * tensor, struct random_normal_distribution * rnd) {