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

Function OpDefAddedDefaultsUnchanged

tensorflow/core/framework/op_def_util.cc:675–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675Status OpDefAddedDefaultsUnchanged(const OpDef& old_op,
676 const OpDef& penultimate_op,
677 const OpDef& new_op) {
678 AttrMap new_attrs, old_attrs;
679 FillAttrMap(old_op, &old_attrs);
680 FillAttrMap(new_op, &new_attrs);
681
682 for (const auto& penultimate_attr : penultimate_op.attr()) {
683 const OpDef::AttrDef* old_attr =
684 gtl::FindPtrOrNull(old_attrs, penultimate_attr.name());
685 if (old_attr != nullptr) continue; // attr wasn't added
686 const OpDef::AttrDef* new_attr =
687 gtl::FindPtrOrNull(new_attrs, penultimate_attr.name());
688
689 // These shouldn't happen if the op passed OpDefCompatible().
690 if (new_attr == nullptr) {
691 return errors::InvalidArgument("Missing attr '", penultimate_attr.name(),
692 "' in op: ", SummarizeOpDef(new_op));
693 }
694 if (!penultimate_attr.has_default_value() ||
695 !new_attr->has_default_value()) {
696 return errors::InvalidArgument("Missing default for attr '",
697 penultimate_attr.name(),
698 "' in op: ", SummarizeOpDef(new_op));
699 }
700
701 // Actually test that the attr's default value hasn't changed.
702 if (!AreAttrValuesEqual(penultimate_attr.default_value(),
703 new_attr->default_value())) {
704 return errors::InvalidArgument(
705 "Can't change default value for attr '", penultimate_attr.name(),
706 "' from ", SummarizeAttrValue(penultimate_attr.default_value()),
707 " in op: ", SummarizeOpDef(new_op));
708 }
709 }
710
711 return Status::OK();
712}
713
714Status OpDefAttrDefaultsUnchanged(const OpDef& old_op, const OpDef& new_op) {
715 AttrMap new_attrs, old_attrs;

Callers 1

ValidateCompatibleMethod · 0.85

Calls 10

FillAttrMapFunction · 0.85
FindPtrOrNullFunction · 0.85
InvalidArgumentFunction · 0.85
SummarizeOpDefFunction · 0.85
AreAttrValuesEqualFunction · 0.85
SummarizeAttrValueFunction · 0.85
attrMethod · 0.80
has_default_valueMethod · 0.80
nameMethod · 0.65
default_valueMethod · 0.45

Tested by

no test coverage detected