CuSubVector< Real > Class Template Reference

#include <matrix-common.h>

Inheritance diagram for CuSubVector< Real >:
Collaboration diagram for CuSubVector< Real >:

Public Member Functions

 CuSubVector (const CuVectorBase< Real > &t, const MatrixIndexT origin, const MatrixIndexT length)
 
 CuSubVector (const CuSubVector &other)
 Copy constructor this constructor needed for Range() to work in base class. More...
 
 CuSubVector (const Real *data, MatrixIndexT length)
 
 CuSubVector (const CuMatrixBase< Real > &matrix, MatrixIndexT row)
 This operation does not preserve const-ness, so be careful. More...
 
- Public Member Functions inherited from CuVectorBase< Real >
MatrixIndexT Dim () const
 Dimensions. More...
 
Real * Data ()
 Returns a pointer to the start of the vector's data. More...
 
const Real * Data () const
 Returns a pointer to the start of the vector's data (const). More...
 
void CopyFromVec (const CuVectorBase< Real > &src)
 Copy functions; these will crash if the dimension do not match. More...
 
template<typename OtherReal >
void CopyFromVec (const CuVectorBase< OtherReal > &M)
 
template<typename OtherReal >
void CopyFromVec (const VectorBase< OtherReal > &src)
 
template<typename OtherReal >
void CopyToVec (VectorBase< OtherReal > *dst) const
 
void CopyRowsFromMat (const CuMatrixBase< Real > &M)
 
void CopyRowsFromMat (const MatrixBase< Real > &M)
 
void SetZero ()
 Math operations. More...
 
void Set (Real value)
 
void Add (Real value)
 
void Scale (Real value)
 
void AddVec (Real alpha, const CuVectorBase< Real > &vec, Real beta=1.0)
 
template<typename OtherReal >
void AddVec (Real alpha, const CuVectorBase< OtherReal > &vec, Real beta=1.0)
 
void AddRowSumMat (Real alpha, const CuMatrixBase< Real > &mat, Real beta=1.0)
 Sum the rows of the matrix, add to vector. More...
 
void AddColSumMat (Real alpha, const CuMatrixBase< Real > &mat, Real beta=1.0)
 Sum the columns of the matrix, add to vector. More...
 
void AddTpVec (const Real alpha, const CuTpMatrix< Real > &M, const MatrixTransposeType trans, const CuVectorBase< Real > &v, const Real beta)
 Add triangular matrix times vector: this <– beta*this + alpha*M*v. More...
 
void MulTp (const CuTpMatrix< Real > &M, const MatrixTransposeType trans)
 Multiplies this vector by lower-triangular marix: *this <– *this *M. More...
 
bool ApproxEqual (const CuVectorBase< Real > &other, float tol=0.01) const
 
void InvertElements ()
 
void CopyElements (const CuMatrixBase< Real > &mat, const MatrixTransposeType trans, const CuArrayBase< int32 > &elements)
 Copies selected elements from 'mat' to *this. More...
 
void Floor (const CuVectorBase< Real > &src, Real floor_val, MatrixIndexT *floored_count=NULL)
 
void Ceiling (const CuVectorBase< Real > &src, Real ceiling_val, MatrixIndexT *ceiled_count=NULL)
 
void Pow (const CuVectorBase< Real > &src, Real power)
 
void ApplyFloor (Real floor_val, MatrixIndexT *floored_count=NULL)
 
void ApplyCeiling (Real ceiling_val, MatrixIndexT *ceiled_count=NULL)
 
void ApplyPow (Real power)
 
void ApplySoftMax ()
 
void ApplyLogSoftMax ()
 
void ApplyExp ()
 
void ApplyLog ()
 
Real Sum () const
 
void SetRandn ()
 
void SetRandUniform ()
 
CuSubVector< Real > Range (const MatrixIndexT o, const MatrixIndexT l)
 
const CuSubVector< Real > Range (const MatrixIndexT o, const MatrixIndexT l) const
 
void CopyColFromMat (const CuMatrixBase< Real > &mat, MatrixIndexT col)
 
template<typename OtherReal >
void CopyColFromMat (const CuMatrixBase< OtherReal > &mat, MatrixIndexT col)
 
void AddMatVec (const Real alpha, const CuMatrixBase< Real > &M, MatrixTransposeType trans, const CuVectorBase< Real > &v, const Real beta)
 
void AddVecVec (Real alpha, const CuVectorBase< Real > &v, const CuVectorBase< Real > &r, Real beta)
 
void AddSpVec (const Real alpha, const CuSpMatrix< Real > &S, const CuVectorBase< Real > &v, const Real beta)
 
void AddDiagMat2 (Real alpha, const CuMatrixBase< Real > &M, MatrixTransposeType trans, Real beta)
 Add the diagonal of a matrix times itself: *this = diag(M M^T) + beta * *this (if trans == kNoTrans), or *this = diag(M^T M) + beta * *this (if trans == kTrans). More...
 
void AddDiagMatMat (Real alpha, const CuMatrixBase< Real > &M, MatrixTransposeType transM, const CuMatrixBase< Real > &N, MatrixTransposeType transN, Real beta=1.0)
 Add the diagonal of a matrix product: *this = diag(M N), assuming the "trans" arguments are both kNoTrans; for transpose arguments, it behaves as you would expect. More...
 
CuValue< Real > operator() (MatrixIndexT i)
 
Real Norm (Real p)
 
Real operator() (MatrixIndexT i) const
 
void CopyDiagFromPacked (const CuPackedMatrix< Real > &M)
 Extracts the diagonal of a packed matrix M; works for Sp or Tp. More...
 
void CopyDiagFromMat (const CuMatrix< Real > &M)
 Extracts the diagonal of a matrix. More...
 
Real Max () const
 Returns the maximum value of any element, or -infinity for the empty vector. More...
 
Real Min () const
 Returns the minimum value of any element, or +infinity for the empty vector. More...
 
void ReplaceValue (Real orig, Real changed)
 
void MulElements (const CuVectorBase< Real > &v)
 
void DivElements (const CuVectorBase< Real > &v)
 
const VectorBase< Real > & Vec () const
 
VectorBase< Real > & Vec ()
 
template<>
void CopyColFromMat (const CuMatrixBase< float > &mat, MatrixIndexT col)
 
template<>
void CopyColFromMat (const CuMatrixBase< double > &mat, MatrixIndexT col)
 
template<>
void CopyFromVec (const CuVectorBase< float > &src)
 
template<>
void CopyFromVec (const CuVectorBase< double > &src)
 
template<>
void CopyFromVec (const CuVectorBase< float > &src)
 
template<>
void CopyFromVec (const CuVectorBase< double > &src)
 

Additional Inherited Members

- Protected Member Functions inherited from CuVectorBase< Real >
 CuVectorBase ()
 Default constructor: make it protected so the user cannot instantiate this class. More...
 
- Protected Attributes inherited from CuVectorBase< Real >
Real * data_
 GPU data pointer (or regular data pointer if CUDA is not compiled in or we have no GPU). More...
 
MatrixIndexT dim_
 dimension of the vector More...
 

Detailed Description

template<typename Real>
class kaldi::CuSubVector< Real >

Definition at line 73 of file matrix-common.h.

Constructor & Destructor Documentation

◆ CuSubVector() [1/4]

CuSubVector ( const CuVectorBase< Real > &  t,
const MatrixIndexT  origin,
const MatrixIndexT  length 
)
inline

Definition at line 327 of file cu-vector.h.

References CuVectorBase< Real >::data_, CuVectorBase< Real >::dim_, and KALDI_ASSERT.

328  : CuVectorBase<Real>() {
329  KALDI_ASSERT(static_cast<UnsignedMatrixIndexT>(origin)+
330  static_cast<UnsignedMatrixIndexT>(length) <=
331  static_cast<UnsignedMatrixIndexT>(t.Dim()));
332  this->data_ = const_cast<Real*>(t.Data()+origin);
333  this->dim_ = length;
334  }
Real * data_
GPU data pointer (or regular data pointer if CUDA is not compiled in or we have no GPU)...
Definition: cu-vector.h:248
MatrixIndexT dim_
dimension of the vector
Definition: cu-vector.h:250
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ CuSubVector() [2/4]

CuSubVector ( const CuSubVector< Real > &  other)
inline

Copy constructor this constructor needed for Range() to work in base class.

Definition at line 337 of file cu-vector.h.

References CuVectorBase< Real >::data_, and CuVectorBase< Real >::dim_.

337  : CuVectorBase<Real> () {
338  this->data_ = other.data_;
339  this->dim_ = other.dim_;
340  }
Real * data_
GPU data pointer (or regular data pointer if CUDA is not compiled in or we have no GPU)...
Definition: cu-vector.h:248
MatrixIndexT dim_
dimension of the vector
Definition: cu-vector.h:250

◆ CuSubVector() [3/4]

CuSubVector ( const Real *  data,
MatrixIndexT  length 
)
inline

Definition at line 342 of file cu-vector.h.

References CuVectorBase< Real >::data_, and CuVectorBase< Real >::dim_.

342  : CuVectorBase<Real> () {
343  // Yes, we're evading C's restrictions on const here, and yes, it can be used
344  // to do wrong stuff; unfortunately the workaround would be very difficult.
345  this->data_ = const_cast<Real*>(data);
346  this->dim_ = length;
347  }
Real * data_
GPU data pointer (or regular data pointer if CUDA is not compiled in or we have no GPU)...
Definition: cu-vector.h:248
MatrixIndexT dim_
dimension of the vector
Definition: cu-vector.h:250

◆ CuSubVector() [4/4]

CuSubVector ( const CuMatrixBase< Real > &  matrix,
MatrixIndexT  row 
)
inline

This operation does not preserve const-ness, so be careful.

Definition at line 350 of file cu-vector.h.

References CuVectorBase< Real >::data_, CuVectorBase< Real >::dim_, CuMatrixBase< Real >::NumCols(), and CuMatrixBase< Real >::RowData().

350  {
351  this->data_ = const_cast<Real*>(matrix.RowData(row));
352  this->dim_ = matrix.NumCols();
353  }
Real * data_
GPU data pointer (or regular data pointer if CUDA is not compiled in or we have no GPU)...
Definition: cu-vector.h:248
MatrixIndexT dim_
dimension of the vector
Definition: cu-vector.h:250

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