3 #include <c10/util/ArrayRef.h> 4 #include <c10/util/Exception.h> 9 #include <initializer_list> 20 template <
size_t D,
typename T =
int64_t>
36 "Expected ",
D,
" values, but instead got ", values.
size());
38 std::copy(values.begin(), values.end(), values_.begin());
44 values_.fill(single_size);
77 size_t size() const noexcept {
83 std::array<T, D> values_;
86 template <
size_t D,
typename T>
87 std::ostream& operator<<(
90 if (expanding_array.
size() == 1) {
91 return stream << expanding_array->at(0);
93 return stream << static_cast<at::ArrayRef<T>>(expanding_array);
const std::array< T, D > * operator->() const
Accesses the underlying std::array.
size_t size() const noexcept
Returns the extent of the ExpandingArray.
const std::array< T, D > & operator*() const
Accesses the underlying std::array.
ExpandingArray(T single_size)
Constructs an ExpandingArray from a single value, which is repeated D times (where D is the extent pa...
std::array< T, D > & operator*()
Accesses the underlying std::array.
ExpandingArray(const std::array< T, D > &values)
Constructs an ExpandingArray from a correctly sized std::array.
ExpandingArray(std::initializer_list< T > list)
Constructs an ExpandingArray from an initializer_list.
constexpr size_t size() const
size - Get the array size.
ExpandingArray(at::ArrayRef< T > values)
Constructs an ExpandingArray from an initializer_list.
A utility class that accepts either a container of D-many values, or a single value, which is internally repeated D times.
std::array< T, D > * operator->()
Accesses the underlying std::array.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Flush-To-Zero and Denormals-Are-Zero mode.