31     const Nnet &nnet): nnet_(nnet) {
    36     const std::vector<const ComputationRequest*> &requests,
    55   for (
size_t segment = 0; segment < 
requests_.size(); segment++) {
    59       KALDI_ERR << 
"Not all outputs were computable, cannot create computation.";
    67   std::vector<std::vector<std::vector<int32> > > phases_per_segment;
    69   std::vector<std::vector<int32> > steps;
    74   std::vector<int32> step_to_segment;
    83     for (
size_t segment = 0; segment < 
requests_.size(); segment++) {
    85                                        phases_per_segment[segment]);
    86       while (step_to_segment.size() < steps.size())
    87         step_to_segment.push_back(segment);
    91       std::vector<std::vector<int32> > temp;
    92       phases_per_segment[segment].swap(temp);
    94     steps_computer.
Check();
    96   std::vector<bool> deriv_needed;
    98   CreateStepInfo(deriv_needed, step_to_segment, &steps, computation);
    99   AddCommands(deriv_needed, step_to_segment, computation);
   108                            const std::vector<int32> &step_to_segment,
   111   int32 arbitrary_factor = 8;
   115   std::vector<int32> whole_submatrices;
   120   for (
int32 step = 0; step < num_steps; step++) {
   122     if (step + 1 < static_cast<int32>(step_to_segment.size()) &&
   123         step_to_segment[step + 1] != step_to_segment[step]) {
   134   for (
int32 step = num_steps - 1; step >= 0; step--)
   135     if (deriv_needed[step])
   143     const std::vector<int32> &this_step,
   145     unordered_set<int32> *dep_steps) {
   147   if (this_step.empty())
   155     dep_steps->insert(step_index - 1);
   158   std::vector<int32>::const_iterator step_iter = this_step.begin(),
   159       step_end = this_step.end();
   160   int32 prev_input_step = -1;  
   161   for (; step_iter != step_end; ++step_iter) {
   162     int32 cindex_id = *step_iter;
   164     std::vector<int32>::const_iterator iter = dep.begin(), end = dep.end();
   165     for (; iter != end; ++iter) {
   166       int32 dep_cindex_id = *iter,
   168       if (input_step != prev_input_step) {  
   169         prev_input_step = input_step;
   170         dep_steps->insert(input_step);
   177     const std::vector<std::vector<int32> > &steps,
   178     const std::vector<int32> &step_to_segment,
   179     std::vector<bool> *deriv_needed) {
   181                step_to_segment[0] == 0 &&
   182                step_to_segment.back() + 1 == 
requests_.size());
   183   deriv_needed->clear();
   184   int32 num_steps = steps.size();
   185   deriv_needed->resize(num_steps, 
false);
   187   for (
int32 step = 0; step < num_steps; step++) {
   188     const std::vector<int32> &this_step = steps[step];
   189     if (this_step.empty())  
   191     int32 cindex_id = this_step[0];
   196     unordered_set<int32> input_steps;
   199     unordered_set<int32>::iterator iter = input_steps.begin(),
   200         end = input_steps.end();
   202     for (; iter != end; ++iter) {
   203       int32 dep_step = *iter;
   205       if ((*deriv_needed)[dep_step])
   206         (*deriv_needed)[step] = 
true;
   215       if (request.
inputs[input_index].has_deriv)
   216         (*deriv_needed)[step] = 
true;
   224       if (request.
outputs[output_index].has_deriv)
   225         (*deriv_needed)[step] = 
true;
   238           (*deriv_needed)[step] = 
true;
   243     std::ostringstream os;
   244     os << 
"deriv_needed = ";
   245     for (
int32 i = 0; 
i < deriv_needed->size(); 
i++)
   246       os << ((*deriv_needed)[
i] ? 
"t" : 
"f");
   253   int32 component_node_index;
   257     component_node_index = node_index + 1;
   260     component_node_index = node_index;
   280     const std::vector<bool> &deriv_needed,
   281     const std::vector<int32> &step_to_segment,
   282     std::vector<std::vector<int32> > *by_step,
   285   int32 num_steps = by_step->size();
   287   for (
int32 step = 0; step < num_steps; step++) {
   290     this_info.
segment = step_to_segment[step];
   293     for (
int32 row_index = 0; row_index < num_ids; row_index++)
   307       KALDI_ASSERT((step+1) < by_step->size() && !(*by_step)[step+1].empty());
   320       if (deriv_needed[step])
   325       std::vector<int32>::const_iterator
   328       int32 source_cindex_id = -1;
   329       for (; iter != end; ++iter) {
   330         int32 cindex_id = *iter;
   340                    steps_[input_step].output_cindex_ids.size());
   343                             steps_[input_step].output_indexes);
   347       if (deriv_needed[step])
   361       for (
int32 part = 0; part < num_parts; part++)
   365       if (num_parts == 1) {
   367         if (deriv_needed[step])
   370         int32 cur_dim_offset = 0;
   373         if (deriv_needed[step])
   375         for (
int32 p = 0; p < num_parts; p++) {
   381                                         cur_dim_offset, this_dim);
   382           if (deriv_needed[step])
   386                                           cur_dim_offset, this_dim);
   387           cur_dim_offset += this_dim;
   399   if (step >= 
steps_.size())
   435   for (
int32 part = 0; part < num_parts; part++)
   443         submatrix_index = step_info.
value;
   459     std::vector<std::vector<std::pair<int32, int32> > > *submat_locations_list)
   464   const std::vector<Index> &output_indexes = step_info.output_indexes;
   467   int32 num_indexes = output_indexes.size();
   468   submat_locations_list->clear();
   469   submat_locations_list->resize(num_indexes);
   471   for (
int32 i = 0; 
i < num_indexes; 
i++) {
   472     const Index &index = output_indexes[
i];
   473     std::vector<std::pair<int32, int32> > &this_locations_list =
   474         (*submat_locations_list)[
i];
   479       std::vector<int32> input_cindex_ids;
   480       std::vector<Cindex> input_cindexes;
   482       bool ans = descriptor.
IsComputable(index, cindex_set, &input_cindexes);
   486       std::sort(input_cindexes.begin(), input_cindexes.end());
   487       int32 size = input_cindexes.size();
   488       input_cindex_ids.resize(size);
   492         input_cindex_ids[
j] = c;
   494       this_locations_list.resize(size);
   498       this_locations_list.clear();
   504 const std::vector<std::vector<std::pair<int32, int32> > > &input_locations_list,
   505     std::vector<std::vector<std::pair<int32, int32> > >*submat_locations_list)
   507   submat_locations_list->clear();
   508   submat_locations_list->resize(input_locations_list.size());
   509   int32 size = submat_locations_list->size();
   511     const std::vector<std::pair<int32, int32> > &this_list =
   512         input_locations_list[
i];
   513     std::vector<std::pair<int32, int32> > &this_submat_list =
   514         (*submat_locations_list)[
i];
   515     this_submat_list.resize(this_list.size());
   516     std::vector<std::pair<int32, int32> >::const_iterator
   517         input_iter = this_list.begin(), input_end = this_list.end();
   518     std::vector<std::pair<int32, int32> >::iterator iter =
   519         this_submat_list.begin();
   520     for (; input_iter != input_end; ++input_iter, ++iter) {
   521       int32 step = input_iter->first,
   522           value_submat_index = 
steps_[step].value,
   523           row = input_iter->second;
   524       iter->first = value_submat_index;
   532  const std::vector<std::vector<std::pair<int32, int32> > > &input_locations_list,
   533     std::vector<std::vector<std::pair<int32, int32> > > *submat_locations_list)
   535   submat_locations_list->clear();
   536   submat_locations_list->resize(input_locations_list.size());
   537   int32 size = submat_locations_list->size();
   539     const std::vector<std::pair<int32, int32> > &this_list = input_locations_list[
i];
   540     std::vector<std::pair<int32, int32> > &this_submat_list = (*submat_locations_list)[
i];
   541     this_submat_list.reserve(this_list.size());
   542     std::vector<std::pair<int32, int32> >::const_iterator
   543         input_iter = this_list.begin(), input_end = this_list.end();
   544     for (; input_iter != input_end; ++input_iter) {
   545       int32 step = input_iter->first,
   546           deriv_submat_index = 
steps_[step].deriv,
   547           row = input_iter->second;
   548       if (deriv_submat_index > 0)
   549         this_submat_list.push_back(std::pair<int32,int32>(deriv_submat_index,
   559  const std::vector<std::vector<std::pair<int32,int32> > > &input_locations_list,
   561     std::vector<std::vector<std::pair<int32,int32> > > > >
   562     *split_locations_lists)
 const {
   563   split_locations_lists->clear();
   566   std::map<BaseFloat, std::vector<int32> > alpha_to_nodes;
   568     std::vector<int32> nodes;
   575     for (
size_t i = 0; 
i < nodes.size(); 
i++) {
   579       alpha_to_nodes[alpha].push_back(node);
   583   if (alpha_to_nodes.size() == 1) {
   587     return alpha_to_nodes.begin()->first;
   592   unordered_set<int32> steps_used;
   594     int32 cur_step = -1000;
   595     std::vector<std::vector<std::pair<int32,int32> > >::const_iterator
   596         iter = input_locations_list.begin(),
   597         end = input_locations_list.end();
   598     for (; iter != end; ++iter) {
   599       std::vector<std::pair<int32,int32> >::const_iterator
   600           pair_iter = iter->begin(),
   601           pair_end = iter->end();
   602       for (; pair_iter != pair_end; ++pair_iter) {
   603         if (pair_iter->first != cur_step) {
   604           cur_step = pair_iter->first;
   605           steps_used.insert(cur_step);
   614   std::map<int32, std::vector<int32> > node_to_steps;
   616     unordered_set<int32>::const_iterator
   617         step_iter = steps_used.begin(), step_end = steps_used.end();
   618     for (; step_iter != step_end; ++step_iter) {
   619       int32 step_index = *step_iter;
   622       node_to_steps[node_index].push_back(step_index);
   626   int32 num_rows = input_locations_list.size();
   627   split_locations_lists->resize(alpha_to_nodes.size());
   631   std::vector<int32> step_to_locations_index(
steps_.size(), -1);
   634     std::map<BaseFloat, std::vector<int32> >::const_iterator
   635         iter = alpha_to_nodes.begin(), end = alpha_to_nodes.end();
   636     int32 split_locations_index = 0;
   637     for (; iter != end; ++iter, ++split_locations_index) {
   639       const std::vector<int32> &nodes = iter->second;
   640       (*split_locations_lists)[split_locations_index].first = alpha;
   641       (*split_locations_lists)[split_locations_index].second.resize(num_rows);
   642       for (
size_t i = 0; 
i < nodes.size(); 
i++) {
   643         int32 node_index = nodes[
i];
   645         const std::vector<int32> &steps = node_to_steps[node_index];
   646         for (
size_t j = 0; 
j < steps.size(); 
j++) {
   647           int32 step_index = steps[
j];
   649                        step_to_locations_index[step_index] == -1);
   650           step_to_locations_index[step_index] = split_locations_index;
   658     for (
int32 r = 0; r < num_rows; r++) {
   659       const std::vector<std::pair<int32,int32> > &this_list =
   660           input_locations_list[r];
   661       std::vector<std::pair<int32,int32> >::const_iterator
   662           pair_iter = this_list.begin(),
   663           pair_end = this_list.end();
   664       for (; pair_iter != pair_end; ++pair_iter) {
   665         int32 step = pair_iter->first,
   666             split_locations_index = step_to_locations_index[step];
   667         (*split_locations_lists)[split_locations_index].second[r].push_back(
   672   return std::numeric_limits<BaseFloat>::infinity();
   684   if (offset_term != 0.0) {
   687                                  value_submatrix_index));
   699   const std::vector<std::vector<std::pair<int32,int32> > >
   706    std::vector<std::vector<std::pair<int32,int32> > > > > split_locations_lists;
   707   BaseFloat shared_alpha = 
SplitByScale(descriptor, input_locations_list,
   708                                  &split_locations_lists);
   709   if (shared_alpha - shared_alpha == 0.0) {
   714     std::vector<std::vector<std::pair<int32, int32> > > submat_locations_list;
   716                                     &submat_locations_list);
   718         value_submatrix_index,
   720         submat_locations_list,
   723     for (
size_t i = 0; 
i < split_locations_lists.size(); 
i++) {
   724       BaseFloat this_alpha = split_locations_lists[
i].first;
   726       std::vector<std::vector<std::pair<int32, int32> > > submat_locations_list;
   728                                       &submat_locations_list);
   730         value_submatrix_index,
   732         submat_locations_list,
   739     int32 value_submatrix_index,
   740     int32 input_submatrix_index,
   742     const std::vector<int32> &indexes,
   745   int32 input_num_rows =
   746       computation->
submatrices[input_submatrix_index].num_rows,
   747       num_rows = indexes.size();
   748   if (input_num_rows == num_rows) {
   750     for (i = 0; i < num_rows; i++)
   756                                    value_submatrix_index,
   757                                    input_submatrix_index));
   765   computation->
indexes.push_back(indexes);
   768                                input_submatrix_index, indexes_index));
   773     int32 value_submatrix_index,
   775     const std::vector<std::pair<int32, int32> > &submat_locations,
   778   int32 input_submatrix_index = -1;
   779   std::vector<int32> indexes;
   782                               input_submatrix_index,
   793                                  value_submatrix_index,
   794                                  indexes_multi_index));
   800     int32 value_submatrix_index,
   802     const std::vector<std::vector<std::pair<int32, int32> > > &submat_lists,
   804   std::vector<std::vector<std::pair<int32, int32> > > split_lists;
   806   int32 size = split_lists.size();
   811         value_submatrix_index,
   819     int32 deriv_submatrix_index,
   821     const std::vector<std::vector<std::pair<int32, int32> > > &submat_lists,
   823   std::vector<std::vector<std::pair<int32, int32> > > split_lists;
   825   int32 size = split_lists.size();  
   828         deriv_submatrix_index,
   848   const std::vector<std::vector<std::pair<int32,int32> > >
   855    std::vector<std::vector<std::pair<int32,int32> > > > > split_locations_lists;
   856   BaseFloat shared_alpha = 
SplitByScale(descriptor, input_locations_list,
   857                                  &split_locations_lists);
   858   if (shared_alpha - shared_alpha == 0.0) {
   863     std::vector<std::vector<std::pair<int32, int32> > > submat_locations_list;
   865                                     &submat_locations_list);
   868                                            submat_locations_list,
   871     for (
size_t i = 0; 
i < split_locations_lists.size(); 
i++) {
   872       BaseFloat this_alpha = split_locations_lists[
i].first;
   874       std::vector<std::vector<std::pair<int32, int32> > > submat_locations_list;
   876                                       &submat_locations_list);
   879                                              submat_locations_list,
   888     int32 deriv_submatrix_index,
   890     const std::vector<std::pair<int32, int32> > &submat_locations,
   900   std::vector<int32> second_values;
   903     int32 input_deriv_submatrix_index = first_value;
   905                                input_deriv_submatrix_index,
   912     std::vector<std::pair<int32, int32> > submat_locations_sorted;
   913     std::sort(submat_locations_sorted.begin(), submat_locations_sorted.end());
   924                                    deriv_submatrix_index,
   925                                    indexes_multi_index));
   940     int32 deriv_submatrix_index,
   941     int32 input_deriv_submatrix_index,
   943     const std::vector<int32> &indexes,
   948       computation->
submatrices[input_deriv_submatrix_index].num_rows;
   950   if (input_num_rows == num_rows) {
   952     for (i = 0; i < num_rows; i++)
   959                                      input_deriv_submatrix_index,
   960                                      deriv_submatrix_index));
   965   if (input_num_rows >= num_rows) {
   970     std::vector<int32> reverse_indexes(input_num_rows, -1);
   972     for (i = 0; i < num_rows; i++) {
   973       int32 index_i = indexes[
i];
   974       KALDI_ASSERT(index_i >= -1 && index_i < input_num_rows);
   976         if (reverse_indexes[index_i] == -1)
   977           reverse_indexes[index_i] = 
i;
   985       computation->
indexes.push_back(reverse_indexes);
   989                                      input_deriv_submatrix_index,
   990                                      deriv_submatrix_index,
   995   std::vector<std::pair<int32, int32> > ranges;
   998     if (static_cast<int32>(ranges.size()) != input_num_rows) {
   999       KALDI_ASSERT(static_cast<int32>(ranges.size()) < input_num_rows);
  1001       ranges.resize(input_num_rows, std::pair<int32,int32>(-1, -1));
  1008                                  input_deriv_submatrix_index,
  1009                                  deriv_submatrix_index,
  1010                                  indexes_ranges_index));
  1025   KALDI_ERR << 
"This case not implemented yet.";
  1033       step_info.
deriv > 0) {
  1034     int32 deriv_submatrix_index = step_info.
deriv;
  1038     computation->
commands.push_back(c);
  1044   for (
int32 part = 0; part < num_parts; part++)
  1084   int32 node_index = step_info.node_index,
  1085       submatrix_index = step_info.value;
  1093   computation->
commands.push_back(c);
  1101   int32 input_step = step - 1;
  1103   int32 node_index = step_info.node_index;
  1114       input_submatrix_index = input_step_info.
value,
  1115       output_submatrix_index = step_info.value,
  1116       memo_index = (step_info.deriv > 0 && (properties & 
kUsesMemo) ? step : 0),
  1117       store_stats = (
requests_[0]->store_component_stats &&
  1122                              step_info.precomputed_indexes_index,
  1123                              input_submatrix_index,
  1124                              output_submatrix_index,
  1127   computation->
commands.push_back(c);
  1135   int32 node_index = step_info.node_index,
  1136       deriv_submatrix_index = step_info.deriv;
  1137   if (deriv_submatrix_index == 0)
  1145   computation->
commands.push_back(c);
  1153   int32 input_step = step - 1;
  1155   int32 node_index = step_info.node_index;
  1162   int32 input_submatrix_index = input_step_info.
value,
  1163       output_submatrix_index = step_info.value,
  1164       input_deriv_submatrix_index = input_step_info.
deriv,
  1165       output_deriv_submatrix_index = step_info.deriv,
  1166       memo_index = (properties & 
kUsesMemo ? step : 0);
  1168                (input_deriv_submatrix_index > 0 ||
  1172     input_submatrix_index = 0;
  1174     output_submatrix_index = 0;
  1178                              step_info.precomputed_indexes_index,
  1179                              input_submatrix_index,
  1180                              output_submatrix_index,
  1181                              output_deriv_submatrix_index,
  1182                              input_deriv_submatrix_index,
  1184   computation->
commands.push_back(c);
  1195   unordered_set<int32> input_and_oderiv_matrices;
  1197   for (
int32 step = 0; step < num_steps; step++) {
  1206       int32 value_submatrix_index = this_info.
value,
  1207           value_matrix_index =
  1208           computation->
submatrices[value_submatrix_index].matrix_index;
  1209       input_and_oderiv_matrices.insert(value_matrix_index);
  1211     if (is_output && this_info.
deriv != 0) {
  1212       int32 deriv_submatrix_index = this_info.
deriv,
  1213           deriv_matrix_index =
  1214           computation->
submatrices[deriv_submatrix_index].matrix_index;
  1215       input_and_oderiv_matrices.insert(deriv_matrix_index);
  1220   for (
int32 m = 1; m < num_matrices; m++) {
  1223     if (input_and_oderiv_matrices.count(m) == 0) {
  1225       int32 submatrix_index = whole_submatrices[m];
  1240     const std::vector<int32> &step_to_segment,
  1246   for (
int32 step = 0; step < num_steps; step++) {
  1257     const std::vector<Index> &input_indexes = input_step_info.
output_indexes;
  1258     const std::vector<Index> &output_indexes = step_info.
output_indexes;
  1266                                      input_indexes, output_indexes,
  1268     if (precomputed_indexes == NULL) {
  1277       info.
data = precomputed_indexes;
  1279       if (!input_indexes.empty() && input_indexes.back().n == 1 &&
  1280           !output_indexes.empty() && output_indexes.back().n == 1) {
  1294                                   const std::vector<int32> &step_to_segment,
  1302   std::vector<bool> will_destroy(num_matrices, 
true);
  1305   for (
int32 step = 0; step < num_steps; step++) {
  1310       int32 value_matrix_index =
  1312       will_destroy[value_matrix_index] = 
false;
  1320       bool has_deriv = 
false;
  1321       for (; i < num_inputs; i++) {
  1322         if (input_name == request.
inputs[i].name) {
  1323           has_deriv = request.
inputs[
i].has_deriv;
  1330         int32 deriv_matrix_index =
  1332         will_destroy[deriv_matrix_index] = 
false;
  1337   for (
int32 m = 1; m < num_matrices; m++) {
  1338     if (will_destroy[m]) {
  1339       int32 submatrix_index = whole_submatrices[m];
  1348       num_steps = 
steps_.size();
  1350   for (
int32 step = 0; step < num_steps; step++) {
  1352     if (step_info.
value == 0)
  1357     int32 deriv_matrix = 0;
  1363     debug_info.is_deriv = 
false;
  1364     if (!debug_info.cindexes.empty()) {
  1374                    &debug_info.cindexes);
  1375     if (deriv_matrix != 0) {
  1379       deriv_debug_info.
cindexes = debug_info.cindexes;
  1385                     std::vector<Cindex> *out) {
  1386   size_t indexes_size = indexes.size();
  1387   if (indexes_size > out->size())
  1388     out->reserve(out->size() + indexes_size);
  1389   for (
size_t i = 0; 
i < indexes_size; 
i++)
  1390     out->push_back(
Cindex(node, indexes[
i]));
 BaseFloat SplitByScale(const SumDescriptor &descriptor, const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::pair< BaseFloat, std::vector< std::vector< std::pair< int32, int32 > > > > > *split_locations_lists) const
This function helps to handle scalar factors in Descriptors (expressions like `Scale(-1.0, <descriptor)`). 
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
std::vector< Index > output_indexes
 
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const =0
This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node ind...
 
int32 precomputed_indexes_index
 
std::vector< MatrixDebugInfo > matrix_debug_info
 
void AddBackwardStepComponent(int32 step, NnetComputation *computation) const
 
void CompileForwardFromSubmatLocationsList(int32 value_submatrix_index, BaseFloat alpha, const std::vector< std::vector< std::pair< int32, int32 > > > &submat_locations, NnetComputation *computation) const
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor...
 
virtual BaseFloat GetScaleForNode(int32 node_index) const =0
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
 
std::vector< Index > input_indexes
 
void CompileBackward(int32 step, NnetComputation *computation)
 
bool need_model_derivative
if need_model_derivative is true, then we'll be doing either model training or model-derivative compu...
 
void AllocateMatrices(const std::vector< int32 > &whole_submatrices, NnetComputation *computation) const
 
void ConsolidateIoOperations(const Nnet &nnet, NnetComputation *computation)
This optimization puts the input operations (kAcceptInput) and output operations (kProvideOutput) at ...
 
bool HasContiguousProperty(const std::vector< int32 > &indexes, std::vector< std::pair< int32, int32 > > *reverse_indexes)
This function returns true if for each integer i != -1, all the indexes j at which indexes[j] == i ar...
 
MiscComputationInfo misc_info
misc_info is for extensibility to things that don't easily fit into the framework. 
 
Abstract base-class for neural-net components. 
 
int32 GetVerboseLevel()
Get verbosity level, usually set via command line '–verbose=' switch. 
 
bool ConvertToIndexes(const std::vector< std::pair< int32, int32 > > &location_vector, int32 *first_value, std::vector< int32 > *second_values)
If it is the case for some i >= 0 that all the .first elements of "location_vector" are either i or -...
 
int32 NewMatrix(int32 num_rows, int32 num_cols, MatrixStrideType stride_type)
Convenience function used when adding new matrices. 
 
std::vector< std::vector< std::vector< std::pair< int32, int32 > > > > input_locations_list
 
bool NeedDerivatives() const
returns true if any of inputs[*].has_deriv is true, or need_model_derivative is true. 
 
void CompileBackwardFromSubmatLocationsList(int32 deriv_submatrix_index, BaseFloat alpha, const std::vector< std::vector< std::pair< int32, int32 > > > &submat_locations, NnetComputation *computation) const
 
bool IsInputNode(int32 node) const
Returns true if this is an output node, meaning that it is of type kInput. 
 
std::vector< IoSpecification > inputs
 
std::vector< MatrixInfo > matrices
 
virtual ComponentPrecomputedIndexes * PrecomputeIndexes(const MiscComputationInfo &misc_info, const std::vector< Index > &input_indexes, const std::vector< Index > &output_indexes, bool need_backprop) const
This function must return NULL for simple Components. 
 
bool IsComponentNode(int32 node) const
Returns true if this is a component node, meaning that it is of type kComponent. 
 
void SortAndUniq(std::vector< T > *vec)
Sorts and uniq's (removes duplicates) from a vector. 
 
void AddForwardStepInput(int32 step, NnetComputation *computation) const
 
std::vector< Command > commands
 
void CreateStepInfo(const std::vector< bool > &deriv_needed, const std::vector< int32 > &step_to_segment, std::vector< std::vector< int32 > > *by_step, NnetComputation *computation)
 
struct Index is intended to represent the various indexes by which we number the rows of the matrices...
 
ComponentPrecomputedIndexes * data
 
void CompileForwardFromSubmatLocations(int32 value_submatrix_index, BaseFloat alpha, const std::vector< std::pair< int32, int32 > > &submat_locations, NnetComputation *computation) const
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor...
 
void GetWholeSubmatrices(std::vector< int32 > *whole_submatrices) const
 
std::pair< int32, Index > Cindex
 
void SplitLocations(const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists)
The input to this function is a vector (indexed by matrix-row-index) of lists of pairs (submat_index...
 
void ComputeDerivNeeded(const std::vector< std::vector< int32 > > &steps, const std::vector< int32 > &step_to_segment, std::vector< bool > *deriv_needed)
 
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. 
 
This is an abstract base-class. 
 
std::vector< Cindex > cindexes
The mapping of cindex_id to Cindex. 
 
const NetworkNode & GetNode(int32 node) const
returns const reference to a particular numbered network node. 
 
void CompileBackwardSumDescriptor(int32 step, int32 part_index, NnetComputation *computation) const
 
std::vector< std::vector< int32 > > dependencies
dependencies[cindex_id] gives you the list of other cindex_ids that this particular cindex_id directl...
 
bool need_model_derivative
 
int32 GetCindexId(const Cindex &cindex, bool is_input, bool *is_new)
Maps a Cindex to an integer cindex_id. 
 
bool IsOutputNode(int32 node) const
Returns true if this is an output node, meaning that it is of type kDescriptor and is not directly fo...
 
void Check() const
This is only to be called after you have called ComputeForSegment for all the segments. 
 
int32 Dim(const Nnet &nnet) const
 
std::vector< std::vector< std::pair< int32, int32 > > > indexes_multi
 
void CompileForwardDescriptor(int32 step, NnetComputation *computation) const
 
void ComputeComputationPhases(const Nnet &nnet, const ComputationGraph &graph, std::vector< std::vector< std::vector< int32 > > > *phases_per_segment)
This function divides a computation into 'phases', where a 'phase' is a collection of cindexes which ...
 
virtual int32 Properties() const =0
Return bitmask of the component's properties. 
 
void ComputeInputLocationsList(int32 step, int32 part_index, std::vector< std::vector< std::pair< int32, int32 > > > *input_locations) const
 
std::vector< Cindex > cindexes
 
std::vector< bool > is_input
For each Cindex this tells us whether it was provided as an input to the network. ...
 
std::vector< SubMatrixInfo > submatrices
 
const SumDescriptor & Part(int32 n) const
returns the n'th part. 
 
void CompileBackwardFromSubmatLocations(int32 deriv_submatrix_index, BaseFloat alpha, const std::vector< std::pair< int32, int32 > > &submat_locations, NnetComputation *computation) const
 
Compiler(const ComputationRequest &request, const Nnet &nnet)
 
bool AllOutputsAreComputable() const
 
void ComputeValueSubmatLocationsList(const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::vector< std::pair< int32, int32 > > > *submat_locations_list) const
 
void ComputeDerivSubmatLocationsList(const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::vector< std::pair< int32, int32 > > > *submat_locations_list) const
 
std::vector< int32 > value_parts
 
#define KALDI_PARANOID_ASSERT(cond)
 
void Compute(const ComputationRequest &request)
 
void AppendCindexes(int32 node, const std::vector< Index > &indexes, std::vector< Cindex > *out)
Appends to 'out' the pairs (node, indexes[0]), (node, indexes[1]), ... 
 
std::vector< int32 > output_cindex_ids
 
void CompileForward(int32 step, NnetComputation *computation) const
 
std::vector< Index > output_indexes
 
std::vector< int32 > deriv_parts
 
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...
 
NetworkNode is used to represent, three types of thing: either an input of the network (which pretty ...
 
void CompileBackwardDescriptor(int32 step, NnetComputation *computation)
 
Component * GetComponent(int32 c)
Return component indexed c. Not a copy; not owned by caller. 
 
Class UpdatableComponent is a Component which has trainable parameters; it extends the interface of C...
 
void SetUpPrecomputedIndexes(const std::vector< int32 > &step_to_segment, NnetComputation *computation)
 
virtual bool IsComputable(const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const =0
This function exists to enable us to manage optional dependencies, i.e. 
 
std::vector< PrecomputedIndexesInfo > component_precomputed_indexes
 
std::vector< StepInfo > steps_
 
void ComputeForSegment(const ComputationRequest &request, const std::vector< std::vector< int32 > > &phases)
You call this once for each segment, in order (note: for normal, non-online computations, there is only one segment). 
 
void SplitLocationsBackward(const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists)
This function has the same interface as SplitLocations(); however, it ensures certain additional prop...
 
MatrixStrideType GetStrideType(int32 node_index) const
 
void CompileForwardSumDescriptor(int32 step, int32 part_index, NnetComputation *computation) const
 
std::vector< const ComputationRequest * > requests_
 
void CreateComputation(const CompilerOptions &opts, NnetComputation *computation)
 
#define KALDI_ASSERT(cond)
 
std::vector< IoSpecification > outputs
 
This class arranges the cindex_ids of the computation into a sequence of lists called "steps"...
 
void DeallocateMatrices(const std::vector< int32 > &whole_submatrices, const std::vector< int32 > &step_to_segment, NnetComputation *computation)
 
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...
 
void OutputDebugInfo(NnetComputation *computation) const
 
std::vector< std::vector< int32 > > indexes
 
union kaldi::nnet3::NetworkNode::@15 u
 
int32 NumParts() const
Returns the number of parts that are concatenated over. 
 
std::vector< std::pair< int32, int32 > > cindex_id_to_location_
This maps each cindex_id to its location. 
 
void ExplainWhyAllOutputsNotComputable() const
 
void AddBackwardStepInput(int32 step, NnetComputation *computation) const
 
void ComputeStepDependencies(const std::vector< int32 > &this_step, int32 step_index, unordered_set< int32 > *dep_steps)
 
bool IsSortedAndUniq(const std::vector< T > &vec)
Returns true if the vector is sorted and contains each element only once. 
 
bool IsInputStep(int32 step) const
 
BaseFloat LearningRate() const
Gets the learning rate to be used in gradient descent. 
 
void CompileForwardFromIndexes(int32 value_submatrix_index, int32 input_submatrix_index, BaseFloat alpha, const std::vector< int32 > &indexes, NnetComputation *computation) const
Adds to `computation` a command that adds to the submatrix in `value_submatrix_index` a quantity cons...
 
void CompileBackwardFromIndexes(int32 deriv_submatrix_index, int32 input_deriv_submatrix_index, BaseFloat alpha, const std::vector< int32 > &indexes, NnetComputation *computation) const
 
virtual int32 Dim(const Nnet &nnet) const =0
 
bool IsWholeMatrix(int32 submatrix_index) const
 
void AddCommands(const std::vector< bool > &deriv_needed, const std::vector< int32 > &step_to_segment, NnetComputation *computation)
 
const std::vector< std::string > & GetNodeNames() const
returns vector of node names (needed by some parsing code, for instance). 
 
int32 Dim(const Nnet &nnet) const
 
An abstract representation of a set of Cindexes. 
 
void AddForwardStepComponent(int32 step, NnetComputation *computation) const
 
bool IsComponentInputNode(int32 node) const
Returns true if this is component-input node, i.e. 
 
std::vector< std::vector< std::pair< int32, int32 > > > indexes_ranges