fix hashmap code

This commit is contained in:
JohannesGaessler 2024-02-08 10:11:12 +01:00
parent 449585a498
commit 6d2693bc8d

View file

@ -77,19 +77,16 @@ int main(int argc, char ** argv){
const llama_token value = inp_static[i + 2]; const llama_token value = inp_static[i + 2];
auto frequency_it = hashmap.find(key); auto frequency_it = hashmap.find(key);
std::unordered_map<llama_token, int> frequency;
if (frequency_it != hashmap.end()) { if (frequency_it != hashmap.end()) {
frequency = frequency_it->second; auto token_it = frequency_it->second.find(value);
} if (token_it != frequency_it->second.end()) {
auto token_it = frequency.find(value);
if (token_it != frequency.end()) {
token_it->second++; token_it->second++;
} else { } else {
frequency.emplace(std::make_pair(value, 1)); frequency_it->second.emplace(std::make_pair(value, 1));
} }
} else {
if (frequency_it == hashmap.end()) { std::unordered_map<llama_token, int> frequency;
frequency.emplace(std::make_pair(value, 1));
hashmap.emplace(std::make_pair(key, frequency)); hashmap.emplace(std::make_pair(key, frequency));
} }
} }