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

Function IsGradNode

tensorflow/core/profiler/internal/tfprof_code.cc:50–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50bool IsGradNode(const string& name, string* forward_name) {
51 // Given a forward operation with name op, its gradient op has the following
52 // name: ...gradients/op_grad/...
53 // TODO(xpan): This is hacky.
54 auto grad_prefix = name.find("gradients/");
55 auto grad_suffix = name.find("_grad/");
56 if (grad_prefix == name.npos || grad_suffix == name.npos) {
57 return false;
58 }
59 auto start = grad_prefix + string("gradients/").length();
60 auto len = grad_suffix - start;
61 if (len <= 0) {
62 return false;
63 }
64 *forward_name = name.substr(start, len);
65 return true;
66}
67
68// StringTable maps each string to an id.
69class StringTable {

Callers 1

AddNodeMethod · 0.85

Calls 2

findMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected