Rate this Page

Template Class ExpandingArray#

Page Contents

Class Documentation#

template<size_t D, typename T = int64_t>
class ExpandingArray#

A utility class that accepts either a container of D-many values, or a single value, which is internally repeated D times.

This is useful to represent parameters that are multidimensional, but often equally sized in all dimensions. For example, the kernel size of a 2D convolution has an x and y length, but x and y are often equal. In such a case you could just pass 3 to an ExpandingArray<2> and it would “expand” to {3, 3}.

Public Functions

inline ExpandingArray(std::initializer_list<T> list)#

Constructs an ExpandingArray from an initializer_list.

The extent of the length is checked against the ExpandingArray’s extent parameter D at runtime.

inline ExpandingArray(std::vector<T> vec)#

Constructs an ExpandingArray from an std::vector.

The extent of the length is checked against the ExpandingArray’s extent parameter D at runtime.

inline ExpandingArray(c10::ArrayRef<T> values)#

Constructs an ExpandingArray from an c10::ArrayRef.

The extent of the length is checked against the ExpandingArray’s extent parameter D at runtime.

inline ExpandingArray(T single_size)#

Constructs an ExpandingArray from a single value, which is repeated D times (where D is the extent parameter of the ExpandingArray).

inline ExpandingArray(const std::array<T, D> &values)#

Constructs an ExpandingArray from a correctly sized std::array.

inline std::array<T, D> &operator*()#

Accesses the underlying std::array.

inline const std::array<T, D> &operator*() const#

Accesses the underlying std::array.

inline std::array<T, D> *operator->()#

Accesses the underlying std::array.

inline const std::array<T, D> *operator->() const#

Accesses the underlying std::array.

inline operator c10::ArrayRef<T>() const#

Returns an ArrayRef to the underlying std::array.

inline size_t size() const noexcept#

Returns the extent of the ExpandingArray.

Protected Attributes

std::array<T, D> values_#

The backing array.