You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #544 closed the ragged half with a typed RaggedDim sentinel, per-element null in TensorType.dims still encodes "dynamic/batch/placeholder" dimensions at the following sites. The Iterable<Dimension<?>> contract is still violated per-element.
Current State
Raw null is emitted into final shape lists at:
Input.java:137 (batchSizes.add(null) for unknown batch size)
Input.java:154 (newShape.add(null) for dynamic batch dim)
These dims are semantically distinct from ragged: uniform within a tensor instance but unknown statically (e.g., tf.keras.Input(shape=(None, 4))).
Test fixtures TENSOR_*_NONE_* (e.g., TENSOR_NONE_4_FLOAT32, TENSOR_2_NONE_INT32, TENSOR_NONE_NONE_STRING) encode this representation directly and will need migration alongside the source change.
TensorShapeUtil.areBroadcastable and TensorShapeUtil.getBroadcastedShapes already special-case null. Whichever encoding is chosen, broadcast must remain "compatible+propagate" for dynamic/batch dims.
Background
Spinoff from #544. The Iterable<Dimension<?>> non-null-element contract claim in that issue is only partially resolved by introducing RaggedDim; this issue tracks the remainder.
Summary
After #544 closed the ragged half with a typed
RaggedDimsentinel, per-elementnullinTensorType.dimsstill encodes "dynamic/batch/placeholder" dimensions at the following sites. TheIterable<Dimension<?>>contract is still violated per-element.Current State
Raw
nullis emitted into final shape lists at:Input.java:137(batchSizes.add(null)for unknown batch size)Input.java:154(newShape.add(null)for dynamic batch dim)FlowFromDirectoryGenerator.java:75(labelShape.add(null))TensorGenerator.java:2683(ret.add(null))These dims are semantically distinct from ragged: uniform within a tensor instance but unknown statically (e.g.,
tf.keras.Input(shape=(None, 4))).Test fixtures
TENSOR_*_NONE_*(e.g.,TENSOR_NONE_4_FLOAT32,TENSOR_2_NONE_INT32,TENSOR_NONE_NONE_STRING) encode this representation directly and will need migration alongside the source change.Proposed Fix
Two options:
RaggedDimsentinel for ragged dimensions instead of rawnullinTensorType.dims#544 with aDynamicDim extends Dimension<Void>(cheap, follows the just-landed precedent).RaggedDimunder a singleUnknownDim(kind)carrying a tag (RAGGED|DYNAMIC|PLACEHOLDER)—the latter fully discharges the per-element-non-null contract claim originally made in Use a typedRaggedDimsentinel for ragged dimensions instead of rawnullinTensorType.dims#544 in one move, at the cost of revisiting that fix.Hidden coupling to update
TensorShapeUtil.areBroadcastableandTensorShapeUtil.getBroadcastedShapesalready special-casenull. Whichever encoding is chosen, broadcast must remain "compatible+propagate" for dynamic/batch dims.Background
Spinoff from #544. The
Iterable<Dimension<?>>non-null-element contract claim in that issue is only partially resolved by introducingRaggedDim; this issue tracks the remainder.