message: [TF] Clean up conv2d/conv3d input ndims check.
diff: @@ -2256,11 +2256,12 @@ def conv2d( # pylint: disable=redefined-builtin,dangerous-default-value
  strides = _get_sequence(strides, 2, channel_index, "strides")
  dilations = _get_sequence(dilations, 2, channel_index, "dilations")
  - # Try really hard to avoid modifying the legacy name scopes - return early.
  - shape = getattr(input, "shape", None)
  - if shape is not None:
  + shape = input.shape
  + # shape object may lack ndims, e.g., if input is an np.ndarray. In that case,
  + # we fall back to len(shape).
  ndims = getattr(shape, "ndims", -1)
  - if ndims == -1: ndims = len(shape)
  + if ndims == -1:
  + ndims = len(shape)
  if ndims in (4, 3, 2, 1, 0, None):
  # We avoid calling squeeze_batch_dims to reduce extra python function
  # call slowdown in eager mode. This branch doesn't require reshapes.
  @@ -2989,9 +2990,9 @@ def _conv3d_expanded_batch(
  dilations=None,
  name=None):
  """Helper function for `conv3d`; handles expanded batches."""
  - # Try really hard to avoid modifying the legacy name sceops - return early.
  - shape = getattr(input, "shape", None)
  - if shape is not None:
  + shape = input.shape
  + # shape object may lack ndims, e.g., if input is an np.ndarray. In that case,
  + # we fall back to len(shape).
  ndims = getattr(shape, "ndims", -1)
  if ndims == -1:
  ndims = len(shape)
  