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

Method SetDebugNodeAttributes

tensorflow/core/debug/debug_graph_utils.cc:413–468  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

411
412// static
413Status DebugNodeInserter::SetDebugNodeAttributes(
414 Node* debug_node, const std::unordered_map<string, string>& attributes) {
415 std::unordered_set<string> unfulfilled_keys;
416 for (const auto& item : attributes) {
417 unfulfilled_keys.insert(item.first);
418 }
419
420 for (const auto& attr : debug_node->op_def().attr()) {
421 if (attributes.find(attr.name()) != attributes.end()) {
422 const string& attr_value = attributes.at(attr.name());
423 if (attr.type() == "string") {
424 debug_node->AddAttr<string>(attr.name(), attr_value);
425 } else if (attr.type() == "float") {
426 float float_value = 0.0;
427 if (!::tensorflow::strings::safe_strtof(attr_value.c_str(),
428 &float_value)) {
429 return errors::InvalidArgument(
430 "Invalid value string for float-type attribute ", attr.name(),
431 "of debug node ", debug_node->name(), ": \"", attr_value, "\"");
432 }
433 debug_node->AddAttr<float>(attr.name(), float_value);
434 } else if (attr.type() == "int") {
435 int64 int_value = 0;
436 if (!::tensorflow::strings::safe_strto64(attr_value, &int_value)) {
437 return errors::InvalidArgument(
438 "Invalid value string for int-type attribute ", attr.name(),
439 "of debug node ", debug_node->name(), ": \"", attr_value, "\"");
440 }
441 debug_node->AddAttr<int>(attr.name(), int_value);
442 } else if (attr.type() == "bool") {
443 bool bool_value;
444 if (!ParseBoolString(attr_value, &bool_value).ok()) {
445 return errors::InvalidArgument(
446 "Invalid value string for bool-type attribute ", attr.name(),
447 "of debug node ", debug_node->name(), ": \"", attr_value, "\"");
448 }
449 debug_node->AddAttr<bool>(attr.name(), bool_value);
450 } else {
451 return errors::InvalidArgument(
452 "Unsupported type of custom attribute for debug ops: ",
453 attr.type());
454 }
455
456 unfulfilled_keys.erase(attr.name());
457 }
458 }
459
460 if (unfulfilled_keys.empty()) {
461 return Status::OK();
462 } else {
463 return errors::InvalidArgument(
464 unfulfilled_keys.size(),
465 " attribute key(s) were not valid for debug node ", debug_node->name(),
466 ": ", absl::StrJoin(unfulfilled_keys, ", "));
467 }
468}
469
470// static

Callers

nothing calls this directly

Calls 15

safe_strtofFunction · 0.85
InvalidArgumentFunction · 0.85
safe_strto64Function · 0.85
ParseBoolStringFunction · 0.85
attrMethod · 0.80
c_strMethod · 0.80
nameMethod · 0.65
typeMethod · 0.65
insertMethod · 0.45
op_defMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected