| 1215 | } |
| 1216 | |
| 1217 | bool IntegerTensorEquals(const Tensor& left, const Tensor& right) { |
| 1218 | bool are_equal; |
| 1219 | // The arrays are the same object |
| 1220 | if (&left == &right) { |
| 1221 | are_equal = true; |
| 1222 | } else { |
| 1223 | const bool left_row_major_p = left.is_row_major(); |
| 1224 | const bool left_column_major_p = left.is_column_major(); |
| 1225 | const bool right_row_major_p = right.is_row_major(); |
| 1226 | const bool right_column_major_p = right.is_column_major(); |
| 1227 | |
| 1228 | if (!(left_row_major_p && right_row_major_p) && |
| 1229 | !(left_column_major_p && right_column_major_p)) { |
| 1230 | const auto& type = checked_cast<const FixedWidthType&>(*left.type()); |
| 1231 | are_equal = |
| 1232 | StridedIntegerTensorContentEquals(0, 0, 0, type.byte_width(), left, right); |
| 1233 | } else { |
| 1234 | const int byte_width = left.type()->byte_width(); |
| 1235 | DCHECK_GT(byte_width, 0); |
| 1236 | |
| 1237 | const uint8_t* left_data = left.data()->data(); |
| 1238 | const uint8_t* right_data = right.data()->data(); |
| 1239 | |
| 1240 | are_equal = memcmp(left_data, right_data, |
| 1241 | static_cast<size_t>(byte_width * left.size())) == 0; |
| 1242 | } |
| 1243 | } |
| 1244 | return are_equal; |
| 1245 | } |
| 1246 | |
| 1247 | template <typename DataType> |
| 1248 | bool StridedFloatTensorContentEquals(const int dim_index, int64_t left_offset, |
no test coverage detected