Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nnet3/nnet-am-decodable-simple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DecodableNnetSimple::DecodableNnetSimple(
(feats_.NumRows() + opts_.frame_subsampling_factor - 1) /
opts_.frame_subsampling_factor;
KALDI_ASSERT(IsSimpleNnet(nnet));
ComputeSimpleNnetContext(nnet, &nnet_left_context_, &nnet_right_context_);
compiler_.GetSimpleNnetContext(&nnet_left_context_, &nnet_right_context_);
KALDI_ASSERT(!(ivector != NULL && online_ivectors != NULL));
KALDI_ASSERT(!(online_ivectors != NULL && online_ivector_period <= 0 &&
"You need to set the --online-ivector-period option!"));
Expand Down
1 change: 0 additions & 1 deletion src/nnet3/nnet-example-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ struct ExampleGenerationConfig {
struct ChunkTimeInfo is used by class UtteranceSplitter to output
information about how we split an utterance into chunks.
*/

struct ChunkTimeInfo {
int32 first_frame;
int32 num_frames;
Expand Down
16 changes: 14 additions & 2 deletions src/nnet3/nnet-optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <iomanip>
#include "nnet3/nnet-optimize.h"
#include "nnet3/nnet-optimize-utils.h"
#include "nnet3/nnet-utils.h"
#include "base/timer.h"

namespace kaldi {
Expand Down Expand Up @@ -638,7 +639,8 @@ CachingOptimizingCompiler::CachingOptimizingCompiler(
seconds_taken_total_(0.0), seconds_taken_compile_(0.0),
seconds_taken_optimize_(0.0), seconds_taken_expand_(0.0),
seconds_taken_check_(0.0), seconds_taken_indexes_(0.0),
seconds_taken_io_(0.0), cache_(config.cache_capacity) { }
seconds_taken_io_(0.0), cache_(config.cache_capacity),
nnet_left_context_(-1), nnet_right_context_(-1) { }

CachingOptimizingCompiler::CachingOptimizingCompiler(
const Nnet &nnet,
Expand All @@ -648,8 +650,18 @@ CachingOptimizingCompiler::CachingOptimizingCompiler(
seconds_taken_total_(0.0), seconds_taken_compile_(0.0),
seconds_taken_optimize_(0.0), seconds_taken_expand_(0.0),
seconds_taken_check_(0.0), seconds_taken_indexes_(0.0),
seconds_taken_io_(0.0), cache_(config.cache_capacity) { }
seconds_taken_io_(0.0), cache_(config.cache_capacity),
nnet_left_context_(-1), nnet_right_context_(-1) { }

void CachingOptimizingCompiler::GetSimpleNnetContext(
int32 *nnet_left_context, int32 *nnet_right_context) {
if (nnet_left_context_ == -1) {
ComputeSimpleNnetContext(nnet_, &nnet_left_context_,
&nnet_right_context_);
}
*nnet_left_context = nnet_left_context_;
*nnet_right_context = nnet_right_context_;
}

void CachingOptimizingCompiler::ReadCache(std::istream &is, bool binary) {
{
Expand Down
14 changes: 14 additions & 0 deletions src/nnet3/nnet-optimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ class CachingOptimizingCompiler {
void ReadCache(std::istream &is, bool binary);
void WriteCache(std::ostream &os, bool binary);


// GetSimpleNnetContext() is equivalent to calling:
// ComputeSimpleNnetContext(nnet_, &nnet_left_context,
// &nnet_right_context)
// but it caches it inside this class. This functionality is independent of
// the rest of the functionality of this class; it just happens to be a
// convenient place to put this mechanism.
void GetSimpleNnetContext(int32 *nnet_left_context,
int32 *nnet_right_context);

private:

// This function just implements the work of Compile(); it's made a separate
Expand Down Expand Up @@ -290,6 +300,10 @@ class CachingOptimizingCompiler {
double seconds_taken_io_;

ComputationCache cache_;

// These following two variables are only used by the function GetSimpleNnetContext().
int32 nnet_left_context_;
int32 nnet_right_context_;
};


Expand Down