| 464 | } |
| 465 | |
| 466 | std::pair<HloInstruction*, HloParserImpl::LocTy>* |
| 467 | HloParserImpl::FindInstruction(const std::string& name, |
| 468 | const optional<Shape>& shape) { |
| 469 | std::pair<HloInstruction*, LocTy>* instr = nullptr; |
| 470 | if (!name.empty()) { |
| 471 | instr = tensorflow::gtl::FindOrNull(current_name_table(), name); |
| 472 | } |
| 473 | |
| 474 | // Potentially call the missing instruction hook. |
| 475 | if (instr == nullptr && create_missing_instruction_ != nullptr && |
| 476 | scoped_name_tables_.size() == 1) { |
| 477 | if (!shape.has_value()) { |
| 478 | Error(lexer_.GetLoc(), |
| 479 | "Operand had no shape in HLO text; cannot create parameter for " |
| 480 | "single-instruction module."); |
| 481 | return nullptr; |
| 482 | } |
| 483 | return create_missing_instruction_(name, *shape); |
| 484 | } |
| 485 | |
| 486 | if (instr != nullptr && shape.has_value() && |
| 487 | !ShapeUtil::Compatible(instr->first->shape(), shape.value())) { |
| 488 | Error( |
| 489 | lexer_.GetLoc(), |
| 490 | StrCat("The declared operand shape ", |
| 491 | ShapeUtil::HumanStringWithLayout(shape.value()), |
| 492 | " is not compatible with the shape of the operand instruction ", |
| 493 | ShapeUtil::HumanStringWithLayout(instr->first->shape()), ".")); |
| 494 | return nullptr; |
| 495 | } |
| 496 | |
| 497 | return instr; |
| 498 | } |
| 499 | |
| 500 | // ::= 'HloModule' name computations |
| 501 | bool HloParserImpl::ParseHloModule(HloModule* module) { |
nothing calls this directly
no test coverage detected