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

Method OpInfo

tensorflow/cc/framework/cc_op_gen.cc:550–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548};
549
550OpInfo::OpInfo(const OpDef& graph_op_def, const ApiDef& api_def,
551 const std::vector<string>& aliases)
552 : graph_op_def(graph_op_def), api_def(api_def), aliases(aliases) {
553 op_name = api_def.endpoint(0).name();
554 InferOpAttributes(graph_op_def, &inferred_input_attrs);
555 has_optional_attrs = HasOptionalAttrs(api_def, inferred_input_attrs);
556 arg_types.push_back("const ::tensorflow::Scope&");
557 arg_names.push_back("scope");
558
559 if (graph_op_def.has_deprecation()) {
560 if (!api_def.summary().empty()) {
561 comment = strings::StrCat(api_def.summary(), "\n");
562 }
563 strings::StrAppend(&comment, "DEPRECATED at GraphDef version ",
564 graph_op_def.deprecation().version(), ":\n",
565 graph_op_def.deprecation().explanation(), ".\n");
566 } else if (api_def.summary().empty()) {
567 comment = "TODO: add doc.\n";
568 } else {
569 comment = strings::StrCat(api_def.summary(), "\n");
570 }
571 if (!api_def.description().empty()) {
572 strings::StrAppend(&comment, "\n", api_def.description(), "\n");
573 }
574 strings::StrAppend(&comment, "\nArguments:\n* scope: A Scope object\n");
575
576 // Process inputs
577 for (int i = 0; i < api_def.arg_order_size(); ++i) {
578 const auto& arg = *FindInputArg(api_def.arg_order(i), graph_op_def);
579 const auto& api_def_arg = *FindInputArg(api_def.arg_order(i), api_def);
580 arg_types.push_back(strings::StrCat(
581 "::tensorflow::", ArgIsList(arg) ? "InputList" : "Input"));
582 arg_names.push_back(AvoidCPPKeywords(api_def_arg.rename_to()));
583
584 // TODO(keveman): Include input type information.
585 StringPiece description = api_def_arg.description();
586 if (!description.empty()) {
587 ConsumeEquals(&description);
588 strings::StrAppend(&comment, "* ",
589 AvoidCPPKeywords(api_def_arg.rename_to()), ": ",
590 api_def_arg.description(), "\n");
591 }
592 }
593
594 // Process attrs
595 string required_attrs_comment;
596 string optional_attrs_comment;
597 for (int i = 0; i < graph_op_def.attr_size(); ++i) {
598 // ApiDef attributes must be in the same order as in OpDef since
599 // we initialize ApiDef based on OpDef.
600 const auto& attr(graph_op_def.attr(i));
601 const auto& api_def_attr(api_def.attr(i));
602 CHECK_EQ(attr.name(), api_def_attr.name());
603 // Skip inferred arguments
604 if (inferred_input_attrs.count(attr.name()) > 0) continue;
605
606 const auto entry = AttrTypeName(attr.type());
607 const auto attr_type_name = entry.first;

Callers

nothing calls this directly

Calls 15

InferOpAttributesFunction · 0.85
HasOptionalAttrsFunction · 0.85
FindInputArgFunction · 0.85
ArgIsListFunction · 0.85
AvoidCPPKeywordsFunction · 0.85
ConsumeEqualsFunction · 0.85
AttrTypeNameFunction · 0.85
MakeCommentFunction · 0.85
descriptionMethod · 0.80
has_default_valueMethod · 0.80
nameMethod · 0.65
typeMethod · 0.65

Tested by

no test coverage detected