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

Function BuildMemoryDeviceInfo

tensorflow/core/graph/graph_partition.cc:1193–1220  ·  view source on GitHub ↗

Build memory and device type info for every node in the graph. TODO(yuanbyu): It might be simpler if we convert MemoryType to DeviceType for the inputs/outputs of each node.

Source from the content-addressed store, hash-verified

1191// TODO(yuanbyu): It might be simpler if we convert MemoryType to
1192// DeviceType for the inputs/outputs of each node.
1193Status BuildMemoryDeviceInfo(const Graph& g, GraphInfo* info) {
1194 MemoryTypeVector input_memory_types;
1195 MemoryTypeVector output_memory_types;
1196
1197 info->device_types.resize(g.num_node_ids(), DEVICE_CPU);
1198 for (const Node* node : g.op_nodes()) {
1199 DeviceNameUtils::ParsedName parsed;
1200 if (!DeviceNameUtils::ParseFullName(node->assigned_device_name(),
1201 &parsed)) {
1202 return errors::Internal("Malformed assigned device '",
1203 node->assigned_device_name(), "'");
1204 }
1205
1206 TF_RETURN_IF_ERROR(MemoryTypesForNode(
1207 g.op_registry(), DeviceType(parsed.type), node->def(),
1208 &input_memory_types, &output_memory_types));
1209
1210 int node_id = node->id();
1211 info->device_types[node_id] = DeviceType(parsed.type);
1212 for (int i = 0; i < input_memory_types.size(); ++i) {
1213 info->input_types[{node_id, i}] = input_memory_types[i];
1214 }
1215 for (int i = 0; i < output_memory_types.size(); ++i) {
1216 info->output_types[{node_id, i}] = output_memory_types[i];
1217 }
1218 }
1219 return Status::OK();
1220}
1221
1222// Returns in <nodes> the nodes that should participate in epoch-based recv
1223// scheduling, along with their times; <nodes> is ordered by increasing

Callers 4

PartitionFunction · 0.85
PartitionWithTensorFuseFunction · 0.85
SplitGraphInternalV2Method · 0.85
SplitGraphInternalMethod · 0.85

Calls 9

InternalFunction · 0.85
MemoryTypesForNodeFunction · 0.85
DeviceTypeClass · 0.85
op_nodesMethod · 0.80
resizeMethod · 0.45
num_node_idsMethod · 0.45
op_registryMethod · 0.45
idMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected