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

Method HandleAllToAll

tensorflow/compiler/xla/service/hlo_verifier.cc:230–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230Status 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
274Status ShapeVerifier::HandlePartitionId(HloInstruction* hlo) {
275 return CheckShape(hlo, ShapeUtil::MakeShape(U32, {}));

Callers 1

VisitMethod · 0.45

Calls 10

CheckReplicaGroupsFunction · 0.85
split_dimensionMethod · 0.80
operand_countMethod · 0.80
InternalErrorFunction · 0.50
emptyMethod · 0.45
ToStringMethod · 0.45
shapeMethod · 0.45
operandMethod · 0.45
operandsMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected