Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #22723: Fix call of overloaded Tile is ambiguous
Imported from GitHub PR #22723 #### Fix GCC-13 Build Error in AutoSharding Due to vector<vector> vs. absl::Span Ambiguity When building auto_sharding with GCC-13, the following build error occurred: ``` xla/hlo/experimental/auto_sharding/auto_sharding.cc:895:37: error: call of overloaded 'Tile(const xla::Shape&, <brace-enclosed initializer list>, <brace-enclosed initializer list>, const xla::spmd::DeviceMesh&)' is ambiguous 895 | HloSharding output_spec = Tile(shape, {i}, {j}, device_mesh); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ./xla/hlo/experimental/auto_sharding/cluster_environment.h:33, from ./xla/hlo/experimental/auto_sharding/auto_sharding.h:41: ./xla/hlo/experimental/auto_sharding/auto_sharding_util.h:499:13: note: candidate: 'xla::HloSharding xla::spmd::Tile(const xla::Shape&, absl::lts_20230802::Span<const long int>, const std::vector<std::vector<long int> >&, const DeviceMesh&)' 499 | HloSharding Tile(const Shape& tensor_shape, | ^~~~ ./xla/hlo/experimental/auto_sharding/auto_sharding_util.h:504:13: note: candidate: 'xla::HloSharding xla::spmd::Tile(const xla::Shape&, absl::lts_20230802::Span<const long int>, absl::lts_20230802::Span<const long int>, const DeviceMesh&)' 504 | HloSharding Tile(const Shape& tensor_shape, | ^~~~ ``` #### Solution: To resolve the ambiguity between `std::vector<std::vector<int64_t>>` and `absl::Span<const int64_t>` in `Tile()`, I introduced an overloaded Tile() function that takes `std::initializer_list<int64_t> mesh_dims`. Now, expressions like the following now compile successfully with GCC-13: ``` Tile(shape, {0}, {0}, device_mesh); ``` #### Additional Changes - Removed the `Tile()` declaration from `auto_sharding.h` since it is already declared in `auto_sharding_util.h`. Copybara import of the project: -- a28207f by Alexander Pivovarov <apivovarov@gmail.com>: Fix call of overloaded Tile is ambiguous Merging this change closes #22723 COPYBARA_INTEGRATE_REVIEW=#22723 from apivovarov:fix_Tile_init_list a28207f PiperOrigin-RevId: 728206576
- Loading branch information