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

Function KernelAttrsMatch

tensorflow/core/framework/kernel_def_util.cc:36–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34} // namespace
35
36Status KernelAttrsMatch(const KernelDef& kernel_def, AttrSlice attrs,
37 bool* match) {
38 *match = false;
39 for (const auto& constraint : kernel_def.constraint()) {
40 if (constraint.allowed_values().list().type_size() == 0) {
41 return errors::Unimplemented(
42 "KernelDef '", ProtoShortDebugString(kernel_def),
43 " has constraint on attr '", constraint.name(),
44 "' with unsupported type: ",
45 SummarizeAttrValue(constraint.allowed_values()));
46 }
47
48 const AttrValue* found = attrs.Find(constraint.name());
49 if (found) {
50 if (found->type() != DT_INVALID) {
51 if (!InTypeList(found->type(), constraint.allowed_values())) {
52 return Status::OK();
53 }
54 } else {
55 if (!AttrValueHasType(*found, "list(type)").ok()) {
56 return errors::InvalidArgument(
57 "KernelDef '", ProtoShortDebugString(kernel_def),
58 "' has constraint on attr '", constraint.name(),
59 "' that has value '", SummarizeAttrValue(*found),
60 "' that does not have type 'type' or 'list(type)' in NodeDef "
61 "'",
62 attrs.SummarizeNode(), "'");
63 }
64
65 for (int t : found->list().type()) {
66 if (!InTypeList(static_cast<DataType>(t),
67 constraint.allowed_values())) {
68 return Status::OK();
69 }
70 }
71 }
72 } else {
73 return errors::InvalidArgument(
74 "OpKernel '", kernel_def.op(), "' has constraint on attr '",
75 constraint.name(), "' not in NodeDef '", attrs.SummarizeNode(),
76 "', KernelDef: '", ProtoShortDebugString(kernel_def), "'");
77 }
78 }
79 *match = true;
80 return Status::OK();
81}
82
83} // namespace tensorflow

Callers 2

FindKernelRegistrationFunction · 0.85
ExpectStatusMethod · 0.85

Calls 13

UnimplementedFunction · 0.85
SummarizeAttrValueFunction · 0.85
InTypeListFunction · 0.85
AttrValueHasTypeFunction · 0.85
InvalidArgumentFunction · 0.85
listMethod · 0.80
SummarizeNodeMethod · 0.80
nameMethod · 0.65
typeMethod · 0.65
constraintMethod · 0.45
FindMethod · 0.45
okMethod · 0.45

Tested by 1

ExpectStatusMethod · 0.68