ComponentPrecomputedIndexes Class Referenceabstract

#include <nnet-component-itf.h>

Inheritance diagram for ComponentPrecomputedIndexes:

Public Member Functions

virtual ComponentPrecomputedIndexesCopy () const =0
 
virtual void Write (std::ostream &os, bool binary) const =0
 
virtual void Read (std::istream &os, bool binary)=0
 
virtual std::string Type () const =0
 
virtual ~ComponentPrecomputedIndexes ()
 

Static Public Member Functions

static ComponentPrecomputedIndexesReadNew (std::istream &is, bool binary)
 
static ComponentPrecomputedIndexesNewComponentPrecomputedIndexesOfType (const std::string &cpi_type)
 

Detailed Description

Definition at line 97 of file nnet-component-itf.h.

Constructor & Destructor Documentation

◆ ~ComponentPrecomputedIndexes()

virtual ~ComponentPrecomputedIndexes ( )
inlinevirtual

Definition at line 107 of file nnet-component-itf.h.

107 { }

Member Function Documentation

◆ Copy()

◆ NewComponentPrecomputedIndexesOfType()

ComponentPrecomputedIndexes * NewComponentPrecomputedIndexesOfType ( const std::string &  cpi_type)
static

Definition at line 55 of file nnet-component-itf.cc.

References KALDI_ASSERT, and ComponentPrecomputedIndexes::Type().

Referenced by ComponentPrecomputedIndexes::ReadNew().

56  {
57  ComponentPrecomputedIndexes *ans = NULL;
58  if (cpi_type == "DistributeComponentPrecomputedIndexes") {
59  ans = new DistributeComponentPrecomputedIndexes();
60  } else if (cpi_type == "StatisticsExtractionComponentPrecomputedIndexes") {
61  ans = new StatisticsExtractionComponentPrecomputedIndexes();
62  } else if (cpi_type == "StatisticsPoolingComponentPrecomputedIndexes") {
63  ans = new StatisticsPoolingComponentPrecomputedIndexes();
64  } else if (cpi_type == "BackpropTruncationComponentPrecomputedIndexes") {
65  ans = new BackpropTruncationComponentPrecomputedIndexes();
66  } else if (cpi_type == "TimeHeightConvolutionComponentPrecomputedIndexes") {
67  ans = new TimeHeightConvolutionComponent::PrecomputedIndexes();
68  } else if (cpi_type == "RestrictedAttentionComponentPrecomputedIndexes") {
69  ans = new RestrictedAttentionComponent::PrecomputedIndexes();
70  } else if (cpi_type == "GeneralDropoutComponentPrecomputedIndexes") {
71  ans = new GeneralDropoutComponentPrecomputedIndexes();
72  } else if (cpi_type == "SpecAugmentTimeMaskComponentPrecomputedIndexes") {
73  ans = new SpecAugmentTimeMaskComponentPrecomputedIndexes();
74  } else if (cpi_type == "TdnnComponentPrecomputedIndexes") {
75  ans = new TdnnComponent::PrecomputedIndexes();
76  }
77  if (ans != NULL) {
78  KALDI_ASSERT(cpi_type == ans->Type());
79  }
80  return ans;
81 }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ Read()

◆ ReadNew()

ComponentPrecomputedIndexes * ReadNew ( std::istream &  is,
bool  binary 
)
static

Definition at line 42 of file nnet-component-itf.cc.

References KALDI_ERR, ComponentPrecomputedIndexes::NewComponentPrecomputedIndexesOfType(), ComponentPrecomputedIndexes::Read(), and kaldi::ReadToken().

Referenced by Component::PrecomputeIndexes(), and NnetComputation::Read().

43  {
44  std::string token;
45  ReadToken(is, binary, &token); // e.g. "<DistributePrecomputedComponentIndexes>".
46  token.erase(0, 1); // erase "<".
47  token.erase(token.length()-1); // erase ">".
48  ComponentPrecomputedIndexes *ans = NewComponentPrecomputedIndexesOfType(token);
49  if (!ans)
50  KALDI_ERR << "Unknown ComponentPrecomputedIndexes type " << token;
51  ans->Read(is, binary);
52  return ans;
53 }
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
Definition: io-funcs.cc:154
#define KALDI_ERR
Definition: kaldi-error.h:147
static ComponentPrecomputedIndexes * NewComponentPrecomputedIndexesOfType(const std::string &cpi_type)

◆ Type()

◆ Write()


The documentation for this class was generated from the following files: