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

Method FindInstruction

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

Source from the content-addressed store, hash-verified

464}
465
466std::pair<HloInstruction*, HloParserImpl::LocTy>*
467HloParserImpl::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
501bool HloParserImpl::ParseHloModule(HloModule* module) {

Callers

nothing calls this directly

Calls 10

FindOrNullFunction · 0.85
CompatibleClass · 0.85
GetLocMethod · 0.80
ErrorFunction · 0.50
StrCatFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
has_valueMethod · 0.45
shapeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected