geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
Public Member Functions | List of all members
geopm::TensorTwoD Class Reference

Class to manage data and operations related to 2D Tensors required for neural net inference. More...

#include <TensorTwoD.hpp>

Public Member Functions

 TensorTwoD ()
 
 TensorTwoD (size_t rows, size_t cols)
 Constructor setting dimensions. More...
 
 TensorTwoD (size_t rows, size_t cols, std::shared_ptr< TensorMath > math)
 Test constructor. More...
 
 TensorTwoD (const TensorTwoD &other)
 Copy constructor using a deep copy. More...
 
 TensorTwoD (TensorTwoD &&other)
 
 TensorTwoD (const std::vector< std::vector< double > > &input)
 Constructor input from a vector of vectors of values. More...
 
 TensorTwoD (const std::vector< std::vector< double > > &input, std::shared_ptr< TensorMath > math)
 Constructor input from a vector of vectors of values. More...
 
 TensorTwoD (const std::vector< TensorOneD > &input)
 Constructor input from a vector of 1D tensors. More...
 
 TensorTwoD (const std::vector< TensorOneD > &input, std::shared_ptr< TensorMath > math)
 Test constructor. More...
 
size_t get_rows () const
 Get number of rows in the 2D tensor. More...
 
size_t get_cols () const
 get number of columns in 2D tensor More...
 
void set_dim (size_t rows, size_t cols)
 Set dimensions of 2D tensor. More...
 
TensorOneD operator* (const TensorOneD &) const
 Multiply a 2D tensor by a 1D tensor. More...
 
TensorOneDoperator[] (size_t idx)
 Reference indexing of 1D Tensor at idx of the 2D Tensor. More...
 
TensorOneD operator[] (size_t idx) const
 Value access of 1D Tensor value at idx. More...
 
TensorTwoDoperator= (const TensorTwoD &other)
 Oerload = operator with an in-place deep copy. More...
 
TensorTwoDoperator= (TensorTwoD &&other)
 
bool operator== (const TensorTwoD &other) const
 Overload == operator to do comparison of the underlying. More...
 
const std::vector< TensorOneD > & get_data () const
 Return the tensor as a vector of tensors. More...
 
void set_data (const std::vector< TensorOneD > &)
 Set the contents as a vector of tensors. More...
 
virtual ~TensorTwoD ()=default
 

Detailed Description

Class to manage data and operations related to 2D Tensors required for neural net inference.

Constructor & Destructor Documentation

◆ TensorTwoD() [1/9]

geopm::TensorTwoD::TensorTwoD ( )

◆ TensorTwoD() [2/9]

geopm::TensorTwoD::TensorTwoD ( size_t  rows,
size_t  cols 
)

Constructor setting dimensions.

◆ TensorTwoD() [3/9]

geopm::TensorTwoD::TensorTwoD ( size_t  rows,
size_t  cols,
std::shared_ptr< TensorMath math 
)

Test constructor.

◆ TensorTwoD() [4/9]

geopm::TensorTwoD::TensorTwoD ( const TensorTwoD other)

Copy constructor using a deep copy.

Parameters
[in]TensorTwoD&2D Tensor to copy

◆ TensorTwoD() [5/9]

geopm::TensorTwoD::TensorTwoD ( TensorTwoD &&  other)

◆ TensorTwoD() [6/9]

geopm::TensorTwoD::TensorTwoD ( const std::vector< std::vector< double > > &  input)

Constructor input from a vector of vectors of values.

Parameters
[in]inputstd::vector<std::vector<double> > instance
Exceptions
geopm::Exceptionif input is not rectangular or if input is empty.

◆ TensorTwoD() [7/9]

geopm::TensorTwoD::TensorTwoD ( const std::vector< std::vector< double > > &  input,
std::shared_ptr< TensorMath math 
)

Constructor input from a vector of vectors of values.

Parameters
[in]inputstd::vector<std::vector<double> > instance
[in]mathTensorMath instance
Exceptions
geopm::Exceptionif input is not rectangular or if input is empty.

◆ TensorTwoD() [8/9]

geopm::TensorTwoD::TensorTwoD ( const std::vector< TensorOneD > &  input)

Constructor input from a vector of 1D tensors.

Parameters
[in]inputstd::vector<TensorOneD> instance
Exceptions
geopm::Exceptionif input is not rectangular or if input is empty.

◆ TensorTwoD() [9/9]

geopm::TensorTwoD::TensorTwoD ( const std::vector< TensorOneD > &  input,
std::shared_ptr< TensorMath math 
)

Test constructor.

Parameters
[in]inputstd::vector<TensorOneD> instance
[in]mathTensorMath instance
Exceptions
geopm::Exceptionif input is not rectangular or if input is empty.

◆ ~TensorTwoD()

virtual geopm::TensorTwoD::~TensorTwoD ( )
virtualdefault

Member Function Documentation

◆ get_cols()

size_t geopm::TensorTwoD::get_cols ( ) const

get number of columns in 2D tensor

Returns
Number of columns in the 2D tensor

◆ get_data()

const std::vector< TensorOneD > & geopm::TensorTwoD::get_data ( ) const

Return the tensor as a vector of tensors.

Returns
Returns the contents of the tensor.

◆ get_rows()

size_t geopm::TensorTwoD::get_rows ( ) const

Get number of rows in the 2D tensor.

Returns
Number of rows of the 2D tensor

◆ operator*()

TensorOneD geopm::TensorTwoD::operator* ( const TensorOneD other) const

Multiply a 2D tensor by a 1D tensor.

Parameters
[in]TensorOneD&Reference to the multiplicand
Exceptions
geopm::Exceptionif the sizes are incompatible, i.e. if 2D tensor number of columns is unequal to 1D tensor number of rows

◆ operator=() [1/2]

TensorTwoD & geopm::TensorTwoD::operator= ( const TensorTwoD other)

Oerload = operator with an in-place deep copy.

Parameters
[in]TensorTwoD&Reference to the 2D Tensor to copy

◆ operator=() [2/2]

TensorTwoD & geopm::TensorTwoD::operator= ( TensorTwoD &&  other)

◆ operator==()

bool geopm::TensorTwoD::operator== ( const TensorTwoD other) const

Overload == operator to do comparison of the underlying.

Parameters
[in]otherThe tensor to compare against

◆ operator[]() [1/2]

TensorOneD & geopm::TensorTwoD::operator[] ( size_t  idx)

Reference indexing of 1D Tensor at idx of the 2D Tensor.

Parameters
[in]idxThe index at which to look for the value
Returns
Returns a reference to the 1D Tensor at idx

◆ operator[]() [2/2]

TensorOneD geopm::TensorTwoD::operator[] ( size_t  idx) const

Value access of 1D Tensor value at idx.

@pram [in] idx The index at which to look for the value

Returns
Returns the values of 1D Tensors at idx

◆ set_data()

void geopm::TensorTwoD::set_data ( const std::vector< TensorOneD > &  data)

Set the contents as a vector of tensors.

◆ set_dim()

void geopm::TensorTwoD::set_dim ( size_t  rows,
size_t  cols 
)

Set dimensions of 2D tensor.

Parameters
[in]rowsThe number of "rows" or 1D tensors
[in]colsThe number of "cols" or the size of each 1D tensor

If the instance contains more than rows 1D tensors, it will be truncated. If the instance contains fewer than rows 1D tensors, it will be expanded to a total number of rows, uninitialized. The individual 1D tensors will be managed similarly.

Exceptions
geopm::Exceptionif rows = 0 and cols > 0

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