use system pool for hypo

This commit is contained in:
Hieu Hoang 2016-01-05 16:58:27 +00:00
parent 749c531996
commit 197fd1b903
6 changed files with 11 additions and 7 deletions

View File

@ -46,7 +46,7 @@ void QueueItem::CreateHypothesis(Manager &mgr)
//cerr << prevHypo << endl;
//cerr << *prevHypo << endl;
hypo = Hypothesis::Create(mgr.system.GetSystemPool(), mgr);
hypo = Hypothesis::Create(mgr.GetSystemPool(), mgr);
hypo->Init(mgr, *prevHypo, edge->path, tp, edge->newBitmap, edge->estimatedScore);
hypo->EvaluateWhenApplied();
}

View File

@ -51,7 +51,7 @@ void Search::Decode()
}
const Bitmap &initBitmap = m_mgr.GetBitmaps().GetInitialBitmap();
Hypothesis *initHypo = Hypothesis::Create(m_mgr.system.GetSystemPool(), m_mgr);
Hypothesis *initHypo = Hypothesis::Create(m_mgr.GetSystemPool(), m_mgr);
initHypo->Init(m_mgr, m_mgr.GetInputPaths().GetBlank(), m_mgr.GetInitPhrase(), initBitmap);
initHypo->EmptyHypothesisState(m_mgr.GetInput());

View File

@ -45,6 +45,7 @@ void Manager::Init()
{
// init pools etc
m_pool = &system.GetManagerPool();
m_systemPool = &system.GetSystemPool();
m_hypoRecycle = &system.GetHypoRecycler();
m_initPhrase = new (GetPool().Allocate<TargetPhrase>()) TargetPhrase(GetPool(), system, 0);

View File

@ -42,6 +42,9 @@ public:
MemPool &GetPool() const
{ return *m_pool; }
MemPool &GetSystemPool() const
{ return *m_systemPool; }
Recycler<Hypothesis*> &GetHypoRecycle() const
{ return *m_hypoRecycle; }
@ -65,7 +68,7 @@ public:
void OutputBest() const;
protected:
mutable MemPool *m_pool;
mutable MemPool *m_pool, *m_systemPool;
mutable Recycler<Hypothesis*> *m_hypoRecycle;
std::string m_inputStr;

View File

@ -38,7 +38,7 @@ void SearchNormal::Decode()
m_stacks.Init(m_mgr.GetInput().GetSize() + 1);
const Bitmap &initBitmap = m_mgr.GetBitmaps().GetInitialBitmap();
Hypothesis *initHypo = Hypothesis::Create(m_mgr.system.GetSystemPool(), m_mgr);
Hypothesis *initHypo = Hypothesis::Create(m_mgr.GetSystemPool(), m_mgr);
initHypo->Init(m_mgr, m_mgr.GetInputPaths().GetBlank(), m_mgr.GetInitPhrase(), initBitmap);
initHypo->EmptyHypothesisState(m_mgr.GetInput());
@ -117,7 +117,7 @@ void SearchNormal::Extend(const Hypothesis &hypo,
const Bitmap &newBitmap,
SCORE estimatedScore)
{
Hypothesis *newHypo = Hypothesis::Create(m_mgr.system.GetSystemPool(), m_mgr);
Hypothesis *newHypo = Hypothesis::Create(m_mgr.GetSystemPool(), m_mgr);
newHypo->Init(m_mgr, hypo, path, tp, newBitmap, estimatedScore);
newHypo->EvaluateWhenApplied();

View File

@ -42,7 +42,7 @@ void SearchNormalBatch::Decode()
m_stacks.Init(m_mgr.GetInput().GetSize() + 1);
const Bitmap &initBitmap = m_mgr.GetBitmaps().GetInitialBitmap();
Hypothesis *initHypo = Hypothesis::Create(m_mgr.system.GetSystemPool(), m_mgr);
Hypothesis *initHypo = Hypothesis::Create(m_mgr.GetSystemPool(), m_mgr);
initHypo->Init(m_mgr, m_mgr.GetInputPaths().GetBlank(), m_mgr.GetInitPhrase(), initBitmap);
initHypo->EmptyHypothesisState(m_mgr.GetInput());
@ -150,7 +150,7 @@ void SearchNormalBatch::Extend(const Hypothesis &hypo,
const Bitmap &newBitmap,
SCORE estimatedScore)
{
Hypothesis *newHypo = Hypothesis::Create(m_mgr.system.GetSystemPool(), m_mgr);
Hypothesis *newHypo = Hypothesis::Create(m_mgr.GetSystemPool(), m_mgr);
newHypo->Init(m_mgr, hypo, path, tp, newBitmap, estimatedScore);
newHypo->EvaluateWhenAppliedNonBatch();