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

Method Find

tensorflow/core/framework/node_def_util.cc:176–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176const AttrValue* AttrSlice::Find(StringPiece attr_name) const {
177 // Currently, the collection used for NodeDef::attr() (google::protobuf::Map)
178 // requires that the keys used for lookups have type 'const string&'. Because
179 // this method takes a StringPiece, it is necessary to allocate a temporary
180 // string, copy attr_name to it, and then use that temporary string for the
181 // lookup. This causes an excessive number of short-lived allocations, and for
182 // large graphs, this can be a significant cost.
183 //
184 // Because most nodes have a small number of attributes, a simple linear scan
185 // is generally more efficient than a hashed lookup. If google::protobuf::Map
186 // changes so that it supports efficient lookups using StringPiece instead of
187 // const string&, then this code could be changed to use attrs_->find() again.
188
189 for (const auto& attr : *attrs_) {
190 if (attr.first == attr_name) {
191 return &attr.second;
192 }
193 }
194 return nullptr;
195}
196
197Status AttrSlice::Find(StringPiece attr_name,
198 const AttrValue** attr_value) const {

Callers 5

SummarizeAttrsHelperFunction · 0.45
node_def_util.ccFile · 0.45
AddArgToSigFunction · 0.45
ComputeArgRangeFunction · 0.45
AddDefaultsToNodeDefFunction · 0.45

Calls 4

FindFunction · 0.85
NotFoundFunction · 0.85
StartsWithFunction · 0.85
AttachDefFunction · 0.85

Tested by

no test coverage detected