Download mosesdecoder/moses2/defer/CubePruningBitmapStack/Stack.h from sleepyhead111/vllm_fairseq: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/sleepyhead111/vllm_fairseq/resolve/main/mosesdecoder/moses2/defer/CubePruningBitmapStack/Stack.h
- Command line
-
hf download hf://sleepyhead111/vllm_fairseq/mosesdecoder/moses2/defer/CubePruningBitmapStack/Stack.h
-
curl -L -o Stack.h https://huggingface.co/sleepyhead111/vllm_fairseq/resolve/main/mosesdecoder/moses2/defer/CubePruningBitmapStack/Stack.h
2.14 kB
| /* | |
| * Stack.h | |
| * | |
| * Created on: 24 Oct 2015 | |
| * Author: hieu | |
| */ | |
| namespace Moses2 | |
| { | |
| class Manager; | |
| namespace NSCubePruningBitmapStack | |
| { | |
| typedef Vector<const Hypothesis*> Hypotheses; | |
| class MiniStack | |
| { | |
| public: | |
| typedef boost::unordered_set<const Hypothesis*, | |
| UnorderedComparer<Hypothesis>, | |
| UnorderedComparer<Hypothesis> | |
| > _HCType; | |
| MiniStack(const Manager &mgr); | |
| StackAdd Add(const Hypothesis *hypo); | |
| _HCType &GetColl() { | |
| return m_coll; | |
| } | |
| const _HCType &GetColl() const { | |
| return m_coll; | |
| } | |
| void Clear(); | |
| Hypotheses &GetSortedAndPruneHypos(const Manager &mgr) const; | |
| protected: | |
| _HCType m_coll; | |
| mutable Hypotheses *m_sortedHypos; | |
| void SortAndPruneHypos(const Manager &mgr) const; | |
| }; | |
| ///////////////////////////////////////////// | |
| class Stack | |
| { | |
| protected: | |
| public: | |
| typedef std::pair<const Bitmap*, size_t> HypoCoverage; | |
| // bitmap and current endPos of hypos | |
| typedef boost::unordered_map<HypoCoverage, Hypotheses*> SortedHypos; | |
| typedef const Bitmap* HypoCoverageInternal; | |
| typedef boost::unordered_map<HypoCoverageInternal, MiniStack* | |
| ,boost::hash<HypoCoverageInternal> | |
| ,std::equal_to<HypoCoverageInternal> | |
| > Coll; | |
| Stack(const Manager &mgr); | |
| virtual ~Stack(); | |
| size_t GetHypoSize() const; | |
| Coll &GetColl() { | |
| return m_coll; | |
| } | |
| const Coll &GetColl() const { | |
| return m_coll; | |
| } | |
| void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle); | |
| MiniStack &GetMiniStack(const HypoCoverageInternal &key); | |
| std::vector<const Hypothesis*> GetBestHypos(size_t num) const; | |
| void Clear(); | |
| SortedHypos GetSortedAndPruneHypos(const Manager &mgr) const; | |
| void SortAndPruneHypos(const Manager &mgr, Hypotheses &hypos) const; | |
| void DebugCounts(); | |
| protected: | |
| const Manager &m_mgr; | |
| Coll m_coll; | |
| std::deque<MiniStack*> m_miniStackRecycler; | |
| }; | |
| } | |
| } | |