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

Function SetDevice

tensorflow/tools/graph_transforms/set_device.cc:23–42  ·  view source on GitHub ↗

Sets the device field of ops in the graph.

Source from the content-addressed store, hash-verified

21
22// Sets the device field of ops in the graph.
23Status SetDevice(const GraphDef& input_graph_def,
24 const TransformFuncContext& context,
25 GraphDef* output_graph_def) {
26 string new_device;
27 TF_RETURN_IF_ERROR(context.GetOneStringParameter("device", "", &new_device));
28 bool if_default;
29 TF_RETURN_IF_ERROR(
30 context.GetOneBoolParameter("if_default", false, &if_default));
31
32 output_graph_def->Clear();
33 for (const NodeDef& node : input_graph_def.node()) {
34 NodeDef* new_node = output_graph_def->mutable_node()->Add();
35 *new_node = node;
36 if (!if_default || (node.device().empty())) {
37 new_node->set_device(new_device);
38 }
39 }
40
41 return Status::OK();
42}
43
44REGISTER_GRAPH_TRANSFORM("set_device", SetDevice);
45

Callers 1

TESTFunction · 0.70

Calls 8

GetOneStringParameterMethod · 0.80
GetOneBoolParameterMethod · 0.80
ClearMethod · 0.45
nodeMethod · 0.45
AddMethod · 0.45
emptyMethod · 0.45
deviceMethod · 0.45
set_deviceMethod · 0.45

Tested by 1

TESTFunction · 0.56