RTensor is a container with contiguous memory and shape information.
T | Data-type of the tensor |
An RTensor is a vector-like container, which has additional shape information. The elements of the multi-dimensional container can be accessed by their indices in a coherent way without taking care about the one-dimensional memory layout of the contiguous storage. This also allows to manipulate the shape of the container without moving the actual elements in memory. Another feature is that an RTensor can own the underlying contiguous memory but can also represent only a view on existing data without owning it.
Definition at line 162 of file RTensor.hxx.
Classes | |
class | Iterator |
Public Types | |
using | Container_t = C |
using | Index_t = Shape_t |
using | Shape_t = std::vector< std::size_t > |
using | Slice_t = std::vector< Shape_t > |
using | Value_t = V |
Public Member Functions | |
RTensor (Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor owning data initialized with new container. | |
RTensor (std::shared_ptr< Container_t > container, Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor owning externally provided data. | |
RTensor (Value_t *data, Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor as view on data. | |
RTensor (Value_t *data, Shape_t shape, Shape_t strides, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor as view on data. | |
Iterator | begin () noexcept |
RTensor< Value_t, Container_t > | Copy (MemoryLayout layout=MemoryLayout::RowMajor) const |
Copy RTensor to new object. | |
Iterator | end () noexcept |
RTensor< Value_t, Container_t > | ExpandDims (int idx) const |
Expand dimensions. | |
std::shared_ptr< Container_t > | GetContainer () |
const std::shared_ptr< Container_t > | GetContainer () const |
Value_t * | GetData () |
const Value_t * | GetData () const |
MemoryLayout | GetMemoryLayout () const |
const Shape_t & | GetShape () const |
std::size_t | GetSize () const |
const Shape_t & | GetStrides () const |
bool | IsOwner () const |
bool | IsView () const |
Value_t & | operator() (const Index_t &idx) |
Access elements. | |
const Value_t & | operator() (const Index_t &idx) const |
Access elements. | |
template<typename... Idx> | |
Value_t & | operator() (Idx... idx) |
Access elements. | |
template<typename... Idx> | |
const Value_t & | operator() (Idx... idx) const |
Access elements. | |
RTensor< Value_t, Container_t > | Reshape (const Shape_t &shape) const |
Reshape tensor. | |
RTensor< Value_t, Container_t > | Resize (const Shape_t &shape) |
Resize tensor. | |
RTensor< Value_t, Container_t > | Slice (const Slice_t &slice) |
Create a slice of the tensor. | |
RTensor< Value_t, Container_t > | Squeeze () const |
Squeeze dimensions. | |
RTensor< Value_t, Container_t > | Transpose () const |
Transpose. | |
Protected Member Functions | |
void | ReshapeInplace (const Shape_t &shape) |
Reshape tensor in place. | |
Private Attributes | |
std::shared_ptr< Container_t > | fContainer |
Value_t * | fData |
MemoryLayout | fLayout |
Shape_t | fShape |
std::size_t | fSize |
Shape_t | fStrides |
#include <TMVA/RTensor.hxx>
using TMVA::Experimental::RTensor< V, C >::Container_t = C |
Definition at line 169 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Index_t = Shape_t |
Definition at line 167 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Shape_t = std::vector<std::size_t> |
Definition at line 166 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Slice_t = std::vector<Shape_t> |
Definition at line 168 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Value_t = V |
Definition at line 165 of file RTensor.hxx.
|
inline |
Construct a tensor as view on data.
[in] | data | Pointer to data contiguous in memory |
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 189 of file RTensor.hxx.
|
inline |
Construct a tensor as view on data.
[in] | data | Pointer to data contiguous in memory |
[in] | shape | Shape vector |
[in] | strides | Strides vector |
[in] | layout | Memory layout |
Definition at line 201 of file RTensor.hxx.
|
inline |
Construct a tensor owning externally provided data.
[in] | container | Shared pointer to data container |
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 211 of file RTensor.hxx.
|
inline |
Construct a tensor owning data initialized with new container.
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 223 of file RTensor.hxx.
|
inlinenoexcept |
Definition at line 305 of file RTensor.hxx.
|
inline |
Copy RTensor to new object.
[in] | layout | Memory layout of the new RTensor |
Definition at line 563 of file RTensor.hxx.
|
inlinenoexcept |
Definition at line 308 of file RTensor.hxx.
|
inline |
Expand dimensions.
[in] | idx | Index in shape vector where dimension is added |
Definition at line 450 of file RTensor.hxx.
|
inline |
Definition at line 246 of file RTensor.hxx.
|
inline |
Definition at line 247 of file RTensor.hxx.
|
inline |
Definition at line 244 of file RTensor.hxx.
|
inline |
Definition at line 245 of file RTensor.hxx.
|
inline |
Definition at line 248 of file RTensor.hxx.
|
inline |
Definition at line 242 of file RTensor.hxx.
|
inline |
Definition at line 241 of file RTensor.hxx.
|
inline |
Definition at line 243 of file RTensor.hxx.
|
inline |
Definition at line 250 of file RTensor.hxx.
|
inline |
Definition at line 249 of file RTensor.hxx.
|
inline |
Access elements.
[in] | idx | Index vector |
Definition at line 344 of file RTensor.hxx.
|
inline |
Access elements.
[in] | idx | Index vector |
Definition at line 354 of file RTensor.hxx.
Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() | ( | Idx... | idx | ) |
Access elements.
[in] | idx | Indices |
Definition at line 365 of file RTensor.hxx.
const Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() | ( | Idx... | idx | ) | const |
Access elements.
[in] | idx | Indices |
Definition at line 377 of file RTensor.hxx.
|
inline |
Reshape tensor.
[in] | shape | Shape vector |
Definition at line 480 of file RTensor.hxx.
|
inlineprotected |
Reshape tensor in place.
[in] | shape | Shape vector Reshape tensor without changing the overall size |
Definition at line 317 of file RTensor.hxx.
|
inline |
Resize tensor.
[in] | shape | Shape vector |
Definition at line 493 of file RTensor.hxx.
|
inline |
Create a slice of the tensor.
[in] | slice | Slice vector |
Definition at line 510 of file RTensor.hxx.
|
inline |
Squeeze dimensions.
Definition at line 418 of file RTensor.hxx.
|
inline |
Transpose.
Definition at line 390 of file RTensor.hxx.
|
private |
Definition at line 177 of file RTensor.hxx.
|
private |
Definition at line 176 of file RTensor.hxx.
|
private |
Definition at line 175 of file RTensor.hxx.
|
private |
Definition at line 172 of file RTensor.hxx.
|
private |
Definition at line 174 of file RTensor.hxx.
|
private |
Definition at line 173 of file RTensor.hxx.