| 228 | } |
| 229 | |
| 230 | Status ShapeVerifier::HandleAllToAll(HloInstruction* hlo) { |
| 231 | TF_RETURN_IF_ERROR(CheckReplicaGroups(hlo)); |
| 232 | |
| 233 | auto* all_to_all = Cast<HloAllToAllInstruction>(hlo); |
| 234 | TF_RET_CHECK(all_to_all != nullptr); |
| 235 | if (all_to_all->split_dimension()) { |
| 236 | if (hlo->replica_groups().empty()) { |
| 237 | return InternalError( |
| 238 | "An array all-to-all must have an explicit replica_groups config"); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // The size of each replica group must be the same (the split count of the |
| 243 | // operaion). In case the default replica group is used (empty replica group, |
| 244 | // must not be an array all-to-all, as checked above), infer from the number |
| 245 | // of operands. |
| 246 | const int64 split_count = hlo->replica_groups().empty() |
| 247 | ? hlo->operand_count() |
| 248 | : hlo->replica_groups()[0].replica_ids_size(); |
| 249 | for (const ReplicaGroup& g : hlo->replica_groups()) { |
| 250 | if (g.replica_ids_size() != split_count) { |
| 251 | return InternalError( |
| 252 | "Replica group has size %d, but all replica groups in an all-to-all " |
| 253 | "must have size N: %s", |
| 254 | g.replica_ids_size(), hlo->ToString()); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | if (all_to_all->split_dimension()) { |
| 259 | TF_RET_CHECK(hlo->operand_count() == 1); |
| 260 | return CheckShape( |
| 261 | hlo, ShapeInference::InferAllToAllShape( |
| 262 | hlo->operand(0)->shape(), *all_to_all->split_dimension(), |
| 263 | *all_to_all->split_dimension(), split_count)); |
| 264 | } else { |
| 265 | std::vector<const Shape*> operand_shapes; |
| 266 | for (const HloInstruction* operand : hlo->operands()) { |
| 267 | operand_shapes.push_back(&operand->shape()); |
| 268 | } |
| 269 | return CheckShape(hlo, |
| 270 | ShapeInference::InferAllToAllTupleShape(operand_shapes)); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | Status ShapeVerifier::HandlePartitionId(HloInstruction* hlo) { |
| 275 | return CheckShape(hlo, ShapeUtil::MakeShape(U32, {})); |
no test coverage detected