Skip to content

Commit

Permalink
can prune stack < max stack size
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuhoang committed Dec 7, 2016
1 parent 883f2e4 commit ab28a3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions contrib/moses2/HypothesisColl.cpp
Expand Up @@ -242,8 +242,8 @@ void HypothesisColl::PruneHypos(const ManagerBase &mgr, ArcLists &arcLists)
void HypothesisColl::PruneHypos(const ManagerBase &mgr, ArcLists &arcLists, const HypothesisBase **sortedHypos) const
{
size_t maxStackSize = mgr.system.options.search.stack_size;
assert(maxStackSize); // can't do stack=0 - unlimited stack size. No-one ever uses that
assert(GetSize() > maxStackSize);
//assert(maxStackSize); // can't do stack=0 - unlimited stack size. No-one ever uses that
//assert(GetSize() > maxStackSize);
//assert(sortedHypos.size() == GetSize());

/*
Expand All @@ -259,7 +259,19 @@ void HypothesisColl::PruneHypos(const ManagerBase &mgr, ArcLists &arcLists, cons
++ind;
}

const HypothesisBase **iterMiddle = sortedHypos + maxStackSize;
size_t indMiddle;
if (maxStackSize == 0) {
indMiddle = GetSize();
}
else if (GetSize() > maxStackSize) {
indMiddle = maxStackSize;
}
else {
// GetSize() <= maxStackSize
indMiddle = GetSize();
}

const HypothesisBase **iterMiddle = sortedHypos + indMiddle;

std::partial_sort(
sortedHypos,
Expand Down
2 changes: 1 addition & 1 deletion contrib/moses2/legacy/Parameter.cpp
Expand Up @@ -84,7 +84,7 @@ Parameter::Parameter()
//AddParam(search_opts, "early-discarding-threshold", "edt",
// "threshold for constructing hypotheses based on estimate cost");
AddParam(search_opts, "stack", "s",
"maximum stack size for histogram pruning. CANNOT USE 0 = unlimited stack size");
"maximum stack size for histogram pruning. 0 = unlimited stack size");
//AddParam(search_opts, "stack-diversity", "sd",
// "minimum number of hypothesis of each coverage in stack (default 0)");

Expand Down

0 comments on commit ab28a3f

Please sign in to comment.