mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-06 19:49:41 +03:00
recycle recombined hypos
This commit is contained in:
parent
b93b13eabf
commit
9d5aff4b80
@ -19,6 +19,7 @@ using namespace std;
|
||||
|
||||
Manager::Manager(System &system, const std::string &inputStr)
|
||||
:m_pool(&system.GetManagerPool())
|
||||
,m_hypoRecycle(&system.GetHypoRecycle())
|
||||
,m_system(system)
|
||||
,m_initRange(NOT_FOUND, NOT_FOUND)
|
||||
,m_initPhrase(system.GetManagerPool(), system, 0)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <queue>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -29,6 +30,9 @@ public:
|
||||
MemPool &GetPool() const
|
||||
{ return *m_pool; }
|
||||
|
||||
std::queue<Hypothesis*> &GetHypoRecycle() const
|
||||
{ return *m_hypoRecycle; }
|
||||
|
||||
const System &GetSystem() const
|
||||
{ return m_system; }
|
||||
|
||||
@ -46,6 +50,7 @@ public:
|
||||
void Decode();
|
||||
protected:
|
||||
mutable MemPool *m_pool;
|
||||
mutable std::queue<Hypothesis*> *m_hypoRecycle;
|
||||
|
||||
const System &m_system;
|
||||
PhraseImpl *m_input;
|
||||
|
@ -98,9 +98,25 @@ void SearchNormal::Extend(const Hypothesis &hypo,
|
||||
|
||||
size_t numWordsCovered = newBitmap.GetNumWordsCovered();
|
||||
Stack &stack = m_stacks[numWordsCovered];
|
||||
StackAdd stackAdded = stack.Add(newHypo);
|
||||
StackAdd added = stack.Add(newHypo);
|
||||
|
||||
m_arcLists.AddArc(stackAdded.added, newHypo, stackAdded.other);
|
||||
std::queue<Hypothesis*> &hypoRecycle = m_mgr.GetHypoRecycle();
|
||||
|
||||
if (added.added) {
|
||||
// we're winners!
|
||||
if (added.other) {
|
||||
// there was a existing losing hypo
|
||||
hypoRecycle.push(added.other);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// we're losers!
|
||||
// there should be a winner, we're not doing beam pruning
|
||||
UTIL_THROW_IF2(added.other == NULL, "There must have been a winning hypo");
|
||||
hypoRecycle.push(newHypo);
|
||||
}
|
||||
|
||||
//m_arcLists.AddArc(stackAdded.added, newHypo, stackAdded.other);
|
||||
}
|
||||
|
||||
void SearchNormal::DebugStacks() const
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
protected:
|
||||
Manager &m_mgr;
|
||||
std::vector<Stack> &m_stacks;
|
||||
ArcLists m_arcLists;
|
||||
//ArcLists m_arcLists;
|
||||
size_t m_stackSize;
|
||||
|
||||
|
||||
|
@ -38,11 +38,11 @@ StackAdd Stack::Add(const Hypothesis *hypo)
|
||||
std::pair<iterator, bool> addRet = m_hypos.insert(hypo);
|
||||
assert(addRet.second);
|
||||
|
||||
return StackAdd(true, hypoExisting);
|
||||
return StackAdd(true, const_cast<Hypothesis*>(hypoExisting));
|
||||
}
|
||||
else {
|
||||
// already storing the best hypo. discard incoming hypo
|
||||
return StackAdd(false, hypoExisting);
|
||||
return StackAdd(false, const_cast<Hypothesis*>(hypoExisting));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ class StackAdd
|
||||
{
|
||||
public:
|
||||
bool added;
|
||||
const Hypothesis *other;
|
||||
Hypothesis *other;
|
||||
|
||||
StackAdd(bool vadded,
|
||||
const Hypothesis *vother)
|
||||
Hypothesis *vother)
|
||||
:added(vadded)
|
||||
,other(vother)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include "FF/FeatureFunctions.h"
|
||||
#include "Weights.h"
|
||||
@ -16,6 +17,7 @@
|
||||
class FeatureFunction;
|
||||
class StatefulFeatureFunction;
|
||||
class PhraseTable;
|
||||
class Hypothesis;
|
||||
|
||||
class System {
|
||||
public:
|
||||
@ -25,6 +27,9 @@ public:
|
||||
MemPool &GetManagerPool() const
|
||||
{ return m_managerPool; }
|
||||
|
||||
std::queue<Hypothesis*> &GetHypoRecycle() const
|
||||
{ return m_hypoRecycle; }
|
||||
|
||||
const Moses::Parameter ¶ms;
|
||||
mutable Moses::FactorCollection vocab;
|
||||
FeatureFunctions featureFunctions;
|
||||
@ -37,6 +42,7 @@ public:
|
||||
protected:
|
||||
|
||||
mutable MemPool m_managerPool;
|
||||
mutable std::queue<Hypothesis*> m_hypoRecycle;
|
||||
|
||||
void LoadWeights();
|
||||
void LoadMappings();
|
||||
|
Loading…
Reference in New Issue
Block a user