42 SizeVector(
const std::initializer_list<int64_t>& dim_sizes)
43 :
std::vector<int64_t>(dim_sizes) {}
46 :
std::vector<int64_t>(dim_sizes) {}
50 explicit SizeVector(int64_t n, int64_t initial_value = 0)
51 :
std::vector<int64_t>(n, initial_value) {}
53 template <
class InputIterator>
55 :
std::vector<int64_t>(first, last) {}
60 static_cast<std::vector<int64_t>*
>(
this)->
operator=(v);
65 static_cast<std::vector<int64_t>*
>(
this)->
operator=(v);
70 if (this->
size() == 0) {
73 return std::accumulate(this->begin(), this->end(), 1LL,
74 std::multiplies<int64_t>());
88 static inline int64_t WrapDim(int64_t dim,
90 bool inclusive =
false) {
94 int64_t min = -max_dim;
95 int64_t max = inclusive ? max_dim : max_dim - 1;
97 if (dim < min || dim > max) {
99 "Index out-of-range: dim == {}, but it must satisfy {} <= dim " 117 int64_t new_size = 1;
118 bool has_inferred_dim =
false;
119 int64_t inferred_dim;
120 for (int64_t dim = 0, ndim = shape.size(); dim != ndim; dim++) {
121 if (shape[dim] == -1) {
122 if (has_inferred_dim) {
124 "Proposed shape {}, but at most one dimension can be " 129 }
else if (shape[dim] >= 0) {
130 new_size *= shape[dim];
136 if (num_elements == new_size ||
137 (has_inferred_dim && new_size > 0 && num_elements % new_size == 0)) {
138 if (has_inferred_dim) {
149 "Cannot reshape tensor of 0 elements into shape {}, " 150 "because the unspecified dimension size -1 can be any " 151 "value and is ambiguous.",
154 inferred_shape[inferred_dim] = num_elements / new_size;
156 return inferred_shape;
int64_t NumElements() const
Definition: SizeVector.h:69
SizeVector InferShape(SizeVector shape, int64_t num_elements)
Definition: SizeVector.h:115
void LogError(const char *format, const Args &... args)
Definition: Console.h:174
Definition: RendererHandle.h:165
SizeVector(InputIterator first, InputIterator last)
Definition: SizeVector.h:54
std::string ToString() const
Definition: SizeVector.h:77
SizeVector(const std::initializer_list< int64_t > &dim_sizes)
Definition: SizeVector.h:42
int size
Definition: FilePCD.cpp:57
Definition: SizeVector.h:40
SizeVector()
Definition: SizeVector.h:57
SizeVector(const SizeVector &other)
Definition: SizeVector.h:48
Definition: Open3DViewer.h:29
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:155
SizeVector & operator=(SizeVector &&v)
Definition: SizeVector.h:64
SizeVector(const std::vector< int64_t > &dim_sizes)
Definition: SizeVector.h:45
SizeVector & operator=(const SizeVector &v)
Definition: SizeVector.h:59
SizeVector(int64_t n, int64_t initial_value=0)
Definition: SizeVector.h:50