add arg --use-fused-softmax

This commit is contained in:
Hieu Hoang 2018-01-22 17:11:21 +00:00
parent a27f16972b
commit cf4e6726d3
2 changed files with 14 additions and 6 deletions

View File

@ -230,7 +230,9 @@ void Config::AddOptions(size_t argc, char** argv) {
("mini-batch-words", po::value<int>()->default_value(0),
"Set mini-batch size based on words instead of sentences.")
("decoding-mini-batch", po::value<size_t>()->default_value(0),
"Number of sentences in mini batch, just in the decoding. (Default=0 - should make the same as mini-batch")
"Number of sentences in mini batch, just in the decoding. (Default=0 - should make the same as mini-batch")
("use-fused-softmax", po::value<bool>()->default_value(true),
"Use fused softmax/nth-element, if appropriate.")
("show-weights", po::value<bool>()->zero_tokens()->default_value(false),
"Output used weights to stdout and exit")
@ -328,6 +330,7 @@ void Config::AddOptions(size_t argc, char** argv) {
SET_OPTION("maxi-batch", size_t);
SET_OPTION("mini-batch-words", int);
SET_OPTION("decoding-mini-batch", size_t);
SET_OPTION("use-fused-softmax", bool);
SET_OPTION("max-length", size_t);
SET_OPTION("encoder-buffer-size", size_t);

View File

@ -92,13 +92,18 @@ God& God::Init(int argc, char** argv) {
LoadFiltering();
returnNBestList_ = Get<bool>("n-best");
useFusedSoftmax_ = true;
if (gpuLoaders_.size() != 1 || // more than 1 scorer
God::Get<size_t>("beam-size") > 11 // beam size affect shared mem alloc in gLogSoftMax()
) {
if (Get<bool>("use-fused-softmax")) {
useFusedSoftmax_ = true;
if (gpuLoaders_.size() != 1 || // more than 1 scorer
God::Get<size_t>("beam-size") > 11 // beam size affect shared mem alloc in gLogSoftMax()
) {
useFusedSoftmax_ = false;
}
}
else {
useFusedSoftmax_ = false;
}
//useFusedSoftmax_ = false;
//cerr << "useFusedSoftmax_=" << useFusedSoftmax_ << endl;
useTensorCores_ = Get<bool>("tensor-cores");