30 if (*token_ptr ==
"end of input")
32 std::string next_few_tokens =
", next part of line is: ";
35 while (*token_ptr !=
"end of input" && *token_ptr !=
"" &&
36 next_few_tokens.size() < 40) {
37 next_few_tokens = (next_few_tokens +
" ") + *token_ptr;
40 if (*token_ptr !=
"end of input")
41 next_few_tokens = next_few_tokens +
" ...";
42 return next_few_tokens;
46 const std::string &what_we_are_parsing,
47 const std::string **next_token) {
48 if (**next_token != token)
49 KALDI_ERR <<
"Expected '" << token <<
"' while parsing " 50 << what_we_are_parsing <<
", got " 57 const std::string **next_token) {
60 KALDI_ERR <<
"Expected integer while parsing " 61 << what_we_are_parsing <<
", got '" 70 std::vector<Cindex> *dependencies)
const {
71 dependencies->clear();
72 std::vector<SumDescriptor*>::const_iterator sum_iter =
parts_.begin(),
74 std::vector<Cindex> this_part;
75 for (; sum_iter != sum_end; ++sum_iter)
76 (*sum_iter)->GetDependencies(index, dependencies);
84 if (node_index == src_node_)
return scale_;
85 else return std::numeric_limits<BaseFloat>::infinity();
89 return Cindex(src_node_, index);
97 std::vector<int32> *node_indexes)
const {
98 node_indexes->push_back(src_node_);
103 const std::vector<std::string> &node_names)
const {
104 KALDI_ASSERT(static_cast<size_t>(src_node_) < node_names.size());
106 os << node_names[src_node_];
108 os <<
"Scale(" << scale_ <<
", " << node_names[src_node_] <<
")";
113 std::vector<int32> *node_indexes)
const {
114 src_->GetNodeDependencies(node_indexes);
118 return src_->GetScaleForNode(node_index);
125 return src_->MapToInput(ind_mod);
135 const std::vector<std::string> &node_names)
const {
138 src_->WriteConfig(os, node_names);
139 os <<
", " << offset_.t;
141 os <<
", " << offset_.x;
147 std::vector<int32> *node_indexes)
const {
148 for (
size_t i = 0;
i < src_.size();
i++)
154 int32 size = src_.size(), mod = ind.
t % size;
156 if (mod < 0) mod += size;
157 return src_[mod]->MapToInput(ind);
162 std::vector<ForwardingDescriptor*> src_copy(src_.size());
163 for (
size_t i = 0;
i < src_.size();
i++)
164 src_copy[
i] = src_[
i]->
Copy();
171 const std::vector<std::string> &node_names)
const {
174 for (
size_t i = 0;
i < src_.size();
i++) {
175 src_[
i]->WriteConfig(os, node_names);
176 if (
i + 1 < src_.size())
183 std::vector<int32> *node_indexes)
const {
184 src_->GetNodeDependencies(node_indexes);
188 int32 node_index)
const {
189 return src_->GetScaleForNode(node_index);
196 int32 mod = ind_mod.
t % t_modulus_;
200 return src_->MapToInput(ind_mod);
209 const std::vector<std::string> &node_names)
const {
211 src_->WriteConfig(os, node_names);
212 os <<
", " << t_modulus_ <<
")";
216 std::vector<int32> *node_indexes)
const {
217 src_->GetNodeDependencies(node_indexes);
221 int32 node_index)
const {
222 return src_->GetScaleForNode(node_index);
227 switch (variable_name_) {
228 case kT: ind_mod.
t = value_;
break;
229 case kX: ind_mod.
x = value_;
break;
234 return src_->MapToInput(ind_mod);
239 variable_name_, value_);
245 const std::vector<std::string> &node_names)
const {
246 os <<
"ReplaceIndex(";
247 src_->WriteConfig(os, node_names);
248 KALDI_ASSERT(variable_name_ == kT || variable_name_ == kX);
249 os <<
", " << (variable_name_ == kT ?
"t" :
"x") <<
", " 259 std::vector<Cindex> *dependencies)
const {
260 src_->GetDependencies(ind, dependencies);
265 const std::vector<std::string> &node_names)
const {
267 src_->WriteConfig(os, node_names);
272 return src_->Dim(nnet);
276 BaseFloat ans = src_->GetScaleForNode(node_index);
277 if (node_index < 0 && ans != 0.0) {
283 KALDI_ERR <<
"Illegal combination of IfDefined() expression and " 284 "Const() expression encountered.";
290 std::vector<int32> *node_indexes)
const {
291 src_->GetNodeDependencies(node_indexes);
299 std::vector<Cindex> *dependencies)
const {
300 dependencies->push_back(src_->MapToInput(ind));
306 std::vector<Cindex> *used_inputs)
const {
307 Cindex c = src_->MapToInput(ind);
308 bool src_present = cindex_set(c);
309 if (src_present && used_inputs != NULL)
310 used_inputs->push_back(c);
316 const std::vector<std::string> &node_names)
const {
317 src_->WriteConfig(os, node_names);
321 return src_->Dim(nnet);
325 if (node_index >= 0)
return src_->GetScaleForNode(node_index);
331 std::vector<int32> *node_indexes)
const {
332 src_->GetNodeDependencies(node_indexes);
336 if (node_index < 0)
return value_;
337 else return std::numeric_limits<BaseFloat>::infinity();
341 std::ostream &os,
const std::vector<std::string> &node_names)
const {
342 os <<
"Const(" << value_ <<
", " << dim_ <<
')';
351 value_(value), dim_(dim) {
356 const Index &ind, std::vector<Cindex> *dependencies)
const {
357 src1_->GetDependencies(ind, dependencies);
358 src2_->GetDependencies(ind, dependencies);
364 std::vector<Cindex> *used_inputs)
const {
365 std::vector<Cindex> src1_inputs, src2_inputs;
366 bool r = (used_inputs != NULL);
367 bool src1_computable = src1_->IsComputable(ind, cindex_set,
368 r ? &src1_inputs: NULL),
369 src2_computable = src2_->IsComputable(ind, cindex_set,
370 r ? &src2_inputs : NULL);
371 if (op_ == kSumOperation) {
372 if (src1_computable && src2_computable) {
374 used_inputs->insert(used_inputs->end(),
375 src1_inputs.begin(), src1_inputs.end());
376 used_inputs->insert(used_inputs->end(),
377 src2_inputs.begin(), src2_inputs.end());
385 if (src1_computable) {
387 used_inputs->insert(used_inputs->end(),
388 src1_inputs.begin(), src1_inputs.end());
390 }
else if (src2_computable) {
392 used_inputs->insert(used_inputs->end(),
393 src2_inputs.begin(), src2_inputs.end());
402 int32 dim1 = src1_->Dim(nnet), dim2 = src2_->Dim(nnet);
404 KALDI_ERR <<
"Neural net contains " << (op_ == kSumOperation ?
"Sum" :
406 <<
" expression with inconsistent dimension: " << dim1
412 BaseFloat ans1 = src1_->GetScaleForNode(node_index),
413 ans2 = src2_->GetScaleForNode(node_index);
414 bool ans1_valid = (ans1 - ans1 == 0),
415 ans2_valid = (ans2 - ans2 == 0);
416 if (node_index < 0) {
419 if (op_ == kSumOperation) {
424 }
else if (ans1 != ans2) {
425 KALDI_ERR <<
"Illegal combination of Failover operation with Const() " 426 "expression encountered in Descriptor (this is not supported).";
429 if (ans1_valid && ans2_valid && ans1 != ans2) {
431 KALDI_ERR <<
"Inconsistent value for sum descriptor: for node " 432 << node_index <<
", it can have scales " 433 << ans1 <<
" vs. " << ans2 <<
" (you have used unsupported " 434 "combinations of descriptors).";
436 if (!ans2_valid)
return ans1;
441 std::vector<int32> *node_indexes)
const {
442 src1_->GetNodeDependencies(node_indexes);
443 src2_->GetNodeDependencies(node_indexes);
447 return Lcm(src1_->Modulus(), src2_->Modulus());
456 const std::vector<std::string> &node_names)
const {
457 KALDI_ASSERT(op_ == kSumOperation || op_ == kFailoverOperation);
458 if (op_ == kSumOperation) os <<
"Sum(";
459 if (op_ == kFailoverOperation) os <<
"Failover(";
460 src1_->WriteConfig(os, node_names);
462 src2_->WriteConfig(os, node_names);
467 int32 ans = src_.size();;
468 for (
size_t i = 0;
i < src_.size();
i++)
474 int32 node_index)
const {
475 BaseFloat inf = std::numeric_limits<BaseFloat>::infinity(),
477 for (
size_t i = 0;
i < src_.size();
i++) {
478 BaseFloat this_ans = src_[
i]->GetScaleForNode(node_index);
479 if (this_ans != inf) {
480 if (ans != inf && ans != this_ans)
481 KALDI_ERR <<
"Invalid Descriptor encountered: for node-index " 482 << node_index <<
", got two different scales " 483 << this_ans <<
" vs. " << ans;
492 const std::string **next_token) {
500 if (**next_token !=
"end of input")
501 KALDI_ERR <<
"Parsing Descriptor, expected end of input but got " 502 <<
"'" << **next_token <<
"'";
511 const std::vector<std::string> &node_names)
const {
513 if (parts_.size() == 1)
517 for (
size_t i = 0;
i < parts_.size();
i++) {
518 parts_[
i]->WriteConfig(os, node_names);
519 if (
i + 1 < parts_.size())
526 for (
size_t i = 0;
i < parts_.size();
i++)
532 int32 num_parts = parts_.size();
534 for (
int32 part = 0; part < num_parts; part++)
535 dim += parts_[part]->
Dim(nnet);
543 for (
size_t i = 0;
i < other.
parts_.size();
i++)
544 parts_.push_back(other.
parts_[
i]->Copy());
550 for (
size_t i = 0;
i < parts_.size();
i++)
558 std::vector<Cindex> *input_terms)
const {
560 input_terms->clear();
561 for (
size_t i = 0;
i < parts_.size();
i++) {
563 if (!parts_[
i]->
IsComputable(ind, cindex_set, input_terms)) {
565 input_terms->clear();
578 node_indexes->clear();
579 for (
size_t i = 0;
i < parts_.size();
i++)
586 const std::vector<std::string> &node_names,
587 const std::string **next_token) {
590 if (**next_token ==
"Append") {
592 }
else if (**next_token ==
"Sum") {
594 }
else if (**next_token ==
"Failover") {
596 }
else if (**next_token ==
"IfDefined") {
598 }
else if (**next_token ==
"Offset") {
600 }
else if (**next_token ==
"Switch") {
602 }
else if (**next_token ==
"Scale") {
604 }
else if (**next_token ==
"Const") {
606 }
else if (**next_token ==
"Round") {
608 }
else if (**next_token ==
"ReplaceIndex") {
613 for (
size_t i = 0;
i < node_names.size();
i++) {
614 if (**next_token == node_names[
i]) {
620 KALDI_ERR <<
"Expected a Descriptor, got instead " 628 case kAppend:
case kSum:
case kSwitch:
630 case kFailover: ans->
ParseFailover(node_names, next_token);
break;
631 case kIfDefined: ans->
ParseIfDefined(node_names, next_token);
break;
632 case kOffset: ans->
ParseOffset(node_names, next_token);
break;
633 case kRound: ans->
ParseRound(node_names, next_token);
break;
635 case kScale: ans->
ParseScale(node_names, next_token);
break;
636 case kConst: ans->
ParseConst(node_names, next_token);
break;
644 const std::vector<std::string> &node_names,
645 const std::string **next_token) {
646 descriptors_.push_back(Parse(node_names, next_token));
648 if (**next_token ==
")") {
651 }
else if (**next_token ==
",") {
653 descriptors_.push_back(Parse(node_names, next_token));
662 const std::vector<std::string> &node_names,
663 const std::string **next_token) {
664 descriptors_.push_back(Parse(node_names, next_token));
669 const std::vector<std::string> &node_names,
670 const std::string **next_token) {
671 descriptors_.push_back(Parse(node_names, next_token));
673 descriptors_.push_back(Parse(node_names, next_token));
678 const std::vector<std::string> &node_names,
679 const std::string **next_token) {
681 KALDI_ERR <<
"Parsing Scale() in descriptor: expected floating-point scale" 682 ", got: " << **next_token;
686 descriptors_.push_back(Parse(node_names, next_token));
691 const std::vector<std::string> &node_names,
692 const std::string **next_token) {
694 KALDI_ERR <<
"Parsing Const() in descriptor: expected floating-point value" 695 ", got: " << **next_token;
701 KALDI_ERR <<
"Parsing Const() in descriptor: expected nonnegative integer, " 702 "got: " << **next_token;
711 const std::vector<std::string> &node_names,
712 const std::string **next_token) {
713 descriptors_.push_back(Parse(node_names, next_token));
716 if (**next_token ==
",") {
727 const std::vector<std::string> &node_names,
728 const std::string **next_token) {
729 descriptors_.push_back(Parse(node_names, next_token));
737 const std::vector<std::string> &node_names,
738 const std::string **next_token) {
739 descriptors_.push_back(Parse(node_names, next_token));
741 if (**next_token ==
"t") {
744 }
else if (**next_token ==
"x") {
748 KALDI_ERR <<
"Expected 't' or 'x', got " << **next_token;
758 switch (descriptor_type_) {
759 case kNodeName: ans = 1;
break;
760 case kConst: ans = 1;
break;
762 for (
size_t i = 0;
i < descriptors_.size();
i++)
763 ans += descriptors_[
i]->NumAppendTerms();
768 ans = descriptors_[0]->NumAppendTerms();
769 for (
size_t i = 1;
i < descriptors_.size();
i++)
776 switch (descriptor_type_) {
781 int32 cur_term = term;
782 for (
size_t i = 0;
i < descriptors_.size();
i++) {
783 int32 this_num_terms = descriptors_[
i]->NumAppendTerms();
784 if (cur_term < this_num_terms)
785 return descriptors_[
i]->GetAppendTerm(cur_term);
787 cur_term -= this_num_terms;
789 KALDI_ERR <<
"Code error, getting append term.";
797 for (
size_t i = 0;
i < descriptors_.size();
i++)
807 int32 num_terms = NumAppendTerms();
809 if (num_terms == 1) {
810 return GetAppendTerm(0);
814 for (
size_t i = 0;
i < num_terms;
i++) {
824 bool changed =
false;
829 if (child->descriptor_type_ == kOffset) {
832 desc->
value1_ += child->value1_;
833 desc->
value2_ += child->value2_;
834 child->descriptors_.clear();
842 desc->
value1_ = child->value1_;
843 desc->
value2_ = child->value2_;
844 desc->
alpha_ = child->alpha_;
845 child->descriptors_.clear();
853 case kSwitch:
case kRound:
case kReplaceIndex: {
859 if (child->descriptor_type_ == kSum ||
860 child->descriptor_type_ == kFailover ||
861 child->descriptor_type_ == kIfDefined) {
864 KALDI_ERR <<
"Sum(), Failover() or IfDefined() expression inside Switch(), " 865 <<
"we can't currently normalize this.";
870 for (
size_t i = 0;
i < child->descriptors_.size();
i++) {
878 modified_grandchild->
descriptors_.push_back(grandchild);
879 child->descriptors_[
i] = modified_grandchild;
883 desc->
value1_ = child->value1_;
884 desc->
value2_ = child->value2_;
886 child->descriptors_.clear();
922 if (child->descriptor_type_ == kOffset ||
923 child->descriptor_type_ == kReplaceIndex ||
924 child->descriptor_type_ == kRound) {
931 }
else if (child->descriptor_type_ == kSum) {
934 for (
size_t i = 0;
i < child->descriptors_.size();
i++) {
942 child->descriptors_.clear();
945 }
else if (child->descriptor_type_ == kScale) {
949 desc->
alpha_ *= child->alpha_;
951 child->descriptors_.clear();
954 }
else if (child->descriptor_type_ != kNodeName) {
955 KALDI_ERR <<
"Unhandled case encountered when normalizing Descriptor; " 956 "you can work around this by pushing Scale() inside " 957 "other expressions.";
971 while (Normalize(ans));
977 switch (descriptor_type_) {
979 case kAppend: os <<
"Append(";
break;
980 case kSum: os <<
"Sum(";
break;
981 case kFailover: os <<
"Failover(";
break;
982 case kIfDefined: os <<
"IfDefined(";
break;
983 case kSwitch: os <<
"Switch(";
break;
986 case kScale: os <<
"Scale(" << alpha_ <<
", ";
break;
988 case kOffset:
case kRound: {
991 descriptors_[0]->Print(node_names, os);
992 os <<
", " << value1_;
993 if (descriptor_type_ == kOffset && value2_ != 0) os <<
", " << value2_;
997 case kReplaceIndex: {
998 os <<
"ReplaceIndex(";
1000 descriptors_[0]->Print(node_names, os);
1008 os << value2_ <<
")";
1012 KALDI_ASSERT(static_cast<size_t>(value1_) < node_names.size());
1013 os << node_names[value1_];
1017 os <<
"Const(" << alpha_ <<
", " << value1_ <<
")";
1021 for (
size_t i = 0;
i < descriptors_.size();
i++) {
1022 if (
i > 0) os <<
", ";
1023 descriptors_[
i]->Print(node_names, os);
1031 std::vector<SumDescriptor*> sum_descriptors;
1034 sum_descriptors.push_back(
1046 "Badly normalized descriptor");
1047 switch (descriptor_type_) {
1049 KALDI_ERR <<
"Badly normalized descriptor";
1050 case kSum:
case kFailover: {
1051 KALDI_ASSERT(descriptors_.size() == 2 &&
"Bad descriptor");
1053 descriptor_type_ == kSum ?
1056 descriptors_[0]->ConvertToSumDescriptor(),
1057 descriptors_[1]->ConvertToSumDescriptor());
1060 KALDI_ASSERT(descriptors_.size() == 1 &&
"Bad descriptor");
1062 descriptors_[0]->ConvertToSumDescriptor());
1076 switch (this->descriptor_type_) {
1079 KALDI_ASSERT(descriptors_.size() == 1 &&
"bad descriptor");
1081 descriptors_[0]->ConvertToForwardingDescriptor(),
1082 Index(0, value1_, value2_));
1085 std::vector<ForwardingDescriptor*> descriptors;
1086 for (
size_t i = 0;
i < descriptors_.size();
i++)
1087 descriptors.push_back(descriptors_[
i]->ConvertToForwardingDescriptor());
1091 KALDI_ASSERT(descriptors_.size() == 1 &&
"bad descriptor");
1093 descriptors_[0]->ConvertToForwardingDescriptor(),
1096 case kReplaceIndex: {
1097 KALDI_ASSERT(descriptors_.size() == 1 &&
"bad descriptor");
1101 descriptors_[0]->ConvertToForwardingDescriptor(),
1108 if (!(descriptors_.size() == 1 &&
1109 descriptors_[0]->descriptor_type_ == kNodeName)) {
1110 KALDI_ERR <<
"Invalid combination of Scale() expression and other " 1111 "expressions encountered in descriptor.";
1117 KALDI_ERR <<
"Error in Descriptor: Const() " 1118 "appeared too deep in the expression.";
1121 KALDI_ERR <<
"Invalid descriptor type (failure in normalization?)";
virtual ForwardingDescriptor * Copy() const
void GetDependencies(const Index &index, std::vector< Cindex > *used_inputs) const
This function exists to enable us to manage optional dependencies, i.e.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
virtual int32 Dim(const Nnet &nnet) const
virtual Cindex MapToInput(const Index &ind) const
bool ConvertStringToInteger(const std::string &str, Int *out)
Converts a string into an integer via strtoll and returns false if there was any kind of problem (i...
void GetNodeDependencies(std::vector< int32 > *node_indexes) const
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
static bool Normalize(GeneralDescriptor *ptr)
SumDescriptor * ConvertToSumDescriptor() const
This is the case of class SumDescriptor, in which we contain just one term, and that term is optional...
ConstantSumDescriptor(BaseFloat value, int32 dim)
void ParseScale(const std::vector< std::string > &node_names, const std::string **next_token)
static int32 ReadIntegerToken(const std::string &what_we_are_parsing, const std::string **next_token)
virtual void GetDependencies(const Index &ind, std::vector< Cindex > *dependencies) const
Given an Index at the output of this Descriptor, append to "dependencies" a list of Cindexes that des...
virtual int32 Dim(const Nnet &nnet) const
virtual ForwardingDescriptor * Copy() const
bool Parse(const std::vector< std::string > &node_names, const std::string **next_token)
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" all the node indexes.
This class is only used when parsing Descriptors.
void ParseConst(const std::vector< std::string > &node_names, const std::string **next_token)
void ParseRound(const std::vector< std::string > &node_names, const std::string **next_token)
std::vector< GeneralDescriptor * > descriptors_
This is an alternative base-case of SumDescriptor (an alternative to SimpleSumDescriptor) which repre...
virtual bool IsComputable(const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const
This function exists to enable us to manage optional dependencies, i.e.
SimpleForwardingDescriptor is the base-case of ForwardingDescriptor, consisting of a source node in t...
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
The written form is: `Const(, <dimension>)`, e.g.
virtual int32 Modulus() const
This function is for use in things like clockwork RNNs, where shifting the time of the inputs and out...
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
std::vector< SumDescriptor * > parts_
BinarySumDescriptor can represent either A + B, or (A if defined, else B).
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
virtual void GetDependencies(const Index &ind, std::vector< Cindex > *dependencies) const
Given an Index at the output of this Descriptor, append to "dependencies" a list of Cindexes that des...
void ParseReplaceIndex(const std::vector< std::string > &node_names, const std::string **next_token)
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" all the node indexes.
void ParseAppendOrSumOrSwitch(const std::vector< std::string > &node_names, const std::string **next_token)
virtual Cindex MapToInput(const Index &index) const
static std::string ParsingContext(const std::string *token_ptr)
For use in clockwork RNNs and the like, this forwarding-descriptor rounds the time-index t down to th...
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
written form is: if required_ == true, "<written-form-of-src>" else "IfDefined(<written-form-of-src>)...
static GeneralDescriptor * Parse(const std::vector< std::string > &node_names, const std::string **next_token)
virtual SumDescriptor * Copy() const
struct Index is intended to represent the various indexes by which we number the rows of the matrices...
I Lcm(I m, I n)
Returns the least common multiple of two integers.
virtual int32 Dim(const Nnet &nnet) const
std::pair< int32, Index > Cindex
virtual Cindex MapToInput(const Index &ind) const
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node ind...
DescriptorType descriptor_type_
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
written form is: if required_ == true, "<written-form-of-src>" else "IfDefined(<written-form-of-src>)...
This is an abstract base-class.
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" all the node indexes.
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
const NetworkNode & GetNode(int32 node) const
returns const reference to a particular numbered network node.
virtual bool IsComputable(const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const
This function exists to enable us to manage optional dependencies, i.e.
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
Written form is: if op_ == kSum then "Sum(<src1>, <src2>)"; if op_ == kFailover, then "Failover(<src1...
Chooses from different inputs based on the the time index modulo (the number of ForwardingDescriptors...
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
int32 Dim(const Nnet &nnet) const
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)
virtual int32 Dim(const Nnet &nnet) const
virtual ForwardingDescriptor * Copy() const
virtual int32 Modulus() const
const SumDescriptor & Part(int32 n) const
returns the n'th part.
void ParseFailover(const std::vector< std::string > &node_names, const std::string **next_token)
void ParseOffset(const std::vector< std::string > &node_names, const std::string **next_token)
void ParseIfDefined(const std::vector< std::string > &node_names, const std::string **next_token)
bool ConvertStringToReal(const std::string &str, T *out)
ConvertStringToReal converts a string into either float or double and returns false if there was any ...
This is the normal base-case of SumDescriptor which just wraps a ForwardingDescriptor.
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
virtual Cindex MapToInput(const Index &ind) const
A ForwardingDescriptor describes how we copy data from another NetworkNode, or from multiple other Ne...
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
GeneralDescriptor * NormalizeAppend() const
ForwardingDescriptor * ConvertToForwardingDescriptor() const
bool IsComputable(const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const
Has the same purpose and interface as the IsComputable function of the SumDescriptor function...
Descriptor * ConvertToDescriptor()
int32 NumAppendTerms() const
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
Descriptor & operator=(const Descriptor &other)
Assignment operator.
virtual SumDescriptor * Copy() const
Offsets in 't' and 'x' values of other ForwardingDescriptors.
void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
virtual ForwardingDescriptor * Copy() const
#define KALDI_ASSERT(cond)
This ForwardingDescriptor modifies the indexes (n, t, x) by replacing one of them (normally t) with a...
virtual Cindex MapToInput(const Index &ind) const
GeneralDescriptor * GetAppendTerm(int32 term) const
GeneralDescriptor * GetNormalizedDescriptor() const
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
virtual int32 Dim(const Nnet &nnet) const
virtual SumDescriptor * Copy() const
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node ind...
void Print(const std::vector< std::string > &node_names, std::ostream &os)
virtual int32 Modulus() const
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" all the node indexes.
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node ind...
virtual void GetDependencies(const Index &ind, std::vector< Cindex > *dependencies) const
Given an Index at the output of this Descriptor, append to "dependencies" a list of Cindexes that des...
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
virtual bool IsComputable(const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const
This function exists to enable us to manage optional dependencies, i.e.
This file contains class definitions for classes ForwardingDescriptor, SumDescriptor and Descriptor...
virtual BaseFloat GetScaleForNode(int32 node_index) const
This function returns the scale on the node-index 'node_index' when it appears in expressions inside ...
int32 Dim(const Nnet &nnet) const
virtual ForwardingDescriptor * Copy() const
virtual SumDescriptor * Copy() const
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node ind...
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const
This function appends to "node_indexes" all the node indexes.
void Copy(const CuMatrixBase< Real > &src, const CuArray< int32 > ©_from_indices, CuMatrixBase< Real > *tgt)
Copies elements from src into tgt as given by copy_from_indices.