|
Medial Code Documentation
|
A tensor storage. More...
#include <linalg.h>
Public Types | |
| using | ShapeT = size_t[kDim] |
| using | StrideT = ShapeT |
Public Member Functions | |
| template<typename I , int32_t D> | |
| Tensor (I const (&shape)[D], std::int32_t device, Order order=kC) | |
| Create a tensor with shape and device ordinal. | |
| template<typename I , size_t D> | |
| Tensor (common::Span< I const, D > shape, std::int32_t device, Order order=kC) | |
| template<typename It , typename I , int32_t D> | |
| Tensor (It begin, It end, I const (&shape)[D], std::int32_t device, Order order=kC) | |
| Initialize from 2 host iterators. | |
| template<typename I , int32_t D> | |
| Tensor (std::initializer_list< T > data, I const (&shape)[D], std::int32_t device, Order order=kC) | |
| template<typename... Index> | |
| T & | operator() (Index &&...idx) |
| Index operator. | |
| template<typename... Index> | |
| T const & | operator() (Index &&...idx) const |
| Index operator. | |
| TensorView< T, kDim > | View (int32_t device) |
| Get a TensorView for this tensor. | |
| TensorView< T const, kDim > | View (int32_t device) const |
| auto | HostView () const |
| auto | HostView () |
| size_t | Size () const |
| auto | Shape () const |
| auto | Shape (size_t i) const |
| HostDeviceVector< T > * | Data () |
| HostDeviceVector< T > const * | Data () const |
| template<typename Fn > | |
| void | ModifyInplace (Fn &&fn) |
| Visitor function for modification that changes shape and data. | |
| template<typename... S, detail::EnableIfIntegral< S... > * = nullptr> | |
| void | Reshape (S &&...s) |
| Reshape the tensor. | |
| template<size_t D> | |
| void | Reshape (common::Span< size_t const, D > shape) |
| Reshape the tensor. | |
| template<size_t D> | |
| void | Reshape (size_t(&shape)[D]) |
| template<typename... S> | |
| auto | Slice (S &&...slices) const |
| Get a host view on the slice. | |
| template<typename... S> | |
| auto | Slice (S &&...slices) |
| Get a host view on the slice. | |
| void | SetDevice (int32_t device) const |
| Set device ordinal for this tensor. | |
| int32_t | DeviceIdx () const |
A tensor storage.
To use it for other functionality like slicing one needs to obtain a view first. This way we can use it on both host and device.
|
inlineexplicit |
Create a tensor with shape and device ordinal.
The storage is initialized automatically.
See TensorView for parameters of this constructor.
|
inline |
Visitor function for modification that changes shape and data.
| Fn | function that takes a pointer to HostDeviceVector and a static sized span as parameters. |
|
inline |
Index operator.
Not thread safe, should not be used in performance critical region. For more efficient indexing, consider getting a view first.
|
inline |
Index operator.
Not thread safe, should not be used in performance critical region. For more efficient indexing, consider getting a view first.
|
inline |
Reshape the tensor.
If the total size is changed, then data in this tensor is no longer valid.
|
inline |
Reshape the tensor.
If the total size is changed, then data in this tensor is no longer valid.