Skip to content

Commit

Permalink
Fixed compile error on Solaris.
Browse files Browse the repository at this point in the history
  • Loading branch information
taku910 committed Jun 8, 2020
1 parent 63ff22a commit 59b6fe0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/char_model_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ util::Status Trainer::Train() {
sum += it.second;
}

const float logsum = log(sum);
const auto logsum = std::log(static_cast<float>(sum));

CHECK_OR_RETURN(final_pieces_.empty());
for (const auto &it : Sorted(required_chars_)) {
Expand All @@ -46,7 +46,7 @@ util::Status Trainer::Train() {
break;
}
final_pieces_.emplace_back(string_util::UnicodeCharToUTF8(it.first),
log(it.second) - logsum);
std::log(static_cast<float>(it.second)) - logsum);
}

if (trainer_spec_.use_all_vocab()) {
Expand Down
2 changes: 1 addition & 1 deletion src/unigram_model_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ double Digamma(double x) {
const double xx = 1.0 / x;
const double xx2 = xx * xx;
const double xx4 = xx2 * xx2;
result += log(x) + (1.0 / 24.0) * xx2 - (7.0 / 960.0) * xx4 +
result += std::log(x) + (1.0 / 24.0) * xx2 - (7.0 / 960.0) * xx4 +
(31.0 / 8064.0) * xx4 * xx2 - (127.0 / 30720.0) * xx4 * xx4;
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/word_model_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ util::Status Trainer::Train() {
sum += it.second;
}

const float logsum = log(sum);
const auto logsum = std::log(static_cast<float>(sum));

CHECK_OR_RETURN(final_pieces_.empty());
for (const auto &it : Sorted(freq)) {
Expand All @@ -58,7 +58,7 @@ util::Status Trainer::Train() {
final_pieces_.size() == static_cast<size_t>(vocab_size)) {
break;
}
final_pieces_.emplace_back(it.first, log(it.second) - logsum);
final_pieces_.emplace_back(it.first, std::log(static_cast<float>(it.second)) - logsum);
}

if (trainer_spec_.use_all_vocab()) {
Expand Down

0 comments on commit 59b6fe0

Please sign in to comment.