Process aborted when running `tf.keras.layers.MaxPooling1D` on GPU with large `pool_size`
Hi @oawxkw,

I have replicated the reported behaviour.With CPU runtime the code is raising the intended exception as per attached 
[cpu-gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/a355128c42aed48a5f91d7e20bf62110/61778_cpu.ipynb).


But with GPU runtime session getting crashed.

<img width="1508" alt="Screenshot 2023-09-04 at 12 07 01 PM" src="https://github.com/tensorflow/tensorflow/assets/116063290/1153bc27-45ef-4021-a8cf-c83c6b688d16">

 @oawxkw ,

This can be duplicate of #61642 as tf.compat.v1.layers.MaxPooling1D is inheriting from keras.layers.MaxPooling1D only. The other issue already under Dev team review.

Thanks! I also observed some similar "Check failed" errors when using the following APIs on GPU.

- `tf.keras.layers.MaxPooling1D`, `tf.keras.layers.MaxPool1D`, `tf.compat.v1.keras.layers.MaxPooling1D`, `tf.compat.v1.keras.layers.MaxPool1D`
- `tf.keras.layers.MaxPooling2D`, `tf.keras.layers.MaxPool2D`, `tf.compat.v1.keras.layers.MaxPooling2D`, `tf.compat.v1.keras.layers.MaxPool2D`

I confirmed that these behaviors still exist in tensorflow nightly (2.15.0-dev20230906), and probably share the same root cause.
I think these are unexpected behaviors since they are supposed to throw Exceptions like the CPU does, rather than "Check failed" errors.

<details>
  <summary>Code to reproduce the issue in <code>tf.keras.layers.MaxPooling2D</code> APIs</summary>

```python
import tensorflow as tf
print(tf.version.GIT_VERSION, tf.version.VERSION, flush=True)
print(tf.config.list_physical_devices(), flush=True)


try:
    pool_size_0 = 1e+38
    pool_size = [pool_size_0, pool_size_0]
    strides_0 = 2
    strides = [strides_0, strides_0]
    padding = "same"
    data_format = "channels_last"
    arg_class = tf.keras.layers.MaxPooling2D(pool_size, strides, padding=padding, data_format=data_format)
    # arg_class = tf.keras.layers.MaxPool2D(pool_size, strides, padding=padding, data_format=data_format)
    # arg_class = tf.compat.v1.keras.layers.MaxPooling2D(pool_size, strides, padding=padding, data_format=data_format)
    # arg_class = tf.compat.v1.keras.layers.MaxPool2D(pool_size, strides, padding=padding, data_format=data_format)
    arg_input_0_tensor = tf.random.uniform([1, 5, 5, 4], dtype=tf.float32)
    arg_input_0 = tf.identity(arg_input_0_tensor)
    arg_input = [arg_input_0,]
    out = arg_class(*arg_input)
except Exception as e:
    print("Error:", str(e), flush=True)
print("Success!", flush=True)
```

On GPU, the Check failed error occurs:

```text
v2.14.0-rc0-34-gdd01672d9a9 2.14.0-rc1
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
2023-09-07 10:51:52.089257: F tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:1019] Check failed: cudnnSetPoolingNdDescriptor( handle_.get(), (pooling_descriptor.mode() == dnn::PoolingMode::kMaximum ? cudnn_max_pooling_mode : CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING), propagate_nans ? CUDNN_PROPAGATE_NAN : CUDNN_NOT_PROPAGATE_NAN, nd, shape.data(), padding.data(), strides.data()) == CUDNN_STATUS_SUCCESS (3 vs. 0)
Aborted (core dumped)
```

On CPU, it throws an Exception:

```text
v2.14.0-rc0-34-gdd01672d9a9 2.14.0-rc1
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
Error: Exception encountered when calling layer 'max_pooling2d_1' (type MaxPooling2D).

{{function_node __wrapped__MaxPool_device_/job:localhost/replica:0/task:0/device:CPU:0}} Sliding window ksize for dimension 1 was zero. [Op:MaxPool]

Call arguments received by layer 'max_pooling2d_1' (type MaxPooling2D):
  • inputs=tf.Tensor(shape=(3, 74, 74, 256), dtype=float32)
Success!
```
</details>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

binary

### TensorFlow version

2.14.0-rc1

### Custom code

No

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Process aborted with Check failed error when running `tf.keras.layers.MaxPooling1D` on GPU with large `pool_size`, while it throws an Exception on CPU.
When I reduce the `pool_size_0` to `1e+18`, it throws an Exception on GPU, which is a more reasonable behavior I think.
This behavior is similar to what described in #61642, which also throws a Check failed error by using a large `pool_size` for `tf.compat.v1.layers.MaxPooling1D` on GPU.


### Standalone code to reproduce the issue

```python
import tensorflow as tf
print(tf.version.GIT_VERSION, tf.version.VERSION, flush=True)

try:
    pool_size_0 = 1e+19
    pool_size = [pool_size_0,]
    strides_0 = 2
    strides = [strides_0,]
    padding = "same"
    data_format = "channels_last"
    arg_class = tf.keras.layers.MaxPooling1D(pool_size=pool_size,strides=strides,padding=padding,data_format=data_format,)
    # arg_class = tf.keras.layers.MaxPool1D(pool_size=pool_size,strides=strides,padding=padding,data_format=data_format,)
    # arg_class = tf.compat.v1.keras.layers.MaxPooling1D(pool_size=pool_size,strides=strides,padding=padding,data_format=data_format,)
    # arg_class = tf.compat.v1.keras.layers.MaxPool1D(pool_size=pool_size,strides=strides,padding=padding,data_format=data_format,)
    arg_input_0_tensor = tf.random.uniform([1, 5, 4], dtype=tf.float32)
    arg_input_0 = tf.identity(arg_input_0_tensor)
    arg_input = [arg_input_0,]
    out = arg_class(*arg_input)
except Exception as e:
    print("Error:", str(e), flush=True)
print("Success!", flush=True)
```


### Relevant log output

On GPU, it throws a Check failed and core dumped.

```text
v2.14.0-rc0-34-gdd01672d9a9 2.14.0-rc1
2023-09-03 11:34:09.267078: I tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:442] Loaded cuDNN version 8600
2023-09-03 11:34:09.267132: F tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:1019] Check failed: cudnnSetPoolingNdDescriptor( handle_.get(), (pooling_descriptor.mode() == dnn::PoolingMode::kMaximum ? cudnn_max_pooling_mode : CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING), propagate_nans ? CUDNN_PROPAGATE_NAN : CUDNN_NOT_PROPAGATE_NAN, nd, shape.data(), padding.data(), strides.data()) == CUDNN_STATUS_SUCCESS (3 vs. 0)
Aborted (core dumped)
```

On CPU, it throws a Exception.

```text
v2.14.0-rc0-34-gdd01672d9a9 2.14.0-rc1
Error: Exception encountered when calling layer 'max_pooling1d' (type MaxPooling1D).

{{function_node __wrapped__MaxPool_device_/job:localhost/replica:0/task:0/device:CPU:0}} Sliding window ksize for dimension 1 was zero. [Op:MaxPool]

Call arguments received by layer 'max_pooling1d' (type MaxPooling1D):
  • inputs=tf.Tensor(shape=(1, 5, 4), dtype=float32)
Success!
```

When I change the `pool_size_0` to `1e+18`, it throws a Exception on GPU.

```text
v2.14.0-rc0-34-gdd01672d9a9 2.14.0-rc1
2023-09-03 11:51:28.441325: W tensorflow/core/framework/op_kernel.cc:1816] OP_REQUIRES failed at maxpooling_op.cc:1260 : INVALID_ARGUMENT: Attr ksize has value 1000000000000000000 out of range for an int32
Error: Exception encountered when calling layer 'max_pooling1d' (type MaxPooling1D).

{{function_node __wrapped__MaxPool_device_/job:localhost/replica:0/task:0/device:GPU:0}} Attr ksize has value 1000000000000000000 out of range for an int32 [Op:MaxPool]

Call arguments received by layer 'max_pooling1d' (type MaxPooling1D):
  • inputs=tf.Tensor(shape=(1, 5, 4), dtype=float32)
Success!
```
