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

Method ParseComputation

tensorflow/compiler/xla/service/hlo_parser.cc:570–611  ·  view source on GitHub ↗

computation ::= ('ENTRY')? name (param_list_to_shape)? instruction_list

Source from the content-addressed store, hash-verified

568
569// computation ::= ('ENTRY')? name (param_list_to_shape)? instruction_list
570bool HloParserImpl::ParseComputation(HloComputation** entry_computation) {
571 LocTy maybe_entry_loc = lexer_.GetLoc();
572 const bool is_entry_computation = EatIfPresent(TokKind::kw_ENTRY);
573
574 std::string name;
575 LocTy name_loc = lexer_.GetLoc();
576 if (!ParseName(&name)) {
577 return false;
578 }
579
580 LocTy shape_loc = nullptr;
581 Shape shape;
582 if (CanBeParamListToShape() && !ParseParamListToShape(&shape, &shape_loc)) {
583 return false;
584 }
585
586 HloComputation* computation = nullptr;
587 if (!ParseInstructionList(&computation, name)) {
588 return false;
589 }
590
591 // If param_list_to_shape was present, check compatibility.
592 if (shape_loc != nullptr &&
593 !ShapeUtil::Compatible(computation->root_instruction()->shape(), shape)) {
594 return Error(
595 shape_loc,
596 StrCat(
597 "Shape of computation ", name, ", ", ShapeUtil::HumanString(shape),
598 ", is not compatible with that of its root instruction ",
599 computation->root_instruction()->name(), ", ",
600 ShapeUtil::HumanString(computation->root_instruction()->shape())));
601 }
602
603 if (is_entry_computation) {
604 if (*entry_computation != nullptr) {
605 return Error(maybe_entry_loc, "expects only one ENTRY");
606 }
607 *entry_computation = computation;
608 }
609
610 return AddComputation(name, computation, name_loc);
611}
612
613// instruction_list ::= '{' instruction_list1 '}'
614// instruction_list1 ::= (instruction)+

Callers

nothing calls this directly

Calls 7

CompatibleClass · 0.85
GetLocMethod · 0.80
root_instructionMethod · 0.80
nameMethod · 0.65
ErrorFunction · 0.50
StrCatFunction · 0.50
shapeMethod · 0.45

Tested by

no test coverage detected