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 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 an
x
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
-
ExpandingArray
(std::initializer_list<T> list)¶ Constructs an
ExpandingArray
from aninitializer_list
.The extent of the length is checked against the
ExpandingArray
’s extent parameterD
at runtime.
-
ExpandingArray
(std::vector<T> vec)¶ Constructs an
ExpandingArray
from anstd::vector
.The extent of the length is checked against the
ExpandingArray
’s extent parameterD
at runtime.
-
ExpandingArray
(at::ArrayRef<T> values)¶ Constructs an
ExpandingArray
from anat::ArrayRef
.The extent of the length is checked against the
ExpandingArray
’s extent parameterD
at runtime.
-
ExpandingArray
(T single_size)¶ Constructs an
ExpandingArray
from a single value, which is repeatedD
times (whereD
is the extent parameter of theExpandingArray
).
-
ExpandingArray
(const std::array<T, D> &values)¶ Constructs an
ExpandingArray
from a correctly sizedstd::array
.
-
operator at::ArrayRef<T>
() const¶ Returns an
ArrayRef
to the underlyingstd::array
.
-
size_t
size
() const noexcept¶ Returns the extent of the
ExpandingArray
.
-