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

Method Finalize

tensorflow/core/framework/node_def_builder.cc:214–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214Status NodeDefBuilder::Finalize(NodeDef* node_def, bool consume) {
215 const std::vector<string>* errors_ptr = &errors_;
216 std::vector<string> errors_storage;
217 if (op_def_ != nullptr && inputs_specified_ < op_def_->input_arg_size()) {
218 // Since this is a const method, to add an error, we have to make
219 // a copy of the existing errors.
220 errors_storage = errors_;
221 errors_storage.push_back(
222 strings::StrCat(inputs_specified_, " inputs specified of ",
223 op_def_->input_arg_size(), " inputs in Op"));
224 errors_ptr = &errors_storage;
225 }
226
227 if (!errors_ptr->empty()) {
228 if (errors_ptr->size() == 1) {
229 if (op_def_ == nullptr) {
230 return errors::InvalidArgument((*errors_ptr)[0],
231 " while building NodeDef '",
232 node_def_.name(), "'");
233 }
234 return errors::InvalidArgument(
235 (*errors_ptr)[0], " while building NodeDef '", node_def_.name(),
236 "' using ", SummarizeOpDef(*op_def_));
237 } else {
238 return errors::InvalidArgument(
239 errors_ptr->size(), " errors while building NodeDef '",
240 node_def_.name(), "' using ", SummarizeOpDef(*op_def_), ":\n",
241 absl::StrJoin(*errors_ptr, "\n"));
242 }
243 } else {
244 NodeDef node_def_backup;
245 if (node_def == nullptr) node_def = &node_def_backup;
246 if (consume) {
247 *node_def = std::move(node_def_);
248 } else {
249 *node_def = node_def_;
250 }
251
252 // Add control inputs after the regular inputs.
253 for (const auto& control_input : control_inputs_) {
254 node_def->add_input(strings::StrCat("^", control_input));
255 }
256
257 // Add default values for unspecified attrs.
258 AddDefaultsToNodeDef(*op_def_, node_def);
259
260 return Status::OK();
261 }
262}
263
264bool NodeDefBuilder::AttrValueAlreadyPresent(StringPiece name,
265 const AttrValue& value) {

Callers

nothing calls this directly

Calls 9

InvalidArgumentFunction · 0.85
SummarizeOpDefFunction · 0.85
AddDefaultsToNodeDefFunction · 0.85
nameMethod · 0.65
StrCatFunction · 0.50
push_backMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
add_inputMethod · 0.45

Tested by

no test coverage detected