instruction ::= ('ROOT')? name '=' shape opcode operands (attribute)
| 655 | |
| 656 | // instruction ::= ('ROOT')? name '=' shape opcode operands (attribute)* |
| 657 | bool HloParserImpl::ParseInstruction(HloComputation::Builder* builder, |
| 658 | std::string* root_name) { |
| 659 | std::string name; |
| 660 | LocTy maybe_root_loc = lexer_.GetLoc(); |
| 661 | bool is_root = EatIfPresent(TokKind::kw_ROOT); |
| 662 | |
| 663 | const LocTy name_loc = lexer_.GetLoc(); |
| 664 | if (!ParseName(&name) || |
| 665 | !ParseToken(TokKind::kEqual, "expects '=' in instruction")) { |
| 666 | return false; |
| 667 | } |
| 668 | |
| 669 | if (is_root) { |
| 670 | if (!root_name->empty()) { |
| 671 | return Error(maybe_root_loc, "one computation should have only one ROOT"); |
| 672 | } |
| 673 | *root_name = name; |
| 674 | } |
| 675 | |
| 676 | return ParseInstructionRhs(builder, name, name_loc); |
| 677 | } |
| 678 | |
| 679 | bool HloParserImpl::ParseInstructionRhs(HloComputation::Builder* builder, |
| 680 | const std::string& name, |