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

Method ParseDebugOpName

tensorflow/core/debug/debug_graph_utils.cc:361–410  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

359
360// static
361Status DebugNodeInserter::ParseDebugOpName(
362 const string& debug_op_name, string* debug_op_name_proper,
363 std::unordered_map<string, string>* attributes) {
364 const size_t l_index = debug_op_name.find('(');
365 const size_t r_index = debug_op_name.find(')');
366 if (l_index == string::npos && r_index == string::npos) {
367 *debug_op_name_proper = debug_op_name;
368 } else {
369 if (l_index == string::npos || l_index == 0 ||
370 r_index != debug_op_name.size() - 1) {
371 return errors::InvalidArgument("Malformed debug op name \"",
372 debug_op_name, "\"");
373 }
374
375 *debug_op_name_proper = debug_op_name.substr(0, l_index);
376 string arguments = debug_op_name.substr(l_index + 1, r_index - l_index - 1);
377
378 std::vector<string> attribute_segs = str_util::Split(arguments, ";");
379 for (const string& attribute_seg : attribute_segs) {
380 StringPiece seg(attribute_seg);
381 str_util::RemoveWhitespaceContext(&seg);
382 if (seg.empty()) {
383 continue;
384 }
385
386 const size_t eq_index = seg.find('=');
387 if (eq_index == string::npos) {
388 return errors::InvalidArgument(
389 "Malformed attributes in debug op name \"", debug_op_name, "\"");
390 }
391
392 const string key(seg.substr(0, eq_index));
393 const string value(
394 seg.substr(eq_index + 1, attribute_seg.size() - eq_index - 1));
395 if (key.empty() || value.empty()) {
396 return errors::InvalidArgument(
397 "Malformed attributes in debug op name \"", debug_op_name, "\"");
398 }
399
400 if (attributes->find(key) == attributes->end()) {
401 (*attributes)[key] = value;
402 } else {
403 return errors::InvalidArgument("Duplicate attribute name \"", key,
404 "\" found in the debug op: \"",
405 debug_op_name, "\"");
406 }
407 }
408 }
409 return Status::OK();
410}
411
412// static
413Status DebugNodeInserter::SetDebugNodeAttributes(

Callers

nothing calls this directly

Calls 7

InvalidArgumentFunction · 0.85
RemoveWhitespaceContextFunction · 0.85
SplitFunction · 0.50
findMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected