| 183 | |
| 184 | template <typename T, typename U> |
| 185 | void SimpleIntXHelper( |
| 186 | const TensorSliceWriter::CreateBuilderFunction& create_function, |
| 187 | TensorSliceReader::OpenTableFunction open_function, |
| 188 | const string& checkpoint_file) { |
| 189 | const string fname_base = io::JoinPath(testing::TmpDir(), checkpoint_file); |
| 190 | |
| 191 | TensorShape shape({4, 5}); |
| 192 | |
| 193 | // File #0 contains a slice that is the top two rows: |
| 194 | // |
| 195 | // 0 1 2 3 4 |
| 196 | // 5 6 7 8 9 |
| 197 | // . . . . . |
| 198 | // . . . . . |
| 199 | { |
| 200 | const string fname = strings::StrCat(fname_base, "_0"); |
| 201 | TensorSliceWriter writer(fname, create_function); |
| 202 | const T data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 203 | TensorSlice slice = TensorSlice::ParseOrDie("0,2:-"); |
| 204 | TF_CHECK_OK(writer.Add("test", shape, slice, data)); |
| 205 | TF_CHECK_OK(writer.Finish()); |
| 206 | } |
| 207 | |
| 208 | // File #1 contains two slices: |
| 209 | // |
| 210 | // slice #0 is the bottom left corner |
| 211 | // . . . . . |
| 212 | // . . . . . |
| 213 | // 10 11 12 . . |
| 214 | // 15 16 17 . . |
| 215 | // |
| 216 | // slice #1 is the bottom right corner |
| 217 | // . . . . . |
| 218 | // . . . . . |
| 219 | // . . . . . |
| 220 | // . . . 18 19 |
| 221 | { |
| 222 | const string fname = strings::StrCat(fname_base, "_1"); |
| 223 | TensorSliceWriter writer(fname, create_function); |
| 224 | // slice #0 |
| 225 | { |
| 226 | const T data[] = {10, 11, 12, 15, 16, 17}; |
| 227 | TensorSlice slice = TensorSlice::ParseOrDie("2,2:0,3"); |
| 228 | TF_CHECK_OK(writer.Add("test", shape, slice, data)); |
| 229 | } |
| 230 | // slice #1 |
| 231 | { |
| 232 | const T data[] = {18, 19}; |
| 233 | TensorSlice slice = TensorSlice::ParseOrDie("3,1:3,2"); |
| 234 | TF_CHECK_OK(writer.Add("test", shape, slice, data)); |
| 235 | } |
| 236 | TF_CHECK_OK(writer.Finish()); |
| 237 | } |
| 238 | |
| 239 | // Notice that we leave a hole in the tensor |
| 240 | // . . . . . |
| 241 | // . . . . . |
| 242 | // . . . (13) (14) |
nothing calls this directly
no test coverage detected