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

Method ParseComputations

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

computations ::= (computation)+

Source from the content-addressed store, hash-verified

531
532// computations ::= (computation)+
533bool HloParserImpl::ParseComputations(HloModule* module) {
534 HloComputation* entry_computation = nullptr;
535 do {
536 if (!ParseComputation(&entry_computation)) {
537 return false;
538 }
539 } while (lexer_.GetKind() != TokKind::kEof);
540
541 for (int i = 0; i < computations_.size(); i++) {
542 // If entry_computation is not nullptr, it means the computation it pointed
543 // to is marked with "ENTRY"; otherwise, no computation is marked with
544 // "ENTRY", and we use the last computation as the entry computation. We
545 // add the non-entry computations as embedded computations to the module.
546 if ((entry_computation != nullptr &&
547 computations_[i].get() != entry_computation) ||
548 (entry_computation == nullptr && i != computations_.size() - 1)) {
549 module->AddEmbeddedComputation(std::move(computations_[i]));
550 continue;
551 }
552 auto computation = module->AddEntryComputation(std::move(computations_[i]));
553 // The parameters and result layouts were set to default layout. Here we
554 // set the layouts to what the hlo text says.
555 for (int p = 0; p < computation->num_parameters(); p++) {
556 const Shape& param_shape = computation->parameter_instruction(p)->shape();
557 TF_CHECK_OK(module->mutable_entry_computation_layout()
558 ->mutable_parameter_layout(p)
559 ->CopyLayoutFromShape(param_shape));
560 }
561 const Shape& result_shape = computation->root_instruction()->shape();
562 TF_CHECK_OK(module->mutable_entry_computation_layout()
563 ->mutable_result_layout()
564 ->CopyLayoutFromShape(result_shape));
565 }
566 return true;
567}
568
569// computation ::= ('ENTRY')? name (param_list_to_shape)? instruction_list
570bool HloParserImpl::ParseComputation(HloComputation** entry_computation) {

Callers

nothing calls this directly

Calls 13

GetKindMethod · 0.80
AddEntryComputationMethod · 0.80
num_parametersMethod · 0.80
parameter_instructionMethod · 0.80
CopyLayoutFromShapeMethod · 0.80
root_instructionMethod · 0.80
mutable_result_layoutMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected