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.
AFloat | The floating point type used to represent the matrix elements. |
Definition at line 87 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 |
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... | |
TCpuMatrix & | operator= (const TCpuMatrix &)=default |
TCpuMatrix & | operator= (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 Executor & | GetThreadExecutor () |
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>
|
inline |
Definition at line 115 of file CpuMatrix.h.
TMVA::DNN::TCpuMatrix< AReal >::TCpuMatrix | ( | size_t | nRows, |
size_t | nCols | ||
) |
Construct matrix and allocate space for its elements.
Definition at line 23 of file CpuMatrix.cxx.
TMVA::DNN::TCpuMatrix< AFloat >::TCpuMatrix | ( | const TMatrixT< AFloat > & | ) |
Construct a TCpuMatrix object by (deeply) copying from a TMatrixT<Double_t> matrix.
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.
|
default |
|
default |
|
default |
|
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 105 of file CpuMatrix.h.
|
inline |
Definition at line 106 of file CpuMatrix.h.
|
inline |
Definition at line 152 of file CpuMatrix.h.
|
inline |
Definition at line 153 of file CpuMatrix.h.
|
inline |
Definition at line 151 of file CpuMatrix.h.
|
static |
Definition at line 187 of file CpuMatrix.h.
|
inlinestatic |
Definition at line 109 of file CpuMatrix.h.
|
inlinestatic |
Definition at line 111 of file CpuMatrix.h.
|
inline |
Return raw pointer to the elements stored contiguously in column-major order.
Definition at line 162 of file CpuMatrix.h.
|
inline |
Definition at line 163 of file CpuMatrix.h.
|
inline |
Definition at line 154 of file CpuMatrix.h.
|
inlinestatic |
Definition at line 165 of file CpuMatrix.h.
|
private |
Definition at line 74 of file CpuMatrix.cxx.
|
static |
Definition at line 87 of file CpuMatrix.cxx.
|
inline |
Map the given function over the matrix elements.
Executed in parallel using TThreadExecutor.
Definition at line 208 of file CpuMatrix.h.
|
inline |
Same as maps but takes the input values from the matrix A
and writes the results in this matrix.
Definition at line 237 of file CpuMatrix.h.
TMVA::DNN::TCpuMatrix< AFloat >::operator TMatrixT< AFloat > | ( | ) | const |
Convert to a TMatrixT<AFloat_t> object.
Performs a deep copy of the matrix elements.
|
inline |
Definition at line 158 of file CpuMatrix.h.
|
inline |
Return matrix element in row i
and column j
.
Definition at line 157 of file CpuMatrix.h.
|
default |
|
default |
|
inline |
Definition at line 171 of file CpuMatrix.h.
void TMVA::DNN::TCpuMatrix< AFloat >::Zero |
Clear content of the matrix and initialize to zero elements.
Definition at line 265 of file CpuMatrix.h.
TCpuBuffer<AFloat> TMVA::DNN::TCpuMatrix< AFloat >::fBuffer |
The buffer holding the matrix elements in column-major format.
Definition at line 92 of file CpuMatrix.h.
|
private |
Definition at line 95 of file CpuMatrix.h.
|
private |
Definition at line 96 of file CpuMatrix.h.
|
staticprivate |
Vector filled with ones used for BLAS calls.
Definition at line 89 of file CpuMatrix.h.