Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_best_hyps.h « common « amun « src - github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fcb388fff76f0508f67347fd109709ab3c933fb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <functional>
#include <vector>
#include <map>

#include "common/types.h"
#include "scorer.h"

namespace amunmt {

class God;

class BestHypsBase
{
  public:
    BestHypsBase(
        const God &god,
        bool forbidUNK,
        bool isInputFiltered,
        bool returnAttentionWeights,
        const std::map<std::string, float>& weights)
    : god_(god),
      forbidUNK_(forbidUNK),
      isInputFiltered_(isInputFiltered),
      returnAttentionWeights_(returnAttentionWeights),
      weights_(weights)
    {}

    BestHypsBase(const BestHypsBase&) = delete;

    virtual void CalcBeam(
        const Beam& prevHyps,
        const std::vector<ScorerPtr>& scorers,
        const Words& filterIndices,
        std::vector<Beam>& beams,
        std::vector<uint>& beamSizes) = 0;

  protected:
    const God &god_;
    const bool forbidUNK_;
    const bool isInputFiltered_;
    const bool returnAttentionWeights_;
    const std::map<std::string, float> weights_;

};

typedef std::shared_ptr<BestHypsBase> BestHypsBasePtr;

}