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

Function TEST

tensorflow/tools/graph_transforms/backports_test.cc:108–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106TEST_F(BackportConcatV2Test, TestBackportConcatV2) { TestBackportConcatV2(); }
107
108TEST(BackportTensorArrayV3Test, TestBackportTensorArrayV3) {
109 GraphDef graph_def;
110
111 NodeDef* size_node = graph_def.add_node();
112 size_node->set_name("size_node");
113 size_node->set_op("Const");
114 Tensor size_tensor(DT_INT32, {});
115 size_tensor.flat<int32>()(0) = 1;
116 SetNodeTensorAttr<float>("value", size_tensor, size_node);
117
118 NodeDef* tensor_array_node = graph_def.add_node();
119 tensor_array_node->set_name("tensor_array_node");
120 tensor_array_node->set_op("TensorArrayV3");
121 tensor_array_node->add_input("size_node");
122 SetNodeAttr("dtype", DT_FLOAT, tensor_array_node);
123 SetNodeAttr("element_shape", TensorShape({1, 2}), tensor_array_node);
124 SetNodeAttr("dynamic_size", false, tensor_array_node);
125 SetNodeAttr("clear_after_read", true, tensor_array_node);
126 SetNodeAttr("tensor_array_name", "some_name", tensor_array_node);
127
128 NodeDef* handle_output_node = graph_def.add_node();
129 handle_output_node->set_name("handle_output_node");
130 handle_output_node->set_op("Identity");
131 handle_output_node->add_input("tensor_array_node:0");
132
133 NodeDef* flow_output_node = graph_def.add_node();
134 flow_output_node->set_name("flow_output_node");
135 flow_output_node->set_op("Identity");
136 flow_output_node->add_input("tensor_array_node:1");
137
138 NodeDef* tensor_array_grad_node = graph_def.add_node();
139 tensor_array_grad_node->set_name("tensor_array_grad_node");
140 tensor_array_grad_node->set_op("TensorArrayGradV3");
141 tensor_array_grad_node->add_input("tensor_array_node:0");
142 tensor_array_grad_node->add_input("tensor_array_node:1");
143 SetNodeAttr("source", "foo", tensor_array_grad_node);
144
145 NodeDef* grad_handle_output_node = graph_def.add_node();
146 grad_handle_output_node->set_name("grad_handle_output_node");
147 grad_handle_output_node->set_op("Identity");
148 grad_handle_output_node->add_input("tensor_array_grad_node:0");
149
150 NodeDef* grad_flow_output_node = graph_def.add_node();
151 grad_flow_output_node->set_name("grad_flow_output_node");
152 grad_flow_output_node->set_op("Identity");
153 grad_flow_output_node->add_input("tensor_array_grad_node:1");
154
155 GraphDef result;
156 TransformFuncContext context;
157 context.input_names = {};
158 context.output_names = {"handle_output_node", "grad_handle_output_node"};
159 TF_ASSERT_OK(BackportTensorArrayV3Transform(graph_def, context, &result));
160
161 std::map<string, const NodeDef*> node_lookup;
162 MapNamesToNodes(result, &node_lookup);
163 ASSERT_EQ(1, node_lookup.count("tensor_array_node"));
164 EXPECT_EQ("TensorArrayV2", node_lookup.at("tensor_array_node")->op());
165 EXPECT_EQ("TensorArrayGradV2",

Callers

nothing calls this directly

Calls 13

MapNamesToNodesFunction · 0.85
EndsWithFunction · 0.85
set_opMethod · 0.80
SetNodeAttrFunction · 0.70
TensorShapeClass · 0.50
set_nameMethod · 0.45
add_inputMethod · 0.45
countMethod · 0.45
opMethod · 0.45
atMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected