BatchedXvectorComputer Class Reference
Collaboration diagram for BatchedXvectorComputer:

Classes

struct  XvectorTask
 

Public Member Functions

 BatchedXvectorComputer (const BatchedXvectorComputerOptions &opts, const Nnet &nnet, int32 total_context)
 
void AcceptUtterance (const std::string &utt, const Matrix< BaseFloat > &input)
 Accepts an utterance to process into an xvector, and, if one or more batches become full, processes the batch. More...
 
bool XvectorReady () const
 Returns true if at least one xvector is pending output (i.e. More...
 
void OutputXvector (std::string *utt, Vector< BaseFloat > *xvector)
 This function, which must only be called if XvectorReady() has just returned true, outputs an xvector for an utterance. More...
 
void Flush ()
 Calling this will force any partial minibatch to be computed, so that any utterances that have previously been passed to AcceptUtterance() will, when this function returns, have their xvectors ready to be retrieved by OutputXvector(). More...
 

Private Member Functions

void SplitUtteranceIntoChunks (int32 num_frames, std::vector< int32 > *start_frames)
 This decides how to split the utterance into chunks. More...
 
XvectorTaskCreateTask (const std::string &utt, int32 num_chunks)
 This adds a newly created XvectorTask at the tail of the singly linked list whose (head,tail) are results_head_, results_tail_. More...
 
void ComputeOneBatch ()
 Does the nnet computation for one batch and distributes the computed x-vectors (of chunks) appropriately to their XvectorTask objects. More...
 
void AddChunkToBatch (XvectorTask *task, const Matrix< BaseFloat > &input, int32 chunk_start)
 Adds a new chunk to a batch we are preparing. More...
 

Private Attributes

const BatchedXvectorComputerOptionsopts_
 
int32 total_context_
 
const Nnetnnet_
 
int32 feature_dim_
 
int32 xvector_dim_
 
Matrix< BaseFloatinput_feats_
 Staging area for the input features prior to copying them to GPU. More...
 
std::shared_ptr< const NnetComputationcomputation_
 The compiled computation (will be the same for every batch). More...
 
int32 position_in_batch_
 position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and tasks_this_batch_. More...
 
std::vector< XvectorTask * > tasks_this_batch_
 tasks_this_batch_ is of dimension opts_.batch_size. More...
 
XvectorTaskresults_head_
 
XvectorTaskresults_tail_
 

Detailed Description

Definition at line 99 of file nnet3-xvector-compute-batched.cc.

Constructor & Destructor Documentation

◆ BatchedXvectorComputer()

BatchedXvectorComputer ( const BatchedXvectorComputerOptions opts,
const Nnet nnet,
int32  total_context 
)
Parameters
[in]optsOptions class; warning, it keeps a reference to it.
[in]nnetThe neural net we'll be computing with; assumed to have already been prepared for test.
[in]total_contextThe sum of the left and right context of the network, computed after calling SetRequireDirectInput(true, &nnet); so the l/r context isn't zero.

Definition at line 293 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputerOptions::batch_size, BatchedXvectorComputerOptions::chunk_size, CachingOptimizingCompiler::Compile(), BatchedXvectorComputerOptions::compiler_config, BatchedXvectorComputer::computation_, BatchedXvectorComputer::feature_dim_, IoSpecification::has_deriv, IoSpecification::indexes, BatchedXvectorComputer::input_feats_, Nnet::InputDim(), ComputationRequest::inputs, Index::n, rnnlm::n, IoSpecification::name, ComputationRequest::need_model_derivative, BatchedXvectorComputerOptions::optimize_config, BatchedXvectorComputer::opts_, Nnet::OutputDim(), ComputationRequest::outputs, Matrix< Real >::Resize(), ComputationRequest::store_component_stats, Index::t, BatchedXvectorComputer::tasks_this_batch_, and BatchedXvectorComputer::xvector_dim_.

296  :
297  opts_(opts),
298  total_context_(total_context),
299  nnet_(nnet),
301  results_head_(NULL),
302  results_tail_(NULL) {
303 
305 
306  feature_dim_ = nnet.InputDim("input");
307  xvector_dim_ = nnet.OutputDim("output");
308  // Zero input_feats_ in case there is only one batch, to avoid
309  // NaN's being generated due to undefined data.
311  feature_dim_);
312 
313  CachingOptimizingCompiler compiler(nnet, opts.optimize_config,
314  opts.compiler_config);
315 
316  { // This block creates computation_.
317  ComputationRequest request;
318  request.need_model_derivative = false;
319  request.store_component_stats = false;
320  request.inputs.resize(1);
321  IoSpecification &input(request.inputs[0]);
322  input.name = "input";
323  input.has_deriv = false;
324  input.indexes.resize(opts_.batch_size * opts_.chunk_size);
325  // Note: the sequences are interleaved in the input; this will save an extra
326  // copy since it corresponds to how nnet3 stores things by default. (Makes
327  // TDNNs easier to implement.)
328  for (int32 n = 0; n < opts_.batch_size; n++) {
329  for (int32 t = 0; t < opts_.chunk_size; t++) {
330  Index index;
331  index.n = n;
332  index.t = t;
333  // index.x is 0 by default.
334  input.indexes[n + opts_.batch_size * t] = index;
335  }
336  }
337  IoSpecification output;
338  output.name = "output";
339  output.has_deriv = false;
340  output.indexes.resize(opts_.batch_size);
341  for (int32 n = 0; n < opts_.batch_size; n++){
342  Index index;
343  index.n = n;
344  index.t = 0;
345  output.indexes[n] = index;
346  }
347  request.outputs.push_back(output);
348  computation_ = compiler.Compile(request);
349  }
350 }
int32 InputDim(const std::string &input_name) const
Definition: nnet-nnet.cc:669
bool store_component_stats
you should set need_component_stats to true if you need the average-activation and average-derivative...
bool need_model_derivative
if need_model_derivative is true, then we&#39;ll be doing either model training or model-derivative compu...
This class enables you to do the compilation and optimization in one call, and also ensures that if t...
std::shared_ptr< const NnetComputation > computation_
The compiled computation (will be the same for every batch).
Matrix< BaseFloat > input_feats_
Staging area for the input features prior to copying them to GPU.
kaldi::int32 int32
std::vector< IoSpecification > inputs
int32 OutputDim(const std::string &output_name) const
Definition: nnet-nnet.cc:677
struct Index is intended to represent the various indexes by which we number the rows of the matrices...
Definition: nnet-common.h:44
std::vector< XvectorTask * > tasks_this_batch_
tasks_this_batch_ is of dimension opts_.batch_size.
struct rnnlm::@11::@12 n
const BatchedXvectorComputerOptions & opts_
std::vector< Index > indexes
int32 position_in_batch_
position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and task...
std::vector< IoSpecification > outputs
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).

Member Function Documentation

◆ AcceptUtterance()

void AcceptUtterance ( const std::string &  utt,
const Matrix< BaseFloat > &  input 
)

Accepts an utterance to process into an xvector, and, if one or more batches become full, processes the batch.

Definition at line 428 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputer::AddChunkToBatch(), BatchedXvectorComputerOptions::batch_size, BatchedXvectorComputer::ComputeOneBatch(), BatchedXvectorComputer::CreateTask(), rnnlm::i, MatrixBase< Real >::NumRows(), BatchedXvectorComputer::opts_, BatchedXvectorComputer::position_in_batch_, and BatchedXvectorComputer::SplitUtteranceIntoChunks().

Referenced by main().

430  {
431  std::vector<int32> chunk_starts;
432  int32 num_frames = input.NumRows();
433  SplitUtteranceIntoChunks(num_frames, &chunk_starts);
434  int32 num_chunks = chunk_starts.size();
435  XvectorTask *task = CreateTask(utt, num_chunks);
436 
437  for (int32 i = 0; i < num_chunks; i++) {
438  AddChunkToBatch(task, input, chunk_starts[i]);
440  ComputeOneBatch();
441  }
442  }
443 }
void AddChunkToBatch(XvectorTask *task, const Matrix< BaseFloat > &input, int32 chunk_start)
Adds a new chunk to a batch we are preparing.
XvectorTask * CreateTask(const std::string &utt, int32 num_chunks)
This adds a newly created XvectorTask at the tail of the singly linked list whose (head...
kaldi::int32 int32
void ComputeOneBatch()
Does the nnet computation for one batch and distributes the computed x-vectors (of chunks) appropriat...
const BatchedXvectorComputerOptions & opts_
int32 position_in_batch_
position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and task...
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void SplitUtteranceIntoChunks(int32 num_frames, std::vector< int32 > *start_frames)
This decides how to split the utterance into chunks.

◆ AddChunkToBatch()

void AddChunkToBatch ( XvectorTask task,
const Matrix< BaseFloat > &  input,
int32  chunk_start 
)
private

Adds a new chunk to a batch we are preparing.

This will go at position `position_in_batch_` which will be incremented.

Parameters
[in]taskThe task this is part of (records the utterance); tasks_this_batch_[position_in_batch_] will be set to this.
[in]inputThe input matrix of features of which this chunk is a part
[in]chunk_startThe frame at which this chunk starts. Must be >= 0; and if opts_.pad_input is false, chunk_start + opts_.chunk_size must be <= input.NumRows().

Definition at line 352 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputerOptions::batch_size, BatchedXvectorComputerOptions::chunk_size, VectorBase< Real >::CopyFromVec(), BatchedXvectorComputer::feature_dim_, BatchedXvectorComputer::input_feats_, KALDI_ASSERT, KALDI_ERR, rnnlm::n, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), BatchedXvectorComputer::opts_, BatchedXvectorComputerOptions::pad_input, BatchedXvectorComputer::position_in_batch_, and BatchedXvectorComputer::tasks_this_batch_.

Referenced by BatchedXvectorComputer::AcceptUtterance().

355  {
357  KALDI_ASSERT(n >= 0 && n < opts_.batch_size);
358  tasks_this_batch_[n] = task;
359  int32 T = opts_.chunk_size,
360  num_input_frames = input.NumRows();
362  if (input.NumCols() != feature_dim_) {
363  KALDI_ERR << "Feature dimension mismatch: neural net expected "
364  << feature_dim_ << ", got " << input.NumCols();
365  }
366  for (int32 t = 0; t < T; t++) {
368  int32 src_t = t + chunk_start;
369  if (src_t >= num_input_frames) {
371  src_t = num_input_frames - 1; // Pad with repeats of the last frame.
372  }
373  SubVector<BaseFloat> src(input, src_t);
374  dest.CopyFromVec(src);
375  }
376 }
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
Matrix< BaseFloat > input_feats_
Staging area for the input features prior to copying them to GPU.
kaldi::int32 int32
std::vector< XvectorTask * > tasks_this_batch_
tasks_this_batch_ is of dimension opts_.batch_size.
struct rnnlm::@11::@12 n
#define KALDI_ERR
Definition: kaldi-error.h:147
const BatchedXvectorComputerOptions & opts_
int32 position_in_batch_
position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and task...
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
Definition: kaldi-vector.h:501

◆ ComputeOneBatch()

void ComputeOneBatch ( )
private

Does the nnet computation for one batch and distributes the computed x-vectors (of chunks) appropriately to their XvectorTask objects.

Definition at line 404 of file nnet3-xvector-compute-batched.cc.

References NnetComputer::AcceptInput(), BatchedXvectorComputerOptions::batch_size, BatchedXvectorComputer::computation_, BatchedXvectorComputerOptions::compute_config, NnetComputer::GetOutputDestructive(), BatchedXvectorComputer::input_feats_, KALDI_ASSERT, rnnlm::n, BatchedXvectorComputer::nnet_, BatchedXvectorComputer::XvectorTask::num_chunks, BatchedXvectorComputer::XvectorTask::num_chunks_finished, CuMatrixBase< Real >::NumRows(), BatchedXvectorComputer::opts_, BatchedXvectorComputer::position_in_batch_, NnetComputer::Run(), BatchedXvectorComputer::tasks_this_batch_, and BatchedXvectorComputer::XvectorTask::xvector.

Referenced by BatchedXvectorComputer::AcceptUtterance(), and BatchedXvectorComputer::Flush().

404  {
405 
406  CuMatrix<BaseFloat> cu_input_feats(input_feats_);
407  Nnet *nnet_to_update = NULL; // we're not doing any update.
409  nnet_, nnet_to_update);
410  computer.AcceptInput("input", &cu_input_feats);
411  computer.Run();
412  CuMatrix<BaseFloat> cu_output;
413  computer.GetOutputDestructive("output", &cu_output);
414  KALDI_ASSERT(cu_output.NumRows() == opts_.batch_size);
415  Matrix<BaseFloat> output(cu_output);
416  for (int32 n = 0; n < opts_.batch_size; n++) {
417  XvectorTask *task = tasks_this_batch_[n];
418  if (task == NULL)
419  continue; // Would only happen for the last batch.
420  task->num_chunks_finished++;
421  task->xvector.AddVec(1.0 / task->num_chunks, output.Row(n));
422  }
423  position_in_batch_ = 0;
424  std::fill(tasks_this_batch_.begin(), tasks_this_batch_.end(),
425  (XvectorTask*)NULL);
426 }
std::shared_ptr< const NnetComputation > computation_
The compiled computation (will be the same for every batch).
Matrix< BaseFloat > input_feats_
Staging area for the input features prior to copying them to GPU.
kaldi::int32 int32
This class represents a matrix that&#39;s stored on the GPU if we have one, and in memory if not...
Definition: matrix-common.h:71
std::vector< XvectorTask * > tasks_this_batch_
tasks_this_batch_ is of dimension opts_.batch_size.
struct rnnlm::@11::@12 n
const BatchedXvectorComputerOptions & opts_
class NnetComputer is responsible for executing the computation described in the "computation" object...
Definition: nnet-compute.h:59
int32 position_in_batch_
position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and task...
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Dimensions.
Definition: cu-matrix.h:215

◆ CreateTask()

BatchedXvectorComputer::XvectorTask * CreateTask ( const std::string &  utt,
int32  num_chunks 
)
private

This adds a newly created XvectorTask at the tail of the singly linked list whose (head,tail) are results_head_, results_tail_.

Definition at line 275 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputer::XvectorTask::num_chunks, BatchedXvectorComputer::XvectorTask::num_chunks_finished, BatchedXvectorComputer::XvectorTask::tail, BatchedXvectorComputer::XvectorTask::utt_id, and BatchedXvectorComputer::XvectorTask::xvector.

Referenced by BatchedXvectorComputer::AcceptUtterance().

276  {
277  XvectorTask *task = new XvectorTask;
278  task->utt_id = utt;
279  task->num_chunks = num_chunks;
280  task->num_chunks_finished = 0;
281  task->xvector.Resize(xvector_dim_);
282  task->tail = NULL;
283  if (results_tail_) {
284  results_tail_->tail = task;
285  results_tail_ = task;
286  } else { // List was previously empty.
287  results_head_ = task;
288  results_tail_ = task;
289  }
290  return task;
291 }

◆ Flush()

void Flush ( )

Calling this will force any partial minibatch to be computed, so that any utterances that have previously been passed to AcceptUtterance() will, when this function returns, have their xvectors ready to be retrieved by OutputXvector().

Definition at line 397 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputer::ComputeOneBatch(), and BatchedXvectorComputer::position_in_batch_.

Referenced by main().

397  {
398  if (position_in_batch_ == 0)
399  return;
400  ComputeOneBatch();
401 }
void ComputeOneBatch()
Does the nnet computation for one batch and distributes the computed x-vectors (of chunks) appropriat...
int32 position_in_batch_
position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and task...

◆ OutputXvector()

void OutputXvector ( std::string *  utt,
Vector< BaseFloat > *  xvector 
)

This function, which must only be called if XvectorReady() has just returned true, outputs an xvector for an utterance.

Parameters
[out]uttThe utterance-id is written to here. Note: these will be output in the same order as the user called AcceptUtterance(), except that if opts_.pad_input is false and and utterance is shorter than the chunk size, some utterances may be skipped.
[out]xvectorThe xvector will be written to here.

Definition at line 385 of file nnet3-xvector-compute-batched.cc.

References KALDI_ASSERT, BatchedXvectorComputer::results_head_, BatchedXvectorComputer::results_tail_, Vector< Real >::Swap(), BatchedXvectorComputer::XvectorTask::tail, BatchedXvectorComputer::XvectorTask::utt_id, BatchedXvectorComputer::XvectorTask::xvector, and BatchedXvectorComputer::XvectorReady().

Referenced by main().

386  {
388  *utt = results_head_->utt_id;
389  xvector->Swap(&(results_head_->xvector));
390  XvectorTask *new_tail = results_head_->tail;
391  delete results_head_;
392  results_head_ = new_tail;
393  if (new_tail == NULL)
394  results_tail_ = NULL;
395 }
void Swap(Vector< Real > *other)
Swaps the contents of *this and *other. Shallow swap.
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
bool XvectorReady() const
Returns true if at least one xvector is pending output (i.e.

◆ SplitUtteranceIntoChunks()

void SplitUtteranceIntoChunks ( int32  num_frames,
std::vector< int32 > *  start_frames 
)
private

This decides how to split the utterance into chunks.

It does so in a way that minimizes the variance of the x-vector under some simplifying assumptions. It's about minimizing the variance of the x-vector. We treat the x-vector as computed as a sum over frames (although some frames may be repeated or omitted due to gaps between chunks or overlaps between chunks); and we try to minimize the variance of the x-vector estimate; this is minimized when all the frames have the same weight, which is only possible if it can be exactly divided into chunks; anyway, this function computes the best division into chunks.

It's a question of whether to allow overlaps or gaps. Suppose we are averaging independent quantities with variance 1. The variance of a simple sum of M of those quantities is 1/M. Suppose we have M of those quantities, plus N which are repeated twice in the sum. The variance of the estimate formed that way is:

(M + 4N) / (M + 2N)^2

If we can't divide it exactly into chunks we'll compare the variances from the cases where there is a gap vs. an overlap, and choose the one with the smallest variance. (Note: due to context effects we actually lose total_context_ frames from the input signal, and the chunks would have to overlap by total_context_ even if the part at the statistics-computation layer were ideally cut up.

Parameters
[in]num_framesThe number of frames in the utterance
[out]start_framesThis function will output to here a vector containing all the start-frames of chunks in this utterance. All chunks will have duration opts_.chunk_size; if a chunk goes past the end of the input we'll repeat the last frame. (This will only happen if opts_.pad_input is false and num_frames is less than opts_.chunk_length.)

Definition at line 445 of file nnet3-xvector-compute-batched.cc.

References BatchedXvectorComputerOptions::chunk_size, kaldi::nnet3::DivideIntoPieces(), rnnlm::i, KALDI_ASSERT, BatchedXvectorComputer::opts_, BatchedXvectorComputerOptions::pad_input, and BatchedXvectorComputer::total_context_.

Referenced by BatchedXvectorComputer::AcceptUtterance().

446  {
447  start_frames->clear();
448  if (num_frames <= opts_.chunk_size) {
449  if (num_frames == opts_.chunk_size || opts_.pad_input)
450  start_frames->push_back(0);
451  // if we leave start_frames empty, then we just won't compute anything for
452  // this file.
453  } else {
454  // these modified quantities are to account for the context effects... when
455  // the chunks overlap by exactly total_context_, the frames that get
456  // averaged by the respective chunks in their averaging layers would touch
457  // but not overlap. So the optimal separation between chunks would equal
458  // opts_.chunk_size - total_context_.
459  int32 modified_num_frames = num_frames - total_context_,
460  modified_chunk_size = opts_.chunk_size - total_context_;
461  KALDI_ASSERT(modified_num_frames > modified_chunk_size);
462  int32 num_chunks1 = modified_num_frames / modified_chunk_size,
463  num_chunks2 = num_chunks1 + 1;
464  int32 num_frames1 = num_chunks1 * modified_chunk_size,
465  num_frames2 = num_chunks2 * modified_chunk_size;
466  KALDI_ASSERT(num_frames2 > modified_chunk_size);
467  // The M and N below correspond to the M and N in the comment:
468  // M is the number of frames repeated once in the averaging, N
469  // the number of frames repeated twice. (Basically a solution
470  // of the equations: (M + 2N == num_frames2, M+N == modified_num_frames).
471  // Note: by a "frame" above, I mean a specific "t" value in
472  // the utterance.
473  int32 N = num_frames2 - modified_num_frames,
474  M = modified_num_frames - N;
475  KALDI_ASSERT(M + 2*N == num_frames2 && M + N == modified_num_frames);
476 
477  // The variances below are proportional to the variance of our
478  // estimate of the xvector under certain simplifying assumptions..
479  // they help us choose whether to have gaps between the chunks
480  // or overlaps between them.
481  BaseFloat variance1 = 1.0 / num_frames1, // the 1/M mentioned above.
482  variance2 = (M + 4.0*N) / ((M + 2.0*N)*(M + 2.0*N));
483  if (variance1 <= variance2) {
484  // We'll choose the smaller number of chunks. There may be gaps.
485  // Counting the positions at the ends, there are num_chunks+1 positions
486  // where there might be gaps.
487  // Note: "total_gap" is >= 0, it's the positive of the sum of the
488  // sizes of those gaps.
489  int32 num_chunks = num_chunks1,
490  num_gaps = num_chunks + 1,
491  total_gap = modified_num_frames - num_chunks * modified_chunk_size;
492  KALDI_ASSERT(0 <= total_gap && total_gap < modified_chunk_size);
493  std::vector<int32> gap_sizes; // elements will be >= 0.
494  DivideIntoPieces(total_gap, num_gaps, &gap_sizes);
495  int32 pos = gap_sizes[0];
496  for (int32 i = 0; i < num_chunks; i++) {
497  start_frames->push_back(pos);
498  pos += modified_chunk_size + gap_sizes[i + 1];
499  }
500  KALDI_ASSERT(pos == modified_num_frames);
501  } else {
502  int32 num_chunks = num_chunks2,
503  num_overlaps = num_chunks - 1,
504  total_overlap = modified_num_frames - num_chunks * modified_chunk_size;
505  KALDI_ASSERT( -modified_chunk_size < total_overlap && total_overlap <= 0 );
506  std::vector<int32> overlap_sizes; // elements will be <= 0.
507  DivideIntoPieces(total_overlap, num_overlaps, &overlap_sizes);
508  int32 pos = 0;
509  for (int32 i = 0; i < num_chunks; i++) {
510  start_frames->push_back(pos);
511  pos += modified_chunk_size;
512  if (i < num_overlaps)
513  pos += overlap_sizes[i];
514  }
515  KALDI_ASSERT(pos == modified_num_frames);
516  }
517  }
518 }
void DivideIntoPieces(int32 a, int32 b, std::vector< int32 > *pieces)
This function divides the number &#39;a&#39; into &#39;b&#39; pieces, such that the sum of the pieces equals &#39;a&#39; and ...
kaldi::int32 int32
float BaseFloat
Definition: kaldi-types.h:29
const BatchedXvectorComputerOptions & opts_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ XvectorReady()

Member Data Documentation

◆ computation_

std::shared_ptr<const NnetComputation> computation_
private

The compiled computation (will be the same for every batch).

Definition at line 248 of file nnet3-xvector-compute-batched.cc.

Referenced by BatchedXvectorComputer::BatchedXvectorComputer(), and BatchedXvectorComputer::ComputeOneBatch().

◆ feature_dim_

◆ input_feats_

Matrix<BaseFloat> input_feats_
private

Staging area for the input features prior to copying them to GPU.

Dimension is opts_.chunk_size * opts_.batch_size by feature_dim_. The sequences are interleaved (will be faster since this corresponds to how nnet3 keeps things in memory), i.e. row 0 of input_feats_ is time t=0 for chunk n=0; and row 1 of input_feats_ is time t=0 for chunk n=1.

Definition at line 244 of file nnet3-xvector-compute-batched.cc.

Referenced by BatchedXvectorComputer::AddChunkToBatch(), BatchedXvectorComputer::BatchedXvectorComputer(), and BatchedXvectorComputer::ComputeOneBatch().

◆ nnet_

const Nnet& nnet_
private

◆ opts_

◆ position_in_batch_

int32 position_in_batch_
private

position_in_batch_ is the number of chunks that we have filled in in the input_feats_ matrix and tasks_this_batch_.

When it reaches opts_.batch_size we will do the actual computation.

Definition at line 255 of file nnet3-xvector-compute-batched.cc.

Referenced by BatchedXvectorComputer::AcceptUtterance(), BatchedXvectorComputer::AddChunkToBatch(), BatchedXvectorComputer::ComputeOneBatch(), and BatchedXvectorComputer::Flush().

◆ results_head_

◆ results_tail_

XvectorTask* results_tail_
private

◆ tasks_this_batch_

std::vector<XvectorTask*> tasks_this_batch_
private

tasks_this_batch_ is of dimension opts_.batch_size.

It is a vector of pointers to elements of the singly linked list whose head is at results_head_, or NULL for elements with indexes >= position_in_batch_.

Definition at line 262 of file nnet3-xvector-compute-batched.cc.

Referenced by BatchedXvectorComputer::AddChunkToBatch(), BatchedXvectorComputer::BatchedXvectorComputer(), and BatchedXvectorComputer::ComputeOneBatch().

◆ total_context_

int32 total_context_
private

◆ xvector_dim_

int32 xvector_dim_
private

The documentation for this class was generated from the following file: