@@ -97,9 +97,10 @@ HloSharding HloSharding::PartialTile(
9797 });
9898 Array<int64> sorted_tile (tile_assignment_last_dim_replicate.dimensions ());
9999 sorted_tile.Each ([&](absl::Span<const int64> indices, int64* device) {
100- auto begin = sorted_groups[get_group_id (indices)].begin ();
100+ const int64 group_id = get_group_id (indices);
101+ auto begin = sorted_groups[group_id].begin ();
101102 *device = *begin;
102- sorted_groups[get_group_id (indices) ].erase (begin);
103+ sorted_groups[group_id ].erase (begin);
103104 });
104105 return HloSharding (sorted_tile, /* replicate_on_last_tile_dim=*/ true ,
105106 metadata);
@@ -428,20 +429,19 @@ Status HloSharding::ValidateNonTuple(const Shape& shape,
428429 // unique.
429430 Status status = Status::OK ();
430431 absl::flat_hash_set<int64> seen_cores;
431- tile_assignment_.Each (
432- [&](absl::Span<const int64> indices, int32 core) {
433- // Don't overwrite a bad status, so we report the first error.
434- if (status.ok ()) {
435- if (core >= num_devices) {
436- status = tensorflow::errors::InvalidArgument (StrCat (
437- " core " , core, " > " , num_devices, " in tile assignment" ));
438- } else if (seen_cores.contains (core)) {
439- status = tensorflow::errors::InvalidArgument (
440- StrCat (" core " , core, " is not unique in tile assignment" ));
441- }
442- seen_cores.insert (core);
443- }
444- });
432+ tile_assignment_.Each ([&](absl::Span<const int64> indices, int32 core) {
433+ // Don't overwrite a bad status, so we report the first error.
434+ if (status.ok ()) {
435+ if (core >= num_devices) {
436+ status = tensorflow::errors::InvalidArgument (
437+ StrCat (" core " , core, " > " , num_devices, " in tile assignment" ));
438+ } else if (seen_cores.contains (core)) {
439+ status = tensorflow::errors::InvalidArgument (
440+ StrCat (" core " , core, " is not unique in tile assignment" ));
441+ }
442+ seen_cores.insert (core);
443+ }
444+ });
445445 if (!status.ok ()) {
446446 return status;
447447 }
0 commit comments