static*/
| 1457 | } |
| 1458 | |
| 1459 | /*static*/ size_t ShapeUtil::Hash(const Shape& shape) { |
| 1460 | using tensorflow::hash; |
| 1461 | using tensorflow::Hash64Combine; |
| 1462 | |
| 1463 | size_t hash_value = hash<PrimitiveType>()(shape.element_type()); |
| 1464 | |
| 1465 | if (shape.tuple_shapes().empty()) { |
| 1466 | for (int i = 0; i < shape.dimensions_size(); ++i) { |
| 1467 | hash_value = |
| 1468 | Hash64Combine(hash_value, hash<int64>()(shape.dimensions(i))); |
| 1469 | hash_value = Hash64Combine(hash_value, |
| 1470 | hash<bool>()(shape.is_dynamic_dimension(i))); |
| 1471 | } |
| 1472 | |
| 1473 | hash_value = Hash64Combine(hash_value, LayoutUtil::Hash(shape.layout())); |
| 1474 | } else { |
| 1475 | hash_value = 0; |
| 1476 | for (const Shape& subshape : shape.tuple_shapes()) { |
| 1477 | hash_value = Hash64Combine(hash_value, ShapeUtil::Hash(subshape)); |
| 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | return hash_value; |
| 1482 | } |
| 1483 | |
| 1484 | // Returns the indices of the first elements of all consecutive subarrays of the |
| 1485 | // given array. For example: |
nothing calls this directly
no test coverage detected