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

Function TEST_F

tensorflow/core/util/example_proto_helper_test.cc:84–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82};
83
84TEST_F(SingleExampleProtoToTensorsTest, SparseOnlyTrivial) {
85 Example ex;
86 // Set up a feature for each of our supported types.
87 (*ex.mutable_features()->mutable_feature())[kSparseInt64Key]
88 .mutable_int64_list()
89 ->add_value(42);
90 (*ex.mutable_features()->mutable_feature())[kSparseFloatKey]
91 .mutable_float_list()
92 ->add_value(4.2);
93 (*ex.mutable_features()->mutable_feature())[kSparseStringKey]
94 .mutable_bytes_list()
95 ->add_value("forty-two");
96
97 std::vector<Tensor*> output_dense_values(0);
98 std::vector<std::vector<Tensor>> output_sparse_values_tmp(3);
99 for (int i = 0; i < 3; ++i) {
100 output_sparse_values_tmp[i] = std::vector<Tensor>(1);
101 }
102
103 std::vector<FixedLenFeature> empty_dense_vec;
104 TF_EXPECT_OK(SingleExampleProtoToTensors(ex, "", 0, empty_dense_vec,
105 sparse_vec_, &output_dense_values,
106 &output_sparse_values_tmp));
107
108 const std::vector<Tensor>& int64_tensor_vec = output_sparse_values_tmp[0];
109 EXPECT_EQ(1, int64_tensor_vec.size());
110 EXPECT_EQ(42, int64_tensor_vec[0].vec<int64>()(0));
111
112 const std::vector<Tensor>& float_tensor_vec = output_sparse_values_tmp[1];
113 EXPECT_EQ(1, float_tensor_vec.size());
114 EXPECT_NEAR(4.2, float_tensor_vec[0].vec<float>()(0), 0.001);
115
116 const std::vector<Tensor>& string_tensor_vec = output_sparse_values_tmp[2];
117 EXPECT_EQ(1, string_tensor_vec.size());
118 EXPECT_EQ("forty-two", string_tensor_vec[0].vec<tstring>()(0));
119}
120
121TEST_F(SingleExampleProtoToTensorsTest, SparseOnlyEmpty) {
122 Example empty;

Callers

nothing calls this directly

Calls 4

TensorShapeClass · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected