Runtime Tensors#

template<typename T>
class RuntimeTensor : public virtual einsums::tensor_props::TensorBase, public virtual einsums::tensor_props::TypedTensorBase<T>, public virtual einsums::tensor_props::BasicTensorBase, public virtual einsums::detail::RuntimeTensorNoType, public virtual einsums::tensor_props::CoreTensorBase#

Represents a tensor whose properties can be determined at runtime but not compile time.

Subclassed by einsums::python::PyTensor< T >

Public Types

using Vector = VectorData<T>#

Public Functions

RuntimeTensor() = default#
RuntimeTensor(const RuntimeTensor<T> &copy) = default#
inline RuntimeTensor(std::string name, const std::vector<size_t> &dims)#
inline explicit RuntimeTensor(const std::vector<size_t> &dims)#
template<size_t Rank>
inline RuntimeTensor(const Tensor<T, Rank> &copy)#
template<size_t Rank>
inline RuntimeTensor(const TensorView<T, Rank> &copy)#
virtual ~RuntimeTensor() = default#
inline virtual void zero()#
inline virtual void set_all(T val)#
inline T *data()#
inline const T *data() const#
template<typename Storage>
inline T *data(const Storage &index)#
template<typename Storage>
inline const T *data(const Storage &index) const#
template<typename Storage>
inline T &operator()(const Storage &index)#
template<typename Storage>
inline const T &operator()(const Storage &index) const#
template<typename ...Args>
inline T *data(Args... args)#
template<typename ...Args>
inline const T *data(Args... args) const#
template<typename ...Args>
inline T &operator()(Args... args)#

TODO: std::variant can’t handle references.

We might be able to make our own variant that can. This new variant may also be able to replace HostDevReference.

template<typename ...Args>
inline std::variant<T, RuntimeTensorView<T>> operator()(Args... args) const#
template<typename ...Args>
inline RuntimeTensorView<T> operator()(Args... args) const#
inline RuntimeTensorView<T> operator()(const std::vector<Range> &slices)#
inline const RuntimeTensorView<T> operator()(const std::vector<Range> &slices) const#
template<size_t Rank>
inline RuntimeTensor<T> &operator=(const Tensor<T, Rank> &other)#
template<typename TOther, size_t Rank>
inline RuntimeTensor<T> &operator=(const Tensor<TOther, Rank> &other)#
template<typename TOther, size_t Rank>
inline RuntimeTensor<T> &operator=(const TensorView<TOther, Rank> &other)#
inline virtual RuntimeTensor<T> &operator=(const RuntimeTensor<T> &other)#
inline virtual RuntimeTensor<T> &operator=(const RuntimeTensorView<T> &other)#
template<typename TOther>
inline RuntimeTensor<T> &operator=(const RuntimeTensor<TOther> &other)#
template<typename TOther>
inline RuntimeTensor<T> &operator=(const RuntimeTensorView<TOther> &other)#
inline virtual RuntimeTensor<T> &operator=(T value)#
template<typename TOther>
inline RuntimeTensor<T> &operator*=(const TOther &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator*=(const RuntimeTensor<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator*=(const RuntimeTensorView<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator/=(const TOther &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator/=(const RuntimeTensor<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator/=(const RuntimeTensorView<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator+=(const TOther &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator+=(const RuntimeTensor<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator+=(const RuntimeTensorView<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator-=(const TOther &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator-=(const RuntimeTensor<TOther> &b)#
template<typename TOther>
inline RuntimeTensor<T> &operator-=(const RuntimeTensorView<TOther> &b)#
inline virtual size_t dim(int d) const#
inline virtual std::vector<size_t> dims() const noexcept#
inline virtual const Vector &vector_data() const#
inline virtual Vector &vector_data()#
inline virtual size_t stride(int d) const#
inline virtual std::vector<size_t> strides() const noexcept#
inline virtual RuntimeTensorView<T> to_rank_1_view() const#
inline virtual size_t size() const#
inline virtual bool full_view_of_underlying() const noexcept override#
inline virtual const std::string &name() const noexcept override#
inline virtual void set_name(const std::string &new_name) override#
inline virtual size_t rank() const noexcept override#

Protected Attributes

Vector _data#
std::string _name = {"(unnamed)"}#
std::vector<size_t> _dims#
std::vector<size_t> _strides#
size_t _rank = {0}#

Friends

friend class RuntimeTensorView
friend class RuntimeTensor