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

Method CheckEntries

tensorflow/core/util/tensor_slice_writer_test.cc:143–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void TensorSliceWriteTestHelper::CheckEntries(const string& fname) {
144 TensorSliceReader::Table* tptr;
145 TF_CHECK_OK(OpenTableTensorSliceReader(fname, &tptr));
146 std::unique_ptr<TensorSliceReader::Table> table(tptr);
147 CHECK_NOTNULL(table.get());
148
149 // We expect a block of SavedTensorSlices
150 string value;
151 ASSERT_TRUE(table->Get(kSavedTensorSlicesKey, &value));
152 {
153 SavedTensorSlices sts;
154 EXPECT_TRUE(ParseProtoUnlimited(&sts, value));
155 // We also expect two entries for the tensors
156 EXPECT_TRUE(sts.has_meta());
157 EXPECT_EQ(4, sts.meta().tensor_size());
158 // We should have written nontrivial version information
159 EXPECT_LT(0, TF_CHECKPOINT_VERSION);
160 EXPECT_EQ(TF_CHECKPOINT_VERSION, sts.meta().versions().producer());
161 EXPECT_EQ(TF_CHECKPOINT_VERSION_MIN_CONSUMER,
162 sts.meta().versions().min_consumer());
163 // We don't expect any data in the first block.
164 EXPECT_FALSE(sts.has_data());
165 // The two tensors should be stored in the same order as they are first
166 // created.
167 {
168 // The two slices of the "test" tensor
169 const SavedSliceMeta& ssm = sts.meta().tensor(0);
170 EXPECT_EQ("test", ssm.name());
171 EXPECT_EQ(
172 "dim { size: 5 } "
173 "dim { size: 10 }",
174 ssm.shape().ShortDebugString());
175 EXPECT_EQ(DT_INT32, ssm.type());
176 EXPECT_EQ(2, ssm.slice_size());
177 TensorSlice s0(ssm.slice(0));
178 TensorSlice s1(ssm.slice(1));
179 EXPECT_EQ("-:0,1", s0.DebugString());
180 EXPECT_EQ("-:3,1", s1.DebugString());
181 }
182 {
183 // The "AA" tensor
184 const SavedSliceMeta& ssm = sts.meta().tensor(1);
185 EXPECT_EQ("AA", ssm.name());
186 EXPECT_EQ(
187 "dim { size: 3 } "
188 "dim { size: 2 }",
189 ssm.shape().ShortDebugString());
190 EXPECT_EQ(DT_FLOAT, ssm.type());
191 EXPECT_EQ(1, ssm.slice_size());
192 TensorSlice s0(ssm.slice(0));
193 EXPECT_EQ("-:-", s0.DebugString());
194 }
195 {
196 // The "int64" tensor
197 const SavedSliceMeta& ssm = sts.meta().tensor(2);
198 EXPECT_EQ("int64", ssm.name());
199 EXPECT_EQ(
200 "dim { size: 5 } "

Callers

nothing calls this directly

Calls 15

ParseProtoUnlimitedFunction · 0.85
TensorSliceClass · 0.85
ExpectIdenticalIntArraysFunction · 0.85
tensor_sizeMethod · 0.80
slice_sizeMethod · 0.80
sliceMethod · 0.80
ArraySizeFunction · 0.70
nameMethod · 0.65
typeMethod · 0.65
GetDataFunction · 0.50

Tested by

no test coverage detected