NnetComputation::MatrixInfo Struct Reference

#include <nnet-computation.h>

Collaboration diagram for NnetComputation::MatrixInfo:

Public Member Functions

 MatrixInfo ()
 MatrixInfo (int32 num_rows, int32 num_cols, MatrixStrideType stride_type)
void Read (std::istream &istream, bool binary)
void Write (std::ostream &ostream, bool binary) const

Public Attributes

int32 num_rows
int32 num_cols
MatrixStrideType stride_type

Detailed Description

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

Constructor & Destructor Documentation

◆ MatrixInfo() [1/2]

MatrixInfo ( )

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

308 { }

◆ MatrixInfo() [2/2]

Member Function Documentation

◆ Read()

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

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

References kaldi::nnet3::ExpectToken(), KALDI_ASSERT, kaldi::kDefaultStride, kaldi::kStrideEqualNumCols, kaldi::ReadBasicType(), and kaldi::ReadToken().

144  {
145  ExpectToken(is, binary, "<MatrixInfo>");
146  ExpectToken(is, binary, "<NumRows>");
147  ReadBasicType(is, binary, &num_rows);
148  ExpectToken(is, binary, "<NumCols>");
149  ReadBasicType(is, binary, &num_cols);
150  std::string tok;
151  ReadToken(is, binary, &tok);
152  if (tok == "</MatrixInfo>") {
154  } else {
155  KALDI_ASSERT(tok == "<StrideEqualNumCols>");
157  ExpectToken(is, binary, "</MatrixInfo>");
158  }
159 }
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)
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ Write()

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

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

References kaldi::kDefaultStride, kaldi::WriteBasicType(), and kaldi::WriteToken().

161  {
162  WriteToken(os, binary, "<MatrixInfo>");
163  if (!binary) os << std::endl;
164  WriteToken(os, binary, "<NumRows>");
165  WriteBasicType(os, binary, num_rows);
166  WriteToken(os, binary, "<NumCols>");
167  WriteBasicType(os, binary, num_cols);
169  WriteToken(os, binary, "<StrideEqualNumCols>");
170  if (!binary) os << std::endl;
171  WriteToken(os, binary, "</MatrixInfo>");
172  if (!binary) os << std::endl;
173 }
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 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

◆ num_cols

◆ num_rows

◆ stride_type

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