[tf.data] Allow the DeserializeSparse op to accept inconsistent dense shapes.
This changes DeserializeSparse to match the behavior of DeserializeSparseMany and TakeManySparseFromTensorsMap, and thus makes `Dataset.batch()` on sparse tensors match the existing behavior of `tf.train.batch()` and family. The rationale for this change is that the source of many `tf.SparseTensor` objects is `tf.parse[_single]_example()`, and that operation does not try to ensure that consecutive `SparseTensor` objects parsed from the same feature specification have the same `dense_shape`. As a result, the behavior of existing ops that batch `SparseTensor` objects has been to silently pad those objects to the bounding dense_shape, by taking the maximum over each dimension size. While this does reduce our ability to make consistency checks in the `SparseTensor`-handling code, pragmatically we never get consistently shaped `SparseTensor`s in real programs, so this seems like a reasonable path for usability. PiperOrigin-RevId: 176697720
Loading
Please sign in to comment