static
| 46 | |
| 47 | // static |
| 48 | Status DebugNodeInserter::InsertNodes( |
| 49 | const protobuf::RepeatedPtrField<DebugTensorWatch>& watches, Graph* graph, |
| 50 | Device* device) { |
| 51 | // TODO(cais): This method is getting too large in size. |
| 52 | // Refactor it with helpers. |
| 53 | |
| 54 | if (watches.empty()) { |
| 55 | // Nothing to do: Return OK right away. |
| 56 | return Status::OK(); |
| 57 | } |
| 58 | |
| 59 | // Debug ops and URLs for wildcard node names (if any). |
| 60 | std::vector<string> default_debug_ops; |
| 61 | std::vector<string> default_debug_urls; |
| 62 | |
| 63 | // A map from tensor name (e.g., "node_a:0") to list of debug op names |
| 64 | // (e.g., {"DebugIdentity", "DebugNanCount"}) |
| 65 | std::unordered_map<string, std::vector<string>> tensor_watches; |
| 66 | // A map from tensor name to debug_url. |
| 67 | std::unordered_map<string, std::vector<string>> tensor_watch_urls; |
| 68 | std::unordered_map<string, bool> tensor_tolerate_failures; |
| 69 | |
| 70 | // Cache the proto content for fast lookup later |
| 71 | for (const DebugTensorWatch& watch : watches) { |
| 72 | if (watch.debug_ops().empty()) { |
| 73 | continue; |
| 74 | } |
| 75 | |
| 76 | if (watch.debug_urls().empty()) { |
| 77 | continue; |
| 78 | } |
| 79 | |
| 80 | if (watch.node_name() == "*") { |
| 81 | if (watch.output_slot() == -1) { |
| 82 | default_debug_ops.insert(default_debug_ops.end(), |
| 83 | watch.debug_ops().begin(), |
| 84 | watch.debug_ops().end()); |
| 85 | default_debug_urls.insert(default_debug_urls.end(), |
| 86 | watch.debug_urls().begin(), |
| 87 | watch.debug_urls().end()); |
| 88 | } else { |
| 89 | return Status(error::FAILED_PRECONDITION, |
| 90 | strings::StrCat( |
| 91 | "output_slot is expected to be -1 for wildcard ", |
| 92 | "node name (\"*\"), but got ", watch.output_slot())); |
| 93 | } |
| 94 | continue; |
| 95 | } else { |
| 96 | if (watch.output_slot() < 0) { |
| 97 | return Status( |
| 98 | error::FAILED_PRECONDITION, |
| 99 | strings::StrCat("A negative output_slot in DebugTensorWatch is ", |
| 100 | "valid only for the wildcard node name (\"*\"), ", |
| 101 | "but got node name ", watch.node_name())); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | string tensor_name = |
nothing calls this directly
no test coverage detected