| 170 | // - Comparing two shapes ignoring their layout and element type difference: |
| 171 | // Equal().IgnoreLayout().IgnoreElementType()(shape1, shape2); |
| 172 | class Equal { |
| 173 | public: |
| 174 | Equal() = default; |
| 175 | |
| 176 | bool operator()(const Shape& lhs, const Shape& rhs); |
| 177 | |
| 178 | Equal& IgnoreLayout() { |
| 179 | ignore_layout_ = true; |
| 180 | return *this; |
| 181 | } |
| 182 | Equal& IgnoreTilesInLayout() { |
| 183 | ignore_tiles_in_layout_ = true; |
| 184 | return *this; |
| 185 | } |
| 186 | Equal& IgnoreElementSizeInLayout() { |
| 187 | ignore_element_size_in_layout_ = true; |
| 188 | return *this; |
| 189 | } |
| 190 | Equal& IgnoreMemorySpaceInLayout() { |
| 191 | ignore_memory_space_in_layout_ = true; |
| 192 | return *this; |
| 193 | } |
| 194 | Equal& MinorToMajorOnlyInLayout() { |
| 195 | ignore_tiles_in_layout_ = true; |
| 196 | ignore_element_size_in_layout_ = true; |
| 197 | ignore_memory_space_in_layout_ = true; |
| 198 | return *this; |
| 199 | } |
| 200 | Equal& IgnoreElementType() { |
| 201 | ignore_element_type_ = true; |
| 202 | return *this; |
| 203 | } |
| 204 | Equal& IgnoreFpPrecision() { |
| 205 | ignore_fp_precision_ = true; |
| 206 | return *this; |
| 207 | } |
| 208 | Equal& IgnoreDynamicDimension() { |
| 209 | ignore_dynamic_dimension_ = true; |
| 210 | return *this; |
| 211 | } |
| 212 | |
| 213 | private: |
| 214 | bool ignore_layout_ = false; |
| 215 | bool ignore_tiles_in_layout_ = false; |
| 216 | bool ignore_element_size_in_layout_ = false; |
| 217 | bool ignore_memory_space_in_layout_ = false; |
| 218 | bool ignore_element_type_ = false; |
| 219 | bool ignore_fp_precision_ = false; |
| 220 | bool ignore_dynamic_dimension_ = false; |
| 221 | }; |
| 222 | |
| 223 | // Test that all fields of the shape are the same, equivalent to Equal(). |
| 224 | bool operator==(const Shape& other) const { return Equal()(*this, other); } |
no outgoing calls