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

Function ParseExample

tensorflow/core/kernels/example_parsing_ops_test.cc:152–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150
151template <typename Options>
152static Graph* ParseExample(int batch_size, int num_keys, int feature_size) {
153 Graph* g = new Graph(OpRegistry::Global());
154 Tensor& serialized = Options::Store::GetSerializedExample()[std::make_tuple(
155 batch_size, num_keys, feature_size)];
156 Tensor names(DT_STRING, TensorShape({batch_size}));
157
158 std::vector<NodeBuilder::NodeOut> sparse_keys;
159 std::vector<NodeBuilder::NodeOut> dense_keys;
160 std::vector<NodeBuilder::NodeOut> dense_defaults;
161 std::vector<DataType> sparse_types;
162 std::vector<PartialTensorShape> dense_shapes;
163 Options opt;
164 for (int i = 0; i < num_keys; ++i) {
165 Tensor key(DT_STRING, TensorShape());
166 key.scalar<tstring>()() = strings::Printf("feature_%d", i);
167 switch (opt.benchmark_type) {
168 case kDense:
169 dense_keys.emplace_back(test::graph::Constant(g, key));
170 dense_defaults.emplace_back(test::graph::Constant(
171 g, opt.filler.make_dense_default(feature_size)));
172 dense_shapes.push_back(PartialTensorShape({feature_size}));
173 break;
174 case kVarLenDense:
175 dense_keys.emplace_back(test::graph::Constant(g, key));
176 dense_defaults.emplace_back(
177 test::graph::Constant(g, opt.filler.make_dense_default(1)));
178 dense_shapes.push_back(PartialTensorShape({-1}));
179 break;
180 case kSparse:
181 sparse_keys.emplace_back(test::graph::Constant(g, key));
182 sparse_types.push_back(opt.filler.dtype);
183 break;
184 }
185 }
186
187 Node* ret;
188 TF_EXPECT_OK(NodeBuilder(g->NewName("n"), "ParseExample")
189 .Input(test::graph::Constant(g, serialized))
190 .Input(test::graph::Constant(g, names))
191 .Input(sparse_keys)
192 .Input(dense_keys)
193 .Input(dense_defaults)
194 .Attr("sparse_types", sparse_types)
195 .Attr("dense_shapes", dense_shapes)
196 .Finalize(g, &ret));
197
198 return g;
199}
200
201template <typename Options>
202static Graph* ParseSingleExample(int num_keys, int feature_size) {

Callers 1

BuildGraphMethod · 0.50

Calls 12

PrintfFunction · 0.85
PartialTensorShapeClass · 0.85
ConstantFunction · 0.70
TensorShapeClass · 0.50
NodeBuilderClass · 0.50
emplace_backMethod · 0.45
make_dense_defaultMethod · 0.45
push_backMethod · 0.45
FinalizeMethod · 0.45
AttrMethod · 0.45
InputMethod · 0.45
NewNameMethod · 0.45

Tested by

no test coverage detected