MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Hash

Method Hash

tensorflow/compiler/xla/shape_util.cc:1459–1482  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 9

Hash64CombineFunction · 0.85
dimensions_sizeMethod · 0.80
is_dynamic_dimensionMethod · 0.80
HashClass · 0.50
element_typeMethod · 0.45
emptyMethod · 0.45
tuple_shapesMethod · 0.45
dimensionsMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected