|
30 | 30 | from tensorflow.python.framework import test_util
|
31 | 31 | from tensorflow.python.lib.io import file_io
|
32 | 32 | from tensorflow.python.module import module
|
33 |
| -from tensorflow.python.ops import gen_experimental_dataset_ops |
34 | 33 | from tensorflow.python.ops.ragged import ragged_factory_ops
|
35 | 34 | from tensorflow.python.ops.ragged import ragged_gather_ops
|
36 | 35 | from tensorflow.python.platform import gfile
|
@@ -500,40 +499,5 @@ def testInvalidModel(self):
|
500 | 499 | result.eval()
|
501 | 500 |
|
502 | 501 |
|
503 |
| -# Test that datasets depending on a sentencepiece tokenizer resources can be |
504 |
| -# serialized without external references. |
505 |
| -# This test is separate from `SentencepieceTokenizerOpTest` below because |
506 |
| -# context._reset_context() must be called from outside the context created by |
507 |
| -# `@test_util.run_all_in_graph_and_eager_modes`. |
508 |
| -class DatasetSerializationTest(test_util.TensorFlowTestCase): |
509 |
| - |
510 |
| - def testSerialization(self): |
511 |
| - with context.eager_mode(): |
512 |
| - sentencepiece_model_file = ( |
513 |
| - 'tensorflow_text/python/ops/test_data/' |
514 |
| - 'test_oss_model.model') |
515 |
| - model = gfile.GFile(sentencepiece_model_file, 'rb').read() |
516 |
| - sp = SentencepieceTokenizer(model) |
517 |
| - strings = ['hello', 'world'] |
518 |
| - dataset = dataset_ops.Dataset.from_tensor_slices(strings) |
519 |
| - # Ensure we can map the tokenizer across the dataset. |
520 |
| - dataset = dataset.map(sp.tokenize) |
521 |
| - graph = dataset._as_serialized_graph() |
522 |
| - element_spec = dataset.element_spec |
523 |
| - dataset_graph_string = graph.numpy() |
524 |
| - expected = sp.tokenize(strings) |
525 |
| - |
526 |
| - # Reset the eager context to make sure that the serialized dataset graph |
527 |
| - # is self-contained. |
528 |
| - context._reset_context() |
529 |
| - |
530 |
| - with context.eager_mode(): |
531 |
| - restored = dataset_ops.from_variant( |
532 |
| - gen_experimental_dataset_ops.dataset_from_graph(dataset_graph_string), |
533 |
| - element_spec) |
534 |
| - for i, result in enumerate(restored): |
535 |
| - self.assertAllEqual(result, expected[i]) |
536 |
| - |
537 |
| - |
538 | 502 | if __name__ == '__main__':
|
539 | 503 | test.main()
|
0 commit comments