Logo ROOT  
Reference Guide
TMVA::DNN::TCpuMatrix< AFloat > Class Template Reference

template<typename AFloat>
class TMVA::DNN::TCpuMatrix< AFloat >

The TCpuMatrix class.

Matrix class for multi-threaded CPU architectures. Uses the TCpuBuffer class to store the matrices in column-major format for compatibility with BLAS. Provides Map and MapFrom member functions to simplify the application of activation functions and derivatives to matrices.

Copying and assignment of TCpuMatrix objects only performs shallow copies, i.e. copying is fast and the resulting objects share the element data.

Template Parameters
AFloatThe floating point type used to represent the matrix elements.

Definition at line 86 of file CpuMatrix.h.

Public Member Functions

 TCpuMatrix ()
 
 TCpuMatrix (const TCpuBuffer< AFloat > &buffer, size_t m, size_t n)
 Construct a m-times-n matrix from the given buffer. More...
 
 TCpuMatrix (const TCpuMatrix &)=default
 
 TCpuMatrix (const TMatrixT< AFloat > &)
 Construct a TCpuMatrix object by (deeply) copying from a TMatrixT<Double_t> matrix. More...
 
 TCpuMatrix (size_t nRows, size_t nCols)
 Construct matrix and allocate space for its elements. More...
 
 TCpuMatrix (TCpuMatrix &&)=default
 
 ~TCpuMatrix ()=default
 
TCpuBuffer< AFloat > & GetBuffer ()
 Returns pointer to a vector holding only ones with a guaranteed length of the number of columns of every instantiated CpuMatrix object. More...
 
const TCpuBuffer< AFloat > & GetBuffer () const
 
TCpuBuffer< AFloat > & GetDeviceBuffer ()
 
const TCpuBuffer< AFloat > & GetDeviceBuffer () const
 
size_t GetNcols () const
 
size_t GetNoElements () const
 
size_t GetNrows () const
 
AFloat * GetRawDataPointer ()
 Return raw pointer to the elements stored contiguously in column-major order. More...
 
const AFloat * GetRawDataPointer () const
 
size_t GetSize () const
 
template<typename Function_t >
void Map (Function_t &f)
 Map the given function over the matrix elements. More...
 
template<typename Function_t >
void MapFrom (Function_t &f, const TCpuMatrix &A)
 Same as maps but takes the input values from the matrix A and writes the results in this matrix. More...
 
 operator TMatrixT< AFloat > () const
 Convert to a TMatrixT<AFloat_t> object. More...
 
AFloat & operator() (size_t i, size_t j)
 
AFloat operator() (size_t i, size_t j) const
 Return matrix element in row i and column j. More...
 
TCpuMatrixoperator= (const TCpuMatrix &)=default
 
TCpuMatrix< AFloat > & operator= (const TMatrixT< AFloat > &)
 copy from a TMAtrixT . More...
 
TCpuMatrixoperator= (TCpuMatrix &&)=default
 
void Print () const
 
void Zero ()
 Clear content of the matrix and initialize to zero elements. More...
 

Static Public Member Functions

static size_t GetNWorkItems (size_t nelements)
 
static const AFloat * GetOnePointer ()
 
static size_t GetOnePointerSize ()
 
static ExecutorGetThreadExecutor ()
 
static void InitializeOneVector (size_t n)
 

Public Attributes

TCpuBuffer< AFloat > fBuffer
 The buffer holding the matrix elements in column-major format. More...
 

Private Member Functions

void Initialize ()
 

Private Attributes

size_t fNCols
 
size_t fNRows
 

Static Private Attributes

static std::vector< AFloat > fOnes {}
 Vector filled with ones used for BLAS calls. More...
 

#include <TMVA/DNN/Architectures/Cpu/CpuMatrix.h>

Constructor & Destructor Documentation

◆ TCpuMatrix() [1/6]

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix ( )
inline

Definition at line 116 of file CpuMatrix.h.

◆ TCpuMatrix() [2/6]

template<typename AReal >
TMVA::DNN::TCpuMatrix< AReal >::TCpuMatrix ( size_t  nRows,
size_t  nCols 
)

Construct matrix and allocate space for its elements.

Definition at line 35 of file CpuMatrix.cxx.

◆ TCpuMatrix() [3/6]

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix ( const TMatrixT< AFloat > &  )

Construct a TCpuMatrix object by (deeply) copying from a TMatrixT<Double_t> matrix.

◆ TCpuMatrix() [4/6]

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix ( const TCpuBuffer< AFloat > &  buffer,
size_t  m,
size_t  n 
)

Construct a m-times-n matrix from the given buffer.

The size must of course match.

◆ TCpuMatrix() [5/6]

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix ( const TCpuMatrix< AFloat > &  )
default

◆ TCpuMatrix() [6/6]

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix ( TCpuMatrix< AFloat > &&  )
default

◆ ~TCpuMatrix()

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::~TCpuMatrix ( )
default

Member Function Documentation

◆ GetBuffer() [1/2]

template<typename AFloat >
TCpuBuffer<AFloat>& TMVA::DNN::TCpuMatrix< AFloat >::GetBuffer ( )
inline

Returns pointer to a vector holding only ones with a guaranteed length of the number of columns of every instantiated CpuMatrix object.

Definition at line 104 of file CpuMatrix.h.

◆ GetBuffer() [2/2]

template<typename AFloat >
const TCpuBuffer<AFloat>& TMVA::DNN::TCpuMatrix< AFloat >::GetBuffer ( ) const
inline

Definition at line 105 of file CpuMatrix.h.

◆ GetDeviceBuffer() [1/2]

template<typename AFloat >
TCpuBuffer<AFloat>& TMVA::DNN::TCpuMatrix< AFloat >::GetDeviceBuffer ( )
inline

Definition at line 107 of file CpuMatrix.h.

◆ GetDeviceBuffer() [2/2]

template<typename AFloat >
const TCpuBuffer<AFloat>& TMVA::DNN::TCpuMatrix< AFloat >::GetDeviceBuffer ( ) const
inline

Definition at line 108 of file CpuMatrix.h.

◆ GetNcols()

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::GetNcols ( ) const
inline

Definition at line 156 of file CpuMatrix.h.

◆ GetNoElements()

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::GetNoElements ( ) const
inline

Definition at line 157 of file CpuMatrix.h.

◆ GetNrows()

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::GetNrows ( ) const
inline

Definition at line 155 of file CpuMatrix.h.

◆ GetNWorkItems()

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::GetNWorkItems ( size_t  nelements)
static

Definition at line 191 of file CpuMatrix.h.

◆ GetOnePointer()

template<typename AFloat >
static const AFloat* TMVA::DNN::TCpuMatrix< AFloat >::GetOnePointer ( )
inlinestatic

Definition at line 110 of file CpuMatrix.h.

◆ GetOnePointerSize()

template<typename AFloat >
static size_t TMVA::DNN::TCpuMatrix< AFloat >::GetOnePointerSize ( )
inlinestatic

Definition at line 112 of file CpuMatrix.h.

◆ GetRawDataPointer() [1/2]

template<typename AFloat >
AFloat* TMVA::DNN::TCpuMatrix< AFloat >::GetRawDataPointer ( )
inline

Return raw pointer to the elements stored contiguously in column-major order.

Definition at line 166 of file CpuMatrix.h.

◆ GetRawDataPointer() [2/2]

template<typename AFloat >
const AFloat* TMVA::DNN::TCpuMatrix< AFloat >::GetRawDataPointer ( ) const
inline

Definition at line 167 of file CpuMatrix.h.

◆ GetSize()

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::GetSize ( ) const
inline

Definition at line 158 of file CpuMatrix.h.

◆ GetThreadExecutor()

template<typename AFloat >
static Executor& TMVA::DNN::TCpuMatrix< AFloat >::GetThreadExecutor ( )
inlinestatic

Definition at line 169 of file CpuMatrix.h.

◆ Initialize()

template<typename AReal >
void TMVA::DNN::TCpuMatrix< AReal >::Initialize
private

Definition at line 97 of file CpuMatrix.cxx.

◆ InitializeOneVector()

template<typename AReal >
void TMVA::DNN::TCpuMatrix< AReal >::InitializeOneVector ( size_t  n)
static

Definition at line 110 of file CpuMatrix.cxx.

◆ Map()

template<typename AFloat >
template<typename Function_t >
void TMVA::DNN::TCpuMatrix< AFloat >::Map ( Function_t &  f)
inline

Map the given function over the matrix elements.

Executed in parallel using TThreadExecutor.

Definition at line 212 of file CpuMatrix.h.

◆ MapFrom()

template<typename AFloat >
template<typename Function_t >
void TMVA::DNN::TCpuMatrix< AFloat >::MapFrom ( Function_t &  f,
const TCpuMatrix< AFloat > &  A 
)
inline

Same as maps but takes the input values from the matrix A and writes the results in this matrix.

Definition at line 241 of file CpuMatrix.h.

◆ operator TMatrixT< AFloat >()

template<typename AFloat >
TMVA::DNN::TCpuMatrix< AFloat >::operator TMatrixT< AFloat > ( ) const

Convert to a TMatrixT<AFloat_t> object.

Performs a deep copy of the matrix elements.

◆ operator()() [1/2]

template<typename AFloat >
AFloat& TMVA::DNN::TCpuMatrix< AFloat >::operator() ( size_t  i,
size_t  j 
)
inline

Definition at line 162 of file CpuMatrix.h.

◆ operator()() [2/2]

template<typename AFloat >
AFloat TMVA::DNN::TCpuMatrix< AFloat >::operator() ( size_t  i,
size_t  j 
) const
inline

Return matrix element in row i and column j.

Definition at line 161 of file CpuMatrix.h.

◆ operator=() [1/3]

template<typename AFloat >
TCpuMatrix& TMVA::DNN::TCpuMatrix< AFloat >::operator= ( const TCpuMatrix< AFloat > &  )
default

◆ operator=() [2/3]

template<typename AFloat >
TCpuMatrix<AFloat>& TMVA::DNN::TCpuMatrix< AFloat >::operator= ( const TMatrixT< AFloat > &  )

copy from a TMAtrixT .

Deep copy without re-creating a new buffer

◆ operator=() [3/3]

template<typename AFloat >
TCpuMatrix& TMVA::DNN::TCpuMatrix< AFloat >::operator= ( TCpuMatrix< AFloat > &&  )
default

◆ Print()

template<typename AFloat >
void TMVA::DNN::TCpuMatrix< AFloat >::Print ( ) const
inline

Definition at line 175 of file CpuMatrix.h.

◆ Zero()

template<typename AFloat >
void TMVA::DNN::TCpuMatrix< AFloat >::Zero

Clear content of the matrix and initialize to zero elements.

Definition at line 269 of file CpuMatrix.h.

Member Data Documentation

◆ fBuffer

template<typename AFloat >
TCpuBuffer<AFloat> TMVA::DNN::TCpuMatrix< AFloat >::fBuffer

The buffer holding the matrix elements in column-major format.

Definition at line 91 of file CpuMatrix.h.

◆ fNCols

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::fNCols
private

Definition at line 94 of file CpuMatrix.h.

◆ fNRows

template<typename AFloat >
size_t TMVA::DNN::TCpuMatrix< AFloat >::fNRows
private

Definition at line 95 of file CpuMatrix.h.

◆ fOnes

template<typename AFloat >
std::vector< AFloat > TMVA::DNN::TCpuMatrix< AFloat >::fOnes {}
staticprivate

Vector filled with ones used for BLAS calls.

Definition at line 88 of file CpuMatrix.h.


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