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

Method Tuple

tensorflow/compiler/xla/service/hlo_sharding.cc:42–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42HloSharding HloSharding::Tuple(const ShapeTree<HloSharding>& sub_shardings) {
43 std::vector<HloSharding> flattened_list;
44 flattened_list.reserve(sub_shardings.leaf_count());
45 for (const auto& index_to_sharding : sub_shardings.leaves()) {
46 flattened_list.push_back(index_to_sharding.second);
47 }
48 if (flattened_list.empty()) {
49 // Empty tuple sharding ends up having no leaves, but we want to allow
50 // empty tuple HLO instruction results to have sharding, so we fetch the
51 // root ({}) sharding value from the ShapeTree.
52 // A ShapeTree created with ShapeTree<HloSharding>(shape, init) will have
53 // init as value at its root.
54 flattened_list.push_back(sub_shardings.element(ShapeIndex({})));
55 }
56 return HloSharding(flattened_list);
57}
58
59HloSharding HloSharding::Tuple(const Shape& tuple_shape,
60 absl::Span<const HloSharding> shardings) {

Callers

nothing calls this directly

Calls 12

ShapeIndexClass · 0.85
HloShardingClass · 0.85
leaf_countMethod · 0.80
leavesMethod · 0.80
reserveMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
IsTupleMethod · 0.45
ToStringMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected