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

Function GenerateMetadata

tensorflow/compiler/aot/codegen.cc:699–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697}
698
699Status GenerateMetadata(const CodegenOpts& opts,
700 const CompileResult& compile_result,
701 MetadataResult* metadata_result) {
702 std::unique_ptr<xla::ProgramShapeProto> program_shape;
703
704 if (opts.gen_program_shape) {
705 program_shape =
706 absl::make_unique<xla::ProgramShapeProto>(compile_result.program_shape);
707
708 // The parameter names are currently meaningless, and redundant with the
709 // rest of our metadata, so clear them out to avoid confusion and save
710 // space.
711 program_shape->clear_parameter_names();
712 }
713
714 // When asked to serialize a null protobuf, CreateEmbeddedProtocolBuffer gives
715 // a shim that evaluates to nullptr, which is what we want.
716
717 ProtobufToEmbed program_shape_protobuf{
718 CreateUniqueIdentifier(opts, "ProgramShapeProto"),
719 "::xla::ProgramShapeProto", program_shape.get()};
720
721 ProtobufToEmbed hlo_profile_printer_data_protobuf{
722 CreateUniqueIdentifier(opts, "HloProfilePrinterData"),
723 "::xla::HloProfilePrinterData",
724 compile_result.aot->hlo_profile_printer_data()};
725
726 TF_ASSIGN_OR_RETURN(
727 EmbeddedProtocolBuffers embedded_protobufs,
728 CreateEmbeddedProtocolBuffers(
729 opts.target_triple,
730 {program_shape_protobuf, hlo_profile_printer_data_protobuf}));
731
732 metadata_result->program_shape_access_shim =
733 std::move(embedded_protobufs.cpp_shims[0].expression);
734 metadata_result->hlo_profile_printer_data_access_shim =
735 std::move(embedded_protobufs.cpp_shims[1].expression);
736 metadata_result->header_variable_decls.emplace_back(
737 std::move(embedded_protobufs.cpp_shims[0].variable_decl));
738 metadata_result->header_variable_decls.emplace_back(
739 std::move(embedded_protobufs.cpp_shims[1].variable_decl));
740 metadata_result->object_file_data =
741 std::move(embedded_protobufs.object_file_data);
742 return Status::OK();
743}
744
745Status ParseCppClass(const string& cpp_class, string* class_name,
746 std::vector<string>* namespaces) {

Callers 2

MainFunction · 0.85
TESTFunction · 0.85

Calls 5

CreateUniqueIdentifierFunction · 0.85
clear_parameter_namesMethod · 0.80
getMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

TESTFunction · 0.68