mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 22:14:57 +03:00
reuse Batch
This commit is contained in:
parent
9063ccd14e
commit
d9b2855cdd
@ -28,7 +28,7 @@ namespace NSBatch
|
||||
Search::Search(Manager &mgr)
|
||||
:Moses2::Search(mgr)
|
||||
, m_stacks(mgr)
|
||||
, m_batch(mgr.GetPool())
|
||||
, m_batch(mgr.system.GetBatch(mgr.GetSystemPool()))
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
protected:
|
||||
Stacks m_stacks;
|
||||
|
||||
Batch m_batch;
|
||||
Batch &m_batch;
|
||||
|
||||
void Decode(size_t stackInd);
|
||||
void Extend(const Hypothesis &hypo, const InputPath &path);
|
||||
|
@ -95,14 +95,12 @@ void System::LoadMappings()
|
||||
|
||||
MemPool &System::GetSystemPool() const
|
||||
{
|
||||
MemPool &ret = GetThreadSpecificObj(m_systemPool);
|
||||
return ret;
|
||||
return GetThreadSpecificObj(m_systemPool);
|
||||
}
|
||||
|
||||
MemPool &System::GetManagerPool() const
|
||||
{
|
||||
MemPool &ret = GetThreadSpecificObj(m_managerPool);
|
||||
return ret;
|
||||
return GetThreadSpecificObj(m_managerPool);
|
||||
}
|
||||
|
||||
FactorCollection &System::GetVocab() const
|
||||
@ -115,6 +113,18 @@ Recycler<HypothesisBase*> &System::GetHypoRecycler() const
|
||||
return GetThreadSpecificObj(m_hypoRecycler);
|
||||
}
|
||||
|
||||
Batch &System::GetBatch(MemPool &pool) const
|
||||
{
|
||||
Batch *obj;
|
||||
obj = m_batch.get();
|
||||
if (obj == NULL) {
|
||||
obj = new Batch(pool);
|
||||
m_batch.reset(obj);
|
||||
}
|
||||
assert(obj);
|
||||
return *obj;
|
||||
}
|
||||
|
||||
void System::IsPb()
|
||||
{
|
||||
switch (options.search.algo) {
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
|
||||
Recycler<HypothesisBase*> &GetHypoRecycler() const;
|
||||
|
||||
Batch &GetBatch(MemPool &pool) const;
|
||||
|
||||
protected:
|
||||
mutable FactorCollection m_vocab;
|
||||
mutable boost::thread_specific_ptr<MemPool> m_managerPool;
|
||||
@ -66,6 +68,8 @@ protected:
|
||||
|
||||
mutable boost::thread_specific_ptr<Recycler<HypothesisBase*> > m_hypoRecycler;
|
||||
|
||||
mutable boost::thread_specific_ptr<Batch> m_batch;
|
||||
|
||||
void LoadWeights();
|
||||
void LoadMappings();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user