Device Tensor Views#

template<typename T, size_t Rank>
struct DeviceTensorView : public virtual einsums::tensor_props::TRBasicTensorBase<T, Rank>, public virtual einsums::tensor_props::DeviceTensorBase, public virtual einsums::tensor_props::TRTensorViewBase<T, Rank, DeviceTensor<T, Rank>>, public virtual einsums::tensor_props::DevTypedTensorBase<T>, public virtual einsums::tensor_props::LockableTensorBase, public virtual einsums::tensor_props::AlgebraOptimizedTensor#

Public Types

using dev_datatype = typename tensor_props::DevTypedTensorBase<T>::dev_datatype#
using host_datatype = typename tensor_props::DevTypedTensorBase<T>::host_datatype#

Public Functions

DeviceTensorView() = delete#
DeviceTensorView(const DeviceTensorView&)#

Copy constructor.

~DeviceTensorView()#

Destructor.

template<size_t OtherRank, typename ...Args>
inline explicit DeviceTensorView(const DeviceTensor<T, OtherRank> &other, const Dim<Rank> &dim, Args&&... args)#

Create a tensor view around the given tensor.

template<size_t OtherRank, typename ...Args>
inline explicit DeviceTensorView(DeviceTensor<T, OtherRank> &other, const Dim<Rank> &dim, Args&&... args)#

Create a tensor view around the given tensor.

template<size_t OtherRank, typename ...Args>
inline explicit DeviceTensorView(DeviceTensorView<T, OtherRank> &other, const Dim<Rank> &dim, Args&&... args)#

Create a tensor view around the given tensor.

template<size_t OtherRank, typename ...Args>
inline explicit DeviceTensorView(const DeviceTensorView<T, OtherRank> &other, const Dim<Rank> &dim, Args&&... args)#

Create a tensor view around the given tensor.

template<size_t OtherRank, typename ...Args>
inline explicit DeviceTensorView(std::string name, DeviceTensor<T, OtherRank> &other, const Dim<Rank> &dim, Args&&... args)#

Create a tensor view around the given tensor.

template<CoreBasicTensorConcept TensorType>
inline explicit DeviceTensorView(TensorType &core_tensor)#

Create a device tensor view that maps an in-core tensor to the GPU.

DeviceTensorView<T, Rank> &assign(const T *other)#
template<template<typename, size_t> typename AType>
DeviceTensorView<T, Rank> &assign(const AType<T, Rank> &other)#
void set_all(const T &value)#
inline void zero()#
DeviceTensorView &operator=(const T *other)#

Copy as much data as is needed from the host pointer to the device.

template<template<typename, size_t> typename AType>
DeviceTensorView &operator=(const AType<T, Rank> &other)#

Copy data from another tensor.

DeviceTensorView &operator=(const DeviceTensorView<T, Rank> &other)#

Copy data from another tensor.

inline DeviceTensorView &operator=(const T &fill_value)#

Fill the view with a value.

DeviceTensorView<T, Rank> &mult_assign(const T &value)#
DeviceTensorView<T, Rank> &div_assign(const T &value)#
DeviceTensorView<T, Rank> &add_assign(const T &value)#
DeviceTensorView<T, Rank> &sub_assign(const T &value)#
inline DeviceTensorView &operator*=(const T &value)#

Operate each element in the view with a scalar.

inline DeviceTensorView &operator/=(const T &value)#

Operate each element in the view with a scalar.

inline DeviceTensorView &operator+=(const T &value)#

Operate each element in the view with a scalar.

inline DeviceTensorView &operator-=(const T &value)#

Operate each element in the view with a scalar.

inline virtual host_datatype *data() override#

Returns a pointer to the host-readable data.

Returns a pointer to the data as available to the host. If the tensor is in DEV_ONLY mode, then this will return a null pointer. Otherwise, the pointer should be useable, but the data may be outdated.

Returns:

T* A pointer to the data.

inline virtual const host_datatype *data() const override#

Returns a pointer to the host-readable data.

Returns a pointer to the data as available to the host. If the tensor is in DEV_ONLY mode, then this will return a null pointer. Otherwise, the pointer should be useable, but the data may be outdated.

Returns:

const T* An immutable pointer to the data.

inline dev_datatype *gpu_data()#

Get a pointer to the GPU data.

inline const dev_datatype *gpu_data() const#

Get a pointer to the GPU data.

template<typename ...MultiIndex>
dev_datatype *gpu_data(MultiIndex... index)#

Get a pointer to an element in the view.

template<typename ...MultiIndex>
const dev_datatype *gpu_data(MultiIndex... index) const#

Get a const pointer to an element in the view.

dev_datatype *gpu_data_array(const std::array<size_t, Rank> &index_list)#

Get a pointer to an element in the view.

const dev_datatype *gpu_data_array(const std::array<size_t, Rank> &index_list) const#

Get a const pointer to an element in the view.

template<typename ...MultiIndex>
T operator()(MultiIndex... index) const#

Get a value from the view.

inline virtual size_t dim(int d) const override#

Get the dimension of the given rank.

inline virtual Dim<Rank> dims() const override#

Get the dimensions of the view.

inline size_t *gpu_dims()#

Get the dimensions of the view made available to the GPU.

inline const size_t *gpu_dims() const#

Get the dimensions of the view made available to the GPU.

inline virtual const std::string &name() const override#

Get the name of the view.

inline virtual void set_name(const std::string &name) override#

Set the name of the view.

inline virtual size_t stride(int d) const noexcept override#

Get the stride of the given rank.

inline virtual Stride<Rank> strides() const noexcept override#

Get the strides of the view.

inline size_t *gpu_strides()#

Get the strides of the view made available to the GPU.

inline const size_t *gpu_strides() const#

Get the strides of the view made available to the GPU.

DeviceTensorView<T, 1> to_rank_1_view() const#

Convert the view to a one-dimensional array.

inline virtual bool full_view_of_underlying() const noexcept override#

Whether the view wraps all the data.

inline size_t size() const#

Get the size of the view.

inline operator Tensor<T, Rank>() const#