StatisticsExtractionComponentPrecomputedIndexes Class Reference

#include <nnet-general-component.h>

Inheritance diagram for StatisticsExtractionComponentPrecomputedIndexes:
Collaboration diagram for StatisticsExtractionComponentPrecomputedIndexes:

Public Member Functions

ComponentPrecomputedIndexesCopy () const
 
virtual void Write (std::ostream &os, bool binary) const
 
virtual void Read (std::istream &is, bool binary)
 
virtual std::string Type () const
 
- Public Member Functions inherited from ComponentPrecomputedIndexes
virtual ~ComponentPrecomputedIndexes ()
 

Public Attributes

CuArray< Int32Pairforward_indexes
 
CuVector< BaseFloatcounts
 
CuArray< int32backward_indexes
 

Private Member Functions

virtual ~StatisticsExtractionComponentPrecomputedIndexes ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ComponentPrecomputedIndexes
static ComponentPrecomputedIndexesReadNew (std::istream &is, bool binary)
 
static ComponentPrecomputedIndexesNewComponentPrecomputedIndexesOfType (const std::string &cpi_type)
 

Detailed Description

Definition at line 276 of file nnet-general-component.h.

Constructor & Destructor Documentation

◆ ~StatisticsExtractionComponentPrecomputedIndexes()

virtual ~StatisticsExtractionComponentPrecomputedIndexes ( )
inlineprivatevirtual

Definition at line 304 of file nnet-general-component.h.

304 { }

Member Function Documentation

◆ Copy()

ComponentPrecomputedIndexes* Copy ( ) const
inlinevirtual

Implements ComponentPrecomputedIndexes.

Definition at line 294 of file nnet-general-component.h.

References DistributeComponent::Read(), and DistributeComponent::Write().

294  {
295  return new StatisticsExtractionComponentPrecomputedIndexes(*this);
296  }

◆ Read()

void Read ( std::istream &  is,
bool  binary 
)
virtual

Implements ComponentPrecomputedIndexes.

Definition at line 272 of file nnet-general-component.cc.

References kaldi::nnet3::CopyPairVector(), kaldi::ExpectOneOrTwoTokens(), kaldi::nnet3::ExpectToken(), kaldi::ReadIntegerPairVector(), and kaldi::ReadIntegerVector().

272  {
273  ExpectOneOrTwoTokens(is, binary,
274  "<StatisticsExtractionComponentPrecomputedIndexes>",
275  "<ForwardIndexes>");
276  std::vector<std::pair<int32, int32> > pairs_cpu;
277  ReadIntegerPairVector(is, binary, &pairs_cpu);
278  CopyPairVector(pairs_cpu, &forward_indexes);
279  ExpectToken(is, binary, "<Counts>");
280  counts.Read(is, binary);
281  ExpectToken(is, binary, "<BackwardIndexes>");
282  std::vector<int32> backward_indexes_cpu;
283  ReadIntegerVector(is, binary, &backward_indexes_cpu);
284  backward_indexes.CopyFromVec(backward_indexes_cpu);
285  ExpectToken(is, binary, "</StatisticsExtractionComponentPrecomputedIndexes>");
286 }
void CopyFromVec(const std::vector< T > &src)
This function resizes if needed.
Definition: cu-array-inl.h:120
static void CopyPairVector(const CuArray< Int32Pair > &in, std::vector< std::pair< int32, int32 > > *out)
void ReadIntegerPairVector(std::istream &is, bool binary, std::vector< std::pair< T, T > > *v)
Function for reading STL vector of pairs of integer types.
Definition: io-funcs-inl.h:131
void ExpectOneOrTwoTokens(std::istream &is, bool binary, const std::string &token1, const std::string &token2)
This function is like ExpectToken but for two tokens, and it will either accept token1 and then token...
Definition: text-utils.cc:536
void ReadIntegerVector(std::istream &is, bool binary, std::vector< T > *v)
Function for reading STL vector of integer types.
Definition: io-funcs-inl.h:232
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)

◆ Type()

virtual std::string Type ( ) const
inlinevirtual

Implements ComponentPrecomputedIndexes.

Definition at line 302 of file nnet-general-component.h.

302 { return "StatisticsExtractionComponentPrecomputedIndexes"; }

◆ Write()

void Write ( std::ostream &  os,
bool  binary 
) const
virtual

Implements ComponentPrecomputedIndexes.

Definition at line 257 of file nnet-general-component.cc.

References kaldi::nnet3::CopyPairVector(), kaldi::WriteIntegerPairVector(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().

257  {
258  WriteToken(os, binary, "<StatisticsExtractionComponentPrecomputedIndexes>");
259  WriteToken(os, binary, "<ForwardIndexes>");
260  std::vector<std::pair<int32, int32> > pairs_cpu;
261  CopyPairVector(forward_indexes, &pairs_cpu);
262  WriteIntegerPairVector(os, binary, pairs_cpu);
263  WriteToken(os, binary, "<Counts>");
264  counts.Write(os, binary);
265  WriteToken(os, binary, "<BackwardIndexes>");
266  std::vector<int32> backward_indexes_cpu;
267  backward_indexes.CopyToVec(&backward_indexes_cpu);
268  WriteIntegerVector(os, binary, backward_indexes_cpu);
269  WriteToken(os, binary, "</StatisticsExtractionComponentPrecomputedIndexes>");
270 }
void WriteIntegerPairVector(std::ostream &os, bool binary, const std::vector< std::pair< T, T > > &v)
Function for writing STL vectors of pairs of integer types.
Definition: io-funcs-inl.h:93
void CopyToVec(std::vector< T > *dst) const
This function resizes *dst if needed.
Definition: cu-array-inl.h:177
static void CopyPairVector(const CuArray< Int32Pair > &in, std::vector< std::pair< int32, int32 > > *out)
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
void WriteIntegerVector(std::ostream &os, bool binary, const std::vector< T > &v)
Function for writing STL vectors of integer types.
Definition: io-funcs-inl.h:198

Member Data Documentation

◆ backward_indexes

◆ counts

◆ forward_indexes


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