| 114 | } |
| 115 | |
| 116 | Status ValidateSignatureWithAttrs(const OpDef& sig, AttrSlice attr_values) { |
| 117 | // attr_values should specify all attrs defined in fdef. |
| 118 | for (const auto& a : sig.attr()) { |
| 119 | const AttrValue* v = attr_values.Find(a.name()); |
| 120 | if (!v) { |
| 121 | return errors::NotFound("Attr ", a.name(), " is not found from ", |
| 122 | SummarizeOpDef(sig)); |
| 123 | } |
| 124 | Status status = AttrValueHasType(*v, a.type()); |
| 125 | if (!status.ok()) { |
| 126 | errors::AppendToMessage(&status, "for attr '", a.name(), "'"); |
| 127 | return status; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // TODO(josh11b): Enable this code once it works with function gradients. |
| 132 | // Right now the C++ function gradient code assumes it can pass |
| 133 | // all the attrs of the function to the gradient, and any attrs that |
| 134 | // the gradient doesn't care about will be ignored. |
| 135 | #if 0 |
| 136 | if (attr_values.size() != sig.attr_size()) { |
| 137 | for (const auto& a : attr_values) { |
| 138 | // TODO(josh11b): Possibly should ignore attrs that start with "_" here? |
| 139 | bool found = false; |
| 140 | for (const auto& s : sig.attr()) { |
| 141 | if (a.first == s.name()) { |
| 142 | found = true; |
| 143 | break; |
| 144 | } |
| 145 | } |
| 146 | if (!found) { |
| 147 | return errors::NotFound("Attr ", a.first, " is not found in ", |
| 148 | SummarizeOpDef(sig)); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | #endif |
| 153 | |
| 154 | return Status::OK(); |
| 155 | } |
| 156 | |
| 157 | // A helper class for instantiating functions. This contains shared information |
| 158 | // like the resulting graph and node name index. |
no test coverage detected