MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / compare_dimensions

Function compare_dimensions

tests/validation/Validation.h:157–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156template <typename T>
157bool compare_dimensions(const Dimensions<T> &dimensions1,
158 const Dimensions<T> &dimensions2,
159 const DataLayout &data_layout = DataLayout::NCHW)
160{
161 ARM_COMPUTE_ERROR_ON(data_layout == DataLayout::UNKNOWN);
162
163 if (data_layout != DataLayout::NHWC)
164 {
165 if (dimensions1.num_dimensions() != dimensions2.num_dimensions())
166 {
167 return false;
168 }
169
170 for (unsigned int i = 0; i < dimensions1.num_dimensions(); ++i)
171 {
172 if (dimensions1[i] != dimensions2[i])
173 {
174 return false;
175 }
176 }
177 }
178 else
179 {
180 // In case a 1D/2D shape becomes 3D after permutation, the permuted tensor will have two/one dimension(s) more and the first (two) value(s) will be 1
181 // clang-format off
182 const auto max_dims = std::max(dimensions1.num_dimensions(), dimensions2.num_dimensions());
183 for(unsigned int i = 3; i < max_dims; ++i)
184 {
185 if(dimensions1[i] != dimensions2[i])
186 {
187 return false;
188 }
189 }
190 // clang-format on
191
192 if ((dimensions1[0] != dimensions2[2]) || (dimensions1[1] != dimensions2[0]) ||
193 (dimensions1[2] != dimensions2[1]))
194 {
195 return false;
196 }
197 }
198
199 return true;
200}
201
202/** Validate valid regions.
203 *

Callers 4

validateFunction · 0.85
validate_wrapFunction · 0.85
Utils.cppFile · 0.85
TensorInfo.cppFile · 0.85

Calls 1

num_dimensionsMethod · 0.45

Tested by

no test coverage detected