Template Class ExpandingArray¶
Defined in File expanding_array.h
Page Contents
Class Documentation¶
-
template<size_t
D, typenameT= int64_t>
classtorch::ExpandingArray¶ A utility class that accepts either a container of
D-many values, or a single value, which is internally repeatedDtimes.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
xandylength, butxandyare often equal. In such a case you could just pass3to anExpandingArray<2>and it would “expand” to{3, 3}.Public Functions
-
ExpandingArray(std::initializer_list<T> list)¶ Constructs an
ExpandingArrayfrom aninitializer_list.The extent of the length is checked against the
ExpandingArray’s extent parameterDat runtime.
-
ExpandingArray(std::vector<T> vec)¶ Constructs an
ExpandingArrayfrom anstd::vector.The extent of the length is checked against the
ExpandingArray’s extent parameterDat runtime.
-
ExpandingArray(at::ArrayRef<T> values)¶ Constructs an
ExpandingArrayfrom anat::ArrayRef.The extent of the length is checked against the
ExpandingArray’s extent parameterDat runtime.
-
ExpandingArray(T single_size)¶ Constructs an
ExpandingArrayfrom a single value, which is repeatedDtimes (whereDis the extent parameter of theExpandingArray).
-
ExpandingArray(const std::array<T, D> &values)¶ Constructs an
ExpandingArrayfrom a correctly sizedstd::array.
-
operator at::ArrayRef<T>() const¶ Returns an
ArrayRefto the underlyingstd::array.
-
size_t
size() const noexcept¶ Returns the extent of the
ExpandingArray.
-