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

Method SetAllocAttrs

tensorflow/core/common_runtime/graph_view.cc:404–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402} // namespace
403
404Status GraphView::SetAllocAttrs(const Graph* g, const Device* device) {
405 Status s;
406 DeviceNameUtils::ParsedName local_dev_name = device->parsed_name();
407
408 std::vector<const Node*> scoped_allocator_instances;
409 for (const Node* n : g->nodes()) {
410 NodeItem* item = node(n->id());
411 AllocatorAttributes* attrs = item->output_attr_base();
412 if (IsScopedAllocator(n)) {
413 scoped_allocator_instances.push_back(n);
414 }
415
416 // Examine the out edges of each node looking for special use
417 // cases that may affect memory allocation attributes.
418 for (const auto& e : n->out_edges()) {
419 if (!e->IsControlEdge()) {
420 AllocatorAttributes attr;
421 s = InferAllocAttr(n, e->dst(), local_dev_name, &attr);
422 if (!s.ok()) return s;
423 if (attr.value != 0 || attr.scope_id != 0) {
424 attrs[e->src_output()].Merge(attr);
425 }
426 }
427 }
428
429 for (int out = 0; out < n->num_outputs(); out++) {
430 const OpKernel* op_kernel = item->kernel;
431 DCHECK_LT(out, op_kernel->output_memory_types().size());
432 bool on_host = op_kernel->output_memory_types()[out] == HOST_MEMORY;
433 if (on_host) {
434 AllocatorAttributes h;
435 h.set_on_host(on_host);
436 attrs[out].Merge(h);
437 }
438 }
439 }
440 SetScopedAllocatorAttrs(scoped_allocator_instances);
441 return s;
442}
443
444} // namespace tensorflow
445

Callers 1

InitializeMethod · 0.80

Calls 14

IsScopedAllocatorFunction · 0.85
InferAllocAttrFunction · 0.85
output_attr_baseMethod · 0.80
set_on_hostMethod · 0.80
nodesMethod · 0.45
idMethod · 0.45
push_backMethod · 0.45
IsControlEdgeMethod · 0.45
dstMethod · 0.45
okMethod · 0.45
MergeMethod · 0.45
src_outputMethod · 0.45

Tested by

no test coverage detected