All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ComponentPrecomputedIndexes Class Referenceabstract

#include <nnet-component-itf.h>

Inheritance diagram for ComponentPrecomputedIndexes:

Public Member Functions

virtual
ComponentPrecomputedIndexes
Copy () 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
ComponentPrecomputedIndexes
ReadNew (std::istream &is, bool binary)
 
static
ComponentPrecomputedIndexes
NewComponentPrecomputedIndexesOfType (const std::string &cpi_type)
 

Detailed Description

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

Constructor & Destructor Documentation

virtual ~ComponentPrecomputedIndexes ( )
inlinevirtual

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

115 { }

Member Function Documentation

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

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

References KALDI_ASSERT, and ComponentPrecomputedIndexes::Type().

Referenced by ComponentPrecomputedIndexes::ReadNew().

54  {
55  ComponentPrecomputedIndexes *ans = NULL;
56  if (cpi_type == "DistributeComponentPrecomputedIndexes") {
57  ans = new DistributeComponentPrecomputedIndexes();
58  } else if (cpi_type == "StatisticsExtractionComponentPrecomputedIndexes") {
59  ans = new StatisticsExtractionComponentPrecomputedIndexes();
60  } else if (cpi_type == "StatisticsPoolingComponentPrecomputedIndexes") {
61  ans = new StatisticsPoolingComponentPrecomputedIndexes();
62  } else if (cpi_type == "BackpropTruncationComponentPrecomputedIndexes") {
63  ans = new BackpropTruncationComponentPrecomputedIndexes();
64  } else if (cpi_type == "TimeHeightConvolutionComponentPrecomputedIndexes") {
65  ans = new TimeHeightConvolutionComponent::PrecomputedIndexes();
66  } else if (cpi_type == "RestrictedAttentionComponentPrecomputedIndexes") {
67  ans = new RestrictedAttentionComponent::PrecomputedIndexes();
68  }
69  if (ans != NULL) {
70  KALDI_ASSERT(cpi_type == ans->Type());
71  }
72  return ans;
73 }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
ComponentPrecomputedIndexes * ReadNew ( std::istream &  is,
bool  binary 
)
static

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

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

Referenced by NnetComputation::Read().

41  {
42  std::string token;
43  ReadToken(is, binary, &token); // e.g. "<DistributePrecomputedComponentIndexes>".
44  token.erase(0, 1); // erase "<".
45  token.erase(token.length()-1); // erase ">".
46  ComponentPrecomputedIndexes *ans = NewComponentPrecomputedIndexesOfType(token);
47  if (!ans)
48  KALDI_ERR << "Unknown ComponentPrecomputedIndexes type " << token;
49  ans->Read(is, binary);
50  return ans;
51 }
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:127
static ComponentPrecomputedIndexes * NewComponentPrecomputedIndexesOfType(const std::string &cpi_type)

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