| 280 | } |
| 281 | |
| 282 | Status ShapeVerifier::HandleCollectivePermute(HloInstruction* hlo) { |
| 283 | // A source or target cannot appear twice in the collective-permute's |
| 284 | // source-target pairs. |
| 285 | absl::flat_hash_set<int64> seen_sources; |
| 286 | absl::flat_hash_set<int64> seen_targets; |
| 287 | for (const auto& p : hlo->source_target_pairs()) { |
| 288 | if (!seen_sources.insert(p.first).second) { |
| 289 | return InternalError( |
| 290 | "Source %d appears more than once in instruction's source-target " |
| 291 | "pairs: %s", |
| 292 | p.first, hlo->ToString()); |
| 293 | } |
| 294 | if (!seen_targets.insert(p.second).second) { |
| 295 | return InternalError( |
| 296 | "Target %d appears more than once in instruction's source-target " |
| 297 | "pairs: %s", |
| 298 | p.second, hlo->ToString()); |
| 299 | } |
| 300 | } |
| 301 | return CheckShape(hlo, ShapeInference::InferCollectivePermuteShape( |
| 302 | hlo->operand(0)->shape())); |
| 303 | } |
| 304 | |
| 305 | Status ShapeVerifier::HandleReducePrecision(HloInstruction* reduce_precision) { |
| 306 | return CheckShape(reduce_precision, ShapeInference::InferReducePrecisionShape( |