Rate this Page

Template Class ExpandingArray#

Class Documentation#

template<size_tD,typenameT=int64_t>
classExpandingArray#

A utility class that accepts either a container ofD-many values, or a single value, which is internally repeatedD 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 anx andy length, butx andy are often equal. In such a case you could just pass3 to anExpandingArray<2> and it would “expand” to{3,3}.

Public Functions

inlineExpandingArray(std::initializer_list<T>list)#

Constructs anExpandingArray from aninitializer_list.

The extent of the length is checked against theExpandingArray’s extent parameterD at runtime.

inlineExpandingArray(std::vector<T>vec)#

Constructs anExpandingArray from anstd::vector.

The extent of the length is checked against theExpandingArray’s extent parameterD at runtime.

inlineExpandingArray(c10::ArrayRef<T>values)#

Constructs anExpandingArray from anc10::ArrayRef.

The extent of the length is checked against theExpandingArray’s extent parameterD at runtime.

inlineExpandingArray(Tsingle_size)#

Constructs anExpandingArray from a single value, which is repeatedD times (whereD is the extent parameter of theExpandingArray).

inlineExpandingArray(conststd::array<T,D>&values)#

Constructs anExpandingArray from a correctly sizedstd::array.

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

Accesses the underlyingstd::array.

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

Accesses the underlyingstd::array.

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

Accesses the underlyingstd::array.

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

Accesses the underlyingstd::array.

inlineoperatorc10::ArrayRef<T>()const#

Returns anArrayRef to the underlyingstd::array.

inlinesize_tsize()constnoexcept#

Returns the extent of theExpandingArray.

Protected Attributes

std::array<T,D>values_#

The backing array.