33 for (
size_t i = 0;
i <
inputs.size();
i++) {
43 for (i = 0; i <
outputs.size(); i++)
47 KALDI_ERR <<
"You requested model derivatives or input derivatives, but " 48 <<
"provide no derivatives at the output.";
55 const std::string &node_name)
const {
57 for (
size_t i = 0;
i <
inputs.size();
i++) {
58 if (
inputs[
i].name == node_name) {
59 KALDI_ASSERT(ans == -1 &&
"Two inputs with the same name");
67 const std::string &node_name)
const {
71 KALDI_ASSERT(ans == -1 &&
"Two inputs with the same name");
80 for (
size_t i = 1;
i < component_precomputed_indexes.size();
i++)
81 delete component_precomputed_indexes[
i].data;
85 indexes_cuda.resize(indexes.size());
87 for (
size_t i = 0;
i < indexes.size();
i++)
88 indexes_cuda[
i].CopyFromVec(indexes[
i]);
91 indexes_ranges_cuda.resize(indexes_ranges.size());
92 for (
int32 i = 0; i < indexes_ranges.size(); i++) {
93 const std::vector<std::pair<int32,int32> > *input = &(indexes_ranges[
i]);
94 const std::vector<Int32Pair> *input_cast =
95 reinterpret_cast<const std::vector<Int32Pair> *
>(input);
98 indexes_ranges_cuda[
i].CopyFromVec(*input_cast);
106 static_cast<size_t>(base_submatrix) < submatrices.size());
107 const SubMatrixInfo &base_info = submatrices[base_submatrix];
110 static_cast<size_t>(base_matrix) < matrices.size());
112 num_rows = base_info.num_rows - row_offset;
114 num_cols = base_info.num_cols - col_offset;
115 KALDI_ASSERT(row_offset + num_rows <= base_info.num_rows &&
116 col_offset + num_cols <= base_info.num_cols &&
117 row_offset >= 0 && col_offset >= 0 &&
118 num_rows > 0 && num_cols > 0);
119 int32 matrix_row_offset = base_info.row_offset + row_offset,
120 matrix_col_offset = base_info.col_offset + col_offset;
121 int32 ans = submatrices.size();
122 submatrices.push_back(
124 matrix_col_offset, num_cols));
131 if (matrices.empty()) {
135 int32 matrix_index = matrices.size(),
136 submatrix_index = submatrices.size();
137 matrices.push_back(
MatrixInfo(num_rows, num_cols, stride_type));
138 if (!matrix_debug_info.empty())
140 submatrices.push_back(
SubMatrixInfo(matrix_index, 0, num_rows, 0, num_cols));
141 return submatrix_index;
152 if (tok ==
"</MatrixInfo>") {
163 if (!binary) os << std::endl;
169 WriteToken(os, binary,
"<StrideEqualNumCols>");
170 if (!binary) os << std::endl;
172 if (!binary) os << std::endl;
192 if (!binary) os << std::endl;
195 if (!binary) os << std::endl;
198 if (!binary) os << std::endl;
200 if (!binary) os << std::endl;
220 if (!binary) os << std::endl;
231 if (!binary) os << std::endl;
233 if (!binary) os << std::endl;
239 int32 command_type_int;
241 command_type =
static_cast<CommandType>(command_type_int);
243 std::vector<int32> args;
247 std::copy(args.begin(), args.end(), dest);
251 std::string command_type_str;
252 getline(is, command_type_str);
253 if (command_type_str ==
"kAllocMatrix") {
255 }
else if (command_type_str ==
"kDeallocMatrix") {
257 }
else if (command_type_str ==
"kSwapMatrix") {
259 }
else if (command_type_str ==
"kSetConst") {
261 }
else if (command_type_str ==
"kPropagate") {
263 }
else if (command_type_str ==
"kBackprop") {
265 }
else if (command_type_str ==
"kBackpropNoModelUpdate") {
267 }
else if (command_type_str ==
"kMatrixCopy") {
269 }
else if (command_type_str ==
"kMatrixAdd") {
271 }
else if (command_type_str ==
"kCopyRows") {
273 }
else if (command_type_str ==
"kAddRows") {
275 }
else if (command_type_str ==
"kCopyRowsMulti") {
277 }
else if (command_type_str ==
"kCopyToRowsMulti") {
279 }
else if (command_type_str ==
"kAddRowsMulti") {
281 }
else if (command_type_str ==
"kAddToRowsMulti") {
283 }
else if (command_type_str ==
"kAddRowRanges") {
285 }
else if (command_type_str ==
"kCompressMatrix") {
287 }
else if (command_type_str ==
"kDecompressMatrix") {
289 }
else if (command_type_str ==
"kAcceptInput") {
291 }
else if (command_type_str ==
"kProvideOutput") {
293 }
else if (command_type_str ==
"kNoOperation") {
295 }
else if (command_type_str ==
"kNoOperationPermanent") {
297 }
else if (command_type_str ==
"kNoOperationMarker") {
299 }
else if (command_type_str ==
"kNoOperationLabel") {
301 }
else if (command_type_str ==
"kGotoLabel") {
325 std::vector<int32> args;
326 const int32 *src = &arg1;
327 args.insert(args.end(), src, src + 7);
328 while (!args.empty() && args.back() == -1)
332 std::string command_type_str;
333 switch (command_type) {
335 os <<
"kAllocMatrix\n";
338 os <<
"kDeallocMatrix\n";
341 os <<
"kSwapMatrix\n";
347 os <<
"kPropagate\n";
353 os <<
"kBackpropNoModelUpdate\n";
356 os <<
"kMatrixCopy\n";
359 os <<
"kMatrixAdd\n";
368 os <<
"kCopyRowsMulti\n";
371 os <<
"kCopyToRowsMulti\n";
374 os <<
"kAddRowsMulti\n";
377 os <<
"kAddToRowsMulti\n";
380 os <<
"kAddRowRanges\n";
383 os <<
"kCompressMatrix\n";
386 os <<
"kDecompressMatrix\n";
389 os <<
"kAcceptInput\n";
392 os <<
"kProvideOutput\n";
395 os <<
"kNoOperation\n";
398 os <<
"kNoOperationPermanent\n";
401 os <<
"kNoOperationMarker\n";
404 os <<
"kNoOperationLabel\n";
407 os <<
"kGotoLabel\n";
412 os <<
"<Alpha> " << alpha <<
" ";
413 os <<
"<Args> " << arg1 <<
' ' << arg2 <<
' ' 414 << arg3 <<
' ' << arg4 <<
' ' << arg5 <<
' ' 415 << arg6 <<
' ' << arg7 <<
' ';
425 const Nnet &nnet, std::vector<std::string> *submat_strings)
const {
426 int32 num_submatrices = this->submatrices.size();
428 submat_strings->resize(num_submatrices);
429 (*submat_strings)[0] =
"[]";
430 for (
int32 i = 1;
i < num_submatrices;
i++) {
432 std::ostringstream os;
433 if (this->IsWholeMatrix(
i)) {
441 (*submat_strings)[
i] = os.str();
450 std::vector<std::string> *indexes_strings) {
452 indexes_strings->resize(size);
454 std::ostringstream os;
456 (*indexes_strings)[
i] = os.str();
465 std::vector<std::string> *indexes_multi_strings) {
467 indexes_multi_strings->resize(indexes_multi_size);
469 for (
int32 i = 0;
i < indexes_multi_size;
i++) {
470 std::ostringstream os;
472 const std::vector<std::pair<int32, int32> > &vec =
474 int32 size = vec.size();
476 int32 submat_index = vec[
j].first, row_index = vec[
j].second;
477 if (submat_index == -1) {
486 col_end = col_start + submat.
num_cols;
487 if (!(row_index < submat.
num_rows &&
489 KALDI_WARN <<
"Invalid indexes in indexes-multi[" <<
i 490 <<
": submatrix " << submat_index <<
" = m" 495 << submat.
num_rows <<
" rows, but you access row " 498 if (col_start == 0 && col_end == mat.
num_cols)
499 os <<
'm' << submat.
matrix_index <<
'(' << row <<
",:)";
501 os <<
'm' << submat.
matrix_index <<
'(' << row <<
',' << col_start
502 <<
':' << (col_end - 1) <<
')';
504 if (
j + 1 < size) os <<
",";
507 (*indexes_multi_strings)[
i] = os.str();
517 const std::vector<std::string> &submatrix_strings,
518 const std::vector<std::string> &indexes_strings,
519 const std::vector<std::string> &indexes_multi_strings) {
522 size_t max_string_length = 200;
523 std::ostringstream os;
525 os <<
"c" << command_index <<
": ";
529 os << submatrix_strings[c.
arg1] <<
" = undefined(" 534 os << submatrix_strings[c.
arg1] <<
" = []\n";
537 os << submatrix_strings[c.
arg1] <<
".swap(" 538 << submatrix_strings[c.
arg2] <<
") [dim = " 543 os << submatrix_strings[c.
arg1] <<
".set(" << c.
alpha <<
") [dim = " 549 if (c.
arg2 == 0) os <<
"NULL, ";
550 else os <<
"precomputed_indexes[" << c.
arg2 <<
"], ";
551 os << submatrix_strings[c.
arg3] <<
", &" << submatrix_strings[c.
arg4]
558 if (c.
arg2 == 0) os <<
"NULL, ";
559 else os <<
"precomputed_indexes[" << c.
arg2 <<
"], ";
560 os << submatrix_strings[c.
arg3] <<
", " 561 << submatrix_strings[c.
arg4] <<
", " 562 << submatrix_strings[c.
arg5] <<
", " 565 "[component-pointer], " :
"NULL, ")
566 << (c.
arg6 == 0 ? std::string(
"NULL") :
567 std::string(
"&") + submatrix_strings[c.
arg6]) <<
")\n";
571 if (c.
alpha == 1.0) {
572 os << submatrix_strings[c.
arg1] <<
" = " 573 << submatrix_strings[c.
arg2] <<
"\n";
575 os << submatrix_strings[c.
arg1] <<
" = " 577 << submatrix_strings[c.
arg2] <<
"\n";
581 if (c.
alpha == 1.0) {
582 os << submatrix_strings[c.
arg1] <<
" += " 583 << submatrix_strings[c.
arg2] <<
"\n";
585 os << submatrix_strings[c.
arg1] <<
" += " 587 << submatrix_strings[c.
arg2] <<
"\n";
592 os << submatrix_strings[c.
arg1] <<
"." 594 "CopyRows") <<
"(" << c.
alpha <<
", " 595 << submatrix_strings[c.
arg2] << indexes_strings[c.
arg3] <<
")\n";
602 os << submatrix_strings[c.
arg1] <<
"." 606 "CopyToRowsMulti"))) <<
"(" 608 << indexes_multi_strings[c.
arg2] <<
")\n";
612 os << submatrix_strings[c.
arg1] <<
".AddRowRanges(" 614 << submatrix_strings[c.
arg2] <<
", [";
615 const std::vector<std::pair<int32, int32> > &pairs =
617 for (
size_t i = 0;
i < pairs.size();
i++) {
618 if (pairs[
i].first == -1) {
621 os << pairs[
i].first <<
":" << (pairs[
i].second - 1);
623 if (
i + 1 < pairs.size()) os <<
",";
630 std::string truncate = (c.
arg3 != 0 ?
"true" :
"false");
631 std::string compressed_matrix_type;
637 compressed_matrix_type =
"uint16";
639 os <<
"CompressMatrix(" << submatrix_strings[c.
arg1] <<
", " 640 << range <<
", " << compressed_matrix_type <<
", " 641 << truncate <<
")\n";
645 os <<
"DecompressMatrix(" << submatrix_strings[c.
arg1] <<
")\n";
648 os << submatrix_strings[c.
arg1] <<
" = user input [for node: '" 652 os <<
"output " << submatrix_strings[c.
arg1] <<
" to user" 659 os <<
"[no-op-permanent]\n";
662 os <<
"# computation segment separator [e.g., begin backward commands]\n";
665 os <<
"[label for goto statement]\n";
668 os <<
"goto c" << c.
arg1 <<
"\n";
673 std::string str = os.str();
674 if (str.size() <= max_string_length) {
677 size_t len = str.size();
678 os_out << str.substr(0, max_string_length / 2) <<
" ... " 679 << str.substr(len - max_string_length / 2);
688 const std::vector<std::string> &submatrix_strings,
689 const std::vector<std::string> &indexes_strings,
690 const std::vector<std::string> &indexes_multi_strings) {
695 os <<
"m" <<
i <<
"(" << c.
matrices[
i].num_rows
696 <<
", " << c.
matrices[
i].num_cols <<
")";
702 os <<
"# The following show how matrices correspond to network-nodes and\n" 703 <<
"# cindex-ids. Format is: matrix = <node-id>.[value|deriv][ <list-of-cindex-ids> ]\n" 704 <<
"# where a cindex-id is written as (n,t[,x]) but ranges of t values are compressed\n" 705 <<
"# so we write (n, tfirst:tlast).\n";
710 os <<
"m" <<
i <<
" == " << (debug_info.
is_deriv ?
"deriv: " :
"value: ");
718 std::vector<std::string> submatrix_strings, indexes_strings,
719 indexes_multi_strings;
720 this->GetSubmatrixStrings(nnet, &submatrix_strings);
724 indexes_strings, indexes_multi_strings);
725 os <<
"# begin forward commands\n";
726 for (
int32 c = 0; c < commands.size(); c++) {
728 indexes_strings, indexes_multi_strings);
739 if (token ==
"<Version>") {
745 if (version_in != version) {
746 KALDI_ERR <<
"Reading NnetComputation failed because version in " 747 << version_in <<
" != " << version <<
"... you can " 748 <<
"ignore this error if the program continues afterward, " 749 <<
"it would only affect speed.";
754 matrices.resize(num_matrices);
756 for (
size_t c = 0; c < num_matrices; c++) {
757 matrices[c].Read(is, binary);
760 size_t num_matrix_debug_info;
764 matrix_debug_info.resize(num_matrix_debug_info);
766 for (
size_t c = 0; c < num_matrix_debug_info; c++) {
767 matrix_debug_info[c].Read(is, binary);
770 size_t num_submatrices;
774 submatrices.resize(num_submatrices);
776 for (
size_t c = 0; c < num_submatrices; c++) {
777 submatrices[c].Read(is, binary);
783 for (
size_t i = 1;
i < component_precomputed_indexes.size();
i++)
784 delete component_precomputed_indexes[
i].data;
785 component_precomputed_indexes.clear();
787 size_t num_component_precomputed_indexes;
788 ExpectToken(is, binary,
"<NumComponentPrecomputedIndexes>");
789 ReadBasicType(is, binary, &num_component_precomputed_indexes);
791 component_precomputed_indexes.resize(num_component_precomputed_indexes);
795 if (tok ==
"<ComponentPrecomputedIndexes>") {
798 component_precomputed_indexes.clear();
799 component_precomputed_indexes.resize(num_component_precomputed_indexes);
800 for (
size_t c = 0; c < num_component_precomputed_indexes; c++) {
805 component_precomputed_indexes[c].data = p;
810 for (
size_t c = 1; c < num_component_precomputed_indexes; c++) {
823 indexes.resize(num_indexes);
825 for (
size_t c = 0; c < num_indexes; c++) {
829 size_t num_indexes_multi;
833 indexes_multi.resize(num_indexes_multi);
835 for (
size_t c = 0; c < num_indexes_multi; c++) {
839 size_t num_indexes_ranges;
843 indexes_ranges.resize(num_indexes_ranges);
845 for (
size_t c = 0; c < num_indexes_ranges; c++) {
853 commands.resize(num_commands);
855 for (
size_t c = 0; c < num_commands; c++) {
856 commands[c].Read(is, binary);
862 ComputeCudaIndexes();
874 for (
size_t c = 0; c < matrices.size(); c++) {
875 matrices[c].Write(os, binary);
878 if (!binary) os << std::endl;
879 WriteToken(os, binary,
"<NumMatrixDebugInfo>");
882 for (
size_t c = 0; c < matrix_debug_info.size(); c++) {
883 matrix_debug_info[c].Write(os, binary);
886 if (!binary) os << std::endl;
890 for (
size_t c = 0; c < submatrices.size(); c++) {
891 submatrices[c].Write(os, binary);
894 if (!binary) os << std::endl;
895 WriteToken(os, binary,
"<NumComponentPrecomputedIndexes>");
897 WriteToken(os, binary,
"<PrecomputedIndexesInfo>");
898 for (
size_t c = 1; c < component_precomputed_indexes.size(); c++) {
905 if (!binary) os << std::endl;
909 for (
size_t c = 0; c < indexes.size(); c++) {
913 if (!binary) os << std::endl;
917 for (
size_t c = 0; c < indexes_multi.size(); c++) {
921 if (!binary) os << std::endl;
925 for (
size_t c = 0; c < indexes_ranges.size(); c++) {
929 if (!binary) os << std::endl;
933 for (
size_t c = 0; c < commands.size(); c++) {
934 commands[c].Write(os, binary);
937 if (!binary) os << std::endl;
938 WriteToken(os, binary,
"<NeedModelDerivative>");
941 if (!binary) os << std::endl;
946 std::string *preamble,
947 std::vector<std::string> *command_strings)
const {
948 std::vector<std::string> submatrix_strings, indexes_strings,
949 indexes_multi_strings;
950 this->GetSubmatrixStrings(nnet, &submatrix_strings);
953 if (preamble != NULL) {
954 std::ostringstream os;
956 indexes_strings, indexes_multi_strings);
957 *preamble = os.str();
959 if (command_strings != NULL) {
960 command_strings->resize(commands.size());
961 for (
int32 c = 0; c < commands.size(); c++) {
962 std::ostringstream os;
964 indexes_strings, indexes_multi_strings);
965 (*command_strings)[c] = os.str();
967 std::string &str = (*command_strings)[c];
969 str.resize(str.size() - 1);
976 KALDI_ASSERT(submatrix_index > 0 && submatrix_index < submatrices.size());
977 const SubMatrixInfo &submat_info = submatrices[submatrix_index];
978 const MatrixInfo &mat_info = matrices[submat_info.matrix_index];
979 return submat_info.row_offset == 0 && submat_info.col_offset == 0 &&
981 submat_info.num_cols == mat_info.
num_cols;
994 os <<
"name=" << name <<
", has-deriv=" << (has_deriv ?
"true" :
"false" )
1001 name.swap(other->
name);
1021 if (!binary) os << std::endl;
1029 if (!binary) os << std::endl;
1030 WriteToken(os, binary,
"</IoSpecification>");
1031 if (!binary) os << std::endl;
1040 inputs.resize(num_inputs);
1042 for (
size_t c = 0; c < num_inputs; c++) {
1043 inputs[c].Read(is, binary);
1052 for (
size_t c = 0; c < num_outputs; c++) {
1064 WriteToken(os, binary,
"<ComputationRequest>");
1065 if (!binary) os << std::endl;
1068 if (!binary) os << std::endl;
1070 for (
size_t c = 0; c <
inputs.size(); c++) {
1071 inputs[c].Write(os, binary);
1073 if (!binary) os << std::endl;
1077 if (!binary) os << std::endl;
1079 for (
size_t c = 0; c <
outputs.size(); c++) {
1082 if (!binary) os << std::endl;
1084 WriteToken(os, binary,
"<NeedModelDerivative>");
1086 WriteToken(os, binary,
"<StoreComponentStats>");
1088 WriteToken(os, binary,
"</ComputationRequest>");
1089 if (!binary) os << std::endl;
1093 os <<
" # Computation request:\n";
1094 for (
size_t i = 0;
i <
inputs.size();
i++) {
1095 os <<
"input-" <<
i <<
": ";
1098 for (
size_t i = 0;
i <
outputs.size();
i++) {
1099 os <<
"output-" <<
i <<
": ";
1102 os <<
"need-model-derivative: " <<
1104 os <<
"store-component-stats: " <<
1110 return (name == other.
name && indexes == other.
indexes &&
1116 name(name), indexes(std::max<
int32>(0, t_end - t_start)),
1120 std::vector<Index>::iterator iter =
indexes.begin(), end =
indexes.end();
1121 for (
int32 t = t_start; iter != end; ++iter, ++t)
1135 matrices(other.matrices),
1136 matrix_debug_info(other.matrix_debug_info),
1137 submatrices(other.submatrices),
1138 component_precomputed_indexes(other.component_precomputed_indexes),
1139 indexes(other.indexes),
1140 indexes_multi(other.indexes_multi),
1141 indexes_ranges(other.indexes_ranges),
1142 commands(other.commands),
1144 indexes_cuda(other.indexes_cuda),
1145 indexes_ranges_cuda(other.indexes_ranges_cuda) {
1174 std::vector<int32> *whole_submatrices)
const {
1177 whole_submatrices->clear();
1178 whole_submatrices->resize(num_matrices, 0);
1179 for (
int32 s = 1; s < num_submatrices; s++) {
1182 (*whole_submatrices)[m] = s;
1185 for (
int32 m = 1; m < num_matrices; m++) {
1187 "Matrix exists with no submatrix that is " 1188 "the whole of it.");
1197 return string_hasher(io_spec.name) +
1198 indexes_hasher(io_spec.indexes) +
1199 (io_spec.has_deriv ? 4261 : 0);
1207 size_t p1 = 4111, p2 = 26951;
1209 std::vector<IoSpecification>::const_iterator itr = cr->inputs.begin(),
1210 end = cr->inputs.end();
1211 for (; itr != end; ++itr)
1212 ans = ans * p1 + io_hasher(*itr);
1213 itr = cr->outputs.begin();
1214 end = cr->outputs.end();
1215 for (; itr != end; ++itr)
1216 ans = ans * p2 + io_hasher(*itr);
CommandType
CommandType is an enum that describes the category of the command used in the NnetComputation.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void WriteIndexVector(std::ostream &os, bool binary, const std::vector< Index > &vec)
void Write(std::ostream &ostream, bool binary) const
bool store_component_stats
you should set need_component_stats to true if you need the average-activation and average-derivative...
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.
std::vector< MatrixDebugInfo > matrix_debug_info
std::vector< Index > input_indexes
bool need_model_derivative
if need_model_derivative is true, then we'll be doing either model training or model-derivative compu...
const std::string & GetNodeName(int32 node_index) const
returns individual node name.
static void GetIndexesStrings(const Nnet &nnet, const NnetComputation &computation, std::vector< std::string > *indexes_strings)
void ComputeCudaIndexes()
MiscComputationInfo misc_info
misc_info is for extensibility to things that don't easily fit into the framework.
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...
void Read(std::istream &istream, bool binary)
bool operator==(const SubMatrixInfo &other) const
void ReadCindexVector(std::istream &is, bool binary, std::vector< Cindex > *vec)
void PrintIndexes(std::ostream &os, const std::vector< Index > &indexes)
this will only be used for pretty-printing.
int32 NewMatrix(int32 num_rows, int32 num_cols, MatrixStrideType stride_type)
Convenience function used when adding new matrices.
NnetComputation & operator=(const NnetComputation &other)
bool NeedDerivatives() const
returns true if any of inputs[*].has_deriv is true, or need_model_derivative is true.
void Print(std::ostream &os, const Nnet &nnet) const
void Write(std::ostream &ostream, bool binary) const
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
void Print(std::ostream &os) const
This function is for printing in a human-readable way, for debugging.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
std::vector< IoSpecification > inputs
std::vector< MatrixInfo > matrices
bool operator==(const ComputationRequest &other) const
std::vector< Command > commands
A hashing function object for strings.
void Write(std::ostream &ostream, bool binary) const
void Write(std::ostream &ostream, bool binary) const
void ReadIntegerPairVector(std::istream &is, bool binary, std::vector< std::pair< T, T > > *v)
Function for reading STL vector of pairs of integer types.
The two main classes defined in this header are struct ComputationRequest, which basically defines a ...
ComponentPrecomputedIndexes * data
void GetWholeSubmatrices(std::vector< int32 > *whole_submatrices) const
int32 NewSubMatrix(int32 base_submatrix, int32 row_offset, int32 num_rows, int32 col_offset, int32 num_cols)
Convenience function used when adding new sub-matrices.
void WriteCindexVector(std::ostream &os, bool binary, const std::vector< Cindex > &vec)
void GetCommandStrings(const Nnet &nnet, std::string *preamble, std::vector< std::string > *command_strings) const
std::vector< CuArray< int32 > > indexes_cuda
bool need_model_derivative
void Read(std::istream &istream, bool binary)
void ReadIntegerVector(std::istream &is, bool binary, std::vector< T > *v)
Function for reading STL vector of integer types.
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)
std::vector< std::vector< std::pair< int32, int32 > > > indexes_multi
void Write(std::ostream &ostream, bool binary) const
void Read(std::istream &istream, bool binary)
std::vector< Cindex > cindexes
void Read(std::istream &istream, bool binary)
std::vector< SubMatrixInfo > submatrices
virtual void Write(std::ostream &os, bool binary) const =0
void Read(std::istream &istream, bool binary)
void Swap(IoSpecification *other)
void PrintIntegerVector(std::ostream &os, const std::vector< int32 > &ints)
std::vector< CuArray< Int32Pair > > indexes_ranges_cuda
const std::string & GetComponentName(int32 component_index) const
returns individual component name.
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
std::vector< Index > output_indexes
bool operator==(const IoSpecification &other) const
int32 IndexForInput(const std::string &node_name) const
Returns the index into "inputs" corresponding to the node with name "node_name", or -1 if there is no...
void ReadIndexVector(std::istream &is, bool binary, std::vector< Index > *vec)
static ComponentPrecomputedIndexes * ReadNew(std::istream &is, bool binary)
void PrintCindexes(std::ostream &ostream, const std::vector< Cindex > &cindexes, const std::vector< std::string > &node_names)
this will only be used for pretty-printing.
std::string PrintCommand(int32 num_commands, int32 command)
std::vector< PrecomputedIndexesInfo > component_precomputed_indexes
static void PrintComputationPreamble(std::ostream &os, const NnetComputation &c, const Nnet &nnet, const std::vector< std::string > &submatrix_strings, const std::vector< std::string > &indexes_strings, const std::vector< std::string > &indexes_multi_strings)
size_t operator()(const IoSpecification &io_spec) const noexcept
std::vector< Index > indexes
#define KALDI_ASSERT(cond)
std::vector< IoSpecification > outputs
void Swap(MatrixDebugInfo *other)
void WriteIntegerVector(std::ostream &os, bool binary, const std::vector< T > &v)
Function for writing STL vectors of integer types.
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...
void Read(std::istream &istream, bool binary)
int32 IndexForOutput(const std::string &node_name) const
Returns the index into "inputs" corresponding to the node with name "node_name", or -1 if there is no...
std::vector< std::vector< int32 > > indexes
void Write(std::ostream &ostream, bool binary) const
void Read(std::istream &istream, bool binary)
void Print(std::ostream &os) const
This function is for printing info about the computation request in a human-readable way...
size_t operator()(const ComputationRequest *cr) const noexcept
bool IsWholeMatrix(int32 submatrix_index) const
void Print(std::ostream &os) const
const std::vector< std::string > & GetNodeNames() const
returns vector of node names (needed by some parsing code, for instance).
static void GetIndexesMultiStrings(const Nnet &nnet, const NnetComputation &computation, std::vector< std::string > *indexes_multi_strings)
void Write(std::ostream &ostream, bool binary) const
void GetSubmatrixStrings(const Nnet &nnet, std::vector< std::string > *submat_strings) const
std::vector< std::vector< std::pair< int32, int32 > > > indexes_ranges