IoSpecification Struct Reference

#include <nnet-computation.h>

Collaboration diagram for IoSpecification:

Public Member Functions

 IoSpecification ()
 
 IoSpecification (const IoSpecification &other)
 
 IoSpecification (const std::string &name, const std::vector< Index > &indexes, bool has_deriv=false)
 
 IoSpecification (const std::string &name, int32 t_start, int32 t_end)
 
void Print (std::ostream &os) const
 This function is for printing in a human-readable way, for debugging. More...
 
void Swap (IoSpecification *other)
 
void Read (std::istream &istream, bool binary)
 
void Write (std::ostream &ostream, bool binary) const
 
bool operator== (const IoSpecification &other) const
 

Public Attributes

std::string name
 
std::vector< Indexindexes
 
bool has_deriv
 

Detailed Description

Definition at line 72 of file nnet-computation.h.

Constructor & Destructor Documentation

◆ IoSpecification() [1/4]

IoSpecification ( )
inline

Definition at line 78 of file nnet-computation.h.

◆ IoSpecification() [2/4]

IoSpecification ( const IoSpecification other)
inline

Definition at line 80 of file nnet-computation.h.

80  :
81  name(other.name), indexes(other.indexes), has_deriv(other.has_deriv) { }
std::vector< Index > indexes

◆ IoSpecification() [3/4]

IoSpecification ( const std::string &  name,
const std::vector< Index > &  indexes,
bool  has_deriv = false 
)
inline

◆ IoSpecification() [4/4]

IoSpecification ( const std::string &  name,
int32  t_start,
int32  t_end 
)

Definition at line 1114 of file nnet-computation.cc.

References IoSpecification::indexes.

1115  :
1116  name(name), indexes(std::max<int32>(0, t_end - t_start)),
1117  has_deriv(false) {
1118  // the n and x values will already be 0 in "indexes" because
1119  // the default constructor does that; so just set the t values.
1120  std::vector<Index>::iterator iter = indexes.begin(), end = indexes.end();
1121  for (int32 t = t_start; iter != end; ++iter, ++t)
1122  iter->t = t;
1123 }
kaldi::int32 int32
std::vector< Index > indexes

Member Function Documentation

◆ operator==()

bool operator== ( const IoSpecification other) const

Definition at line 1109 of file nnet-computation.cc.

References IoSpecification::has_deriv, IoSpecification::indexes, and IoSpecification::name.

1109  {
1110  return (name == other.name && indexes == other.indexes &&
1111  has_deriv == other.has_deriv);
1112 }
std::vector< Index > indexes

◆ Print()

void Print ( std::ostream &  os) const

This function is for printing in a human-readable way, for debugging.

Output ends in a newline.

Definition at line 993 of file nnet-computation.cc.

References kaldi::nnet3::PrintIndexes().

993  {
994  os << "name=" << name << ", has-deriv=" << (has_deriv ? "true" : "false" )
995  << ", indexes=";
996  PrintIndexes(os, indexes);
997  os << "\n";
998 }
void PrintIndexes(std::ostream &os, const std::vector< Index > &indexes)
this will only be used for pretty-printing.
Definition: nnet-common.cc:442
std::vector< Index > indexes

◆ Read()

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

Definition at line 1006 of file nnet-computation.cc.

References kaldi::nnet3::ExpectToken(), kaldi::ReadBasicType(), kaldi::nnet3::ReadIndexVector(), and kaldi::ReadToken().

1006  {
1007  ExpectToken(is, binary, "<IoSpecification>");
1008  ReadToken(is, binary, &name);
1009  ExpectToken(is, binary, "<NumIndexes>");
1010  size_t num_indexes;
1011  ReadBasicType(is, binary, &num_indexes);
1012  ExpectToken(is, binary, "<Indexes>");
1013  ReadIndexVector(is, binary, &indexes);
1014  ExpectToken(is, binary, "<HasDeriv>");
1015  ReadBasicType(is, binary, &has_deriv);
1016  ExpectToken(is, binary, "</IoSpecification>");
1017 }
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
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
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)
void ReadIndexVector(std::istream &is, bool binary, std::vector< Index > *vec)
Definition: nnet-common.cc:143
std::vector< Index > indexes

◆ Swap()

void Swap ( IoSpecification other)

Definition at line 1000 of file nnet-computation.cc.

References IoSpecification::has_deriv, IoSpecification::indexes, IoSpecification::name, and kaldi::swap().

1000  {
1001  name.swap(other->name);
1002  indexes.swap(other->indexes);
1003  std::swap(has_deriv, other->has_deriv);
1004 }
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
std::vector< Index > indexes

◆ Write()

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

Definition at line 1019 of file nnet-computation.cc.

References kaldi::WriteBasicType(), kaldi::nnet3::WriteIndexVector(), and kaldi::WriteToken().

1019  {
1020  WriteToken(os, binary, "<IoSpecification>");
1021  if (!binary) os << std::endl;
1022  WriteToken(os, binary, name);
1023  WriteToken(os, binary, "<NumIndexes>");
1024  WriteBasicType(os, binary, indexes.size());
1025  WriteToken(os, binary, "<Indexes>");
1026  WriteIndexVector(os, binary, indexes);
1027  WriteToken(os, binary, "<HasDeriv>");
1028  WriteBasicType(os, binary, has_deriv);
1029  if (!binary) os << std::endl;
1030  WriteToken(os, binary, "</IoSpecification>");
1031  if (!binary) os << std::endl;
1032 }
void WriteIndexVector(std::ostream &os, bool binary, const std::vector< Index > &vec)
Definition: nnet-common.cc:126
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
std::vector< Index > indexes
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:34

Member Data Documentation

◆ has_deriv

◆ indexes

◆ name


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