Conv2D backprop APIs can lead to assertion failure at graph optimization step
Hi @Sehun0819 ,

I can see missing validation check for strides in the API Conv2DBackpropFilter.

For other APIs DepthwiseConv2DNativeBackpropFilter & DepthwiseConv2DNativeBackpropInput there is check for `strides.size() `and it should raise error if `strides.size() !=4` .
https://github.com/tensorflow/tensorflow/blob/6fd130f8ad839257a274212fbd935b35f2625584/tensorflow/core/kernels/depthwise_conv_grad_op.cc#L559

https://github.com/tensorflow/tensorflow/blob/6fd130f8ad839257a274212fbd935b35f2625584/tensorflow/core/kernels/depthwise_conv_grad_op.cc#L1070

Could you please confirm whether the behaviour happens with same code above where `strides.size!=4` For Conv2DBackpropInput it should check strides.size here.

https://github.com/tensorflow/tensorflow/blob/6fd130f8ad839257a274212fbd935b35f2625584/tensorflow/core/kernels/conv_grad_input_ops.h#L294 Hi @Sehun0819 , The proposed PR got merged.You can you test with nightly and confirm if this is still an issue? This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63076">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63076">No</a>

### Issue type

Bug

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

Yes

### Source

source

### TensorFlow version

tf 2.17

### Custom code

Yes

### OS platform and distribution

Linux Ubuntu 22.04 LTS

### Mobile device

_No response_

### Python version

3.11.7

### Bazel version

6.5.0

### GCC/compiler version

clang 16

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Conv2D backprop APIs can lead to assertion failure at graph optimization step.
[Error location](https://github.com/tensorflow/tensorflow/blob/955c46c2d5e5af67ccd9e692c518fed559c1d326/tensorflow/core/grappler/costs/op_level_cost_estimator.cc#L982C34-L982C44):
```C++
  std::vector<int64_t> strides = GetStrides(op_info);
```
Here It tries to get strides from input. But because there is no guard that checks size of `strides`, it ends up with assertion failure at [`GetStrides`](https://github.com/tensorflow/tensorflow/blob/955c46c2d5e5af67ccd9e692c518fed559c1d326/tensorflow/core/grappler/costs/op_level_cost_estimator.cc#L192-L193):
```C++
    DCHECK(strides.size() == 4)
        << "Attr strides is not a length-4 vector: " << op_info.DebugString();
```
APIs which have same problem:
`tf.raw_ops.Conv2DBackpropFilter`
`tf.raw_ops.Conv2DBackpropInput`
`tf.raw_ops.DepthwiseConv2DNativeBackpropFilter`
`tf.raw_ops.DepthwiseConv2DNativeBackpropInput`

### Standalone code to reproduce the issue

```Python
import tensorflow as tf

tf.compat.v1.disable_eager_execution()

x = tf.raw_ops.Conv2DBackpropFilter(
    input=tf.random.normal([1,1,1,1]),
    filter_sizes=[1,1,1,1],
    out_backprop=tf.random.normal([1,1,1,1]),
    strides=[1,1,1,1,1],
    padding="VALID",
    use_cudnn_on_gpu=True,
    explicit_paddings=[],
    data_format='NHWC',
    dilations=[1, 1, 1, 1],
    name=None
)

sess = tf.compat.v1.Session()
sess.run(x)
```


### Relevant log output
Note that assertion failure is observable in debug build only.

Release build:
```shell
2024-02-28 14:02:25.871735: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
Traceback (most recent call last):
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1402, in _do_call
    return fn(*args)
           ^^^^^^^^^
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1385, in _run_fn
    return self._call_tf_sessionrun(options, feed_dict, fetch_list,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1478, in _call_tf_sessionrun
    return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tensorflow.python.framework.errors_impl.InvalidArgumentError: Sliding window strides field must specify 4 dimensions
	 [[{{node Conv2DBackpropFilter}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/loft/Conv2DBackpropFilter.py", line 19, in <module>
    sess.run(x)
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 972, in run
    result = self._run(None, fetches, feed_dict, options_ptr,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1215, in _run
    results = self._do_run(handle, final_targets, final_fetches,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1395, in _do_run
    return self._do_call(_run_fn, feeds, fetches, targets, options,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/client/session.py", line 1421, in _do_call
    raise type(e)(node_def, op, message)  # pylint: disable=no-value-for-parameter
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tensorflow.python.framework.errors_impl.InvalidArgumentError: Graph execution error:

Detected at node 'Conv2DBackpropFilter' defined at (most recent call last):
    File "/home/loft/Conv2DBackpropFilter.py", line 5, in <module>
Node: 'Conv2DBackpropFilter'
Sliding window strides field must specify 4 dimensions
	 [[{{node Conv2DBackpropFilter}}]]

Original stack trace for 'Conv2DBackpropFilter':
  File "/home/loft/Conv2DBackpropFilter.py", line 5, in <module>
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/util/tf_export.py", line 377, in wrapper
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1536, in conv2d_backprop_filter
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/framework/op_def_library.py", line 796, in _apply_op_helper
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 2682, in _create_op_internal
  File "/home/loft/anaconda3/envs/tf-latest-release/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 1177, in from_node_def
```

Debug build:
```shell
2024-02-28 14:03:56.399860: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
F0000 00:00:1709096636.447526 4015264 op_level_cost_estimator.cc:192] Check failed: strides.size() == 4 Attr strides is not a length-4 vector: op: "Conv2DBackpropFilter"
attr {
  key: "T"
  value {
    type: DT_FLOAT
  }
}
attr {
  key: "data_format"
  value {
    s: "NHWC"
  }
}
attr {
  key: "dilations"
  value {
    list {
      i: 1
      i: 1
      i: 1
      i: 1
    }
  }
}
attr {
  key: "explicit_paddings"
  value {
    list {
    }
  }
}
attr {
  key: "padding"
  value {
    s: "VALID"
  }
}
attr {
  key: "strides"
  value {
    list {
      i: 1
      i: 1
      i: 1
      i: 1
      i: 1
    }
  }
}
attr {
  key: "use_cudnn_on_gpu"
  value {
    b: true
  }
}
inputs {
  dtype: DT_FLOAT
  shape {
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
  }
}
inputs {
  dtype: DT_INT32
  shape {
    dim {
      size: 4
    }
  }
  value {
    dtype: DT_INT32
    tensor_shape {
      dim {
        size: 4
      }
    }
    int_val: 1
  }
}
inputs {
  dtype: DT_FLOAT
  shape {
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
  }
}
device {
  type: "CPU"
  vendor: "AuthenticAMD"
  model: "241"
  frequency: 2250
  num_cores: 256
  environment {
    key: "cpu_instruction_set"
    value: "SSE, SSE2, SSE3"
  }
  environment {
    key: "eigen"
    value: "3.4.90"
  }
  l1_cache_size: 32768
  l2_cache_size: 524288
  l3_cache_size: 268435456
  memory_size: 268435456
}
outputs {
  dtype: DT_FLOAT
  shape {
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
    dim {
      size: 1
    }
  }
}

*** Check failure stack trace: ***
    @     0x7fefbb0d5467  absl::lts_20230802::log_internal::LogMessage::PrepareToDie()
    @     0x7fefbb0d4ecf  absl::lts_20230802::log_internal::LogMessage::SendToLog()
    @     0x7fefbb0d442d  absl::lts_20230802::log_internal::LogMessage::Flush()
    @     0x7fefbb0d5605  absl::lts_20230802::log_internal::LogMessageFatal::~LogMessageFatal()
    @     0x7fefbad34a2e  tensorflow::grappler::(anonymous namespace)::GetStrides()
    @     0x7fefbad33112  tensorflow::grappler::OpLevelCostEstimator::ConvolutionDimensionsFromInputs()
    @     0x7fefbad3a99d  tensorflow::grappler::OpLevelCostEstimator::CountConv2DBackpropFilterOperations()
    @     0x7fefbad28588  tensorflow::grappler::OpLevelCostEstimator::PredictConv2DBackpropFilter()
    @     0x7fefbad3e095  tensorflow::grappler::OpLevelCostEstimator::OpLevelCostEstimator()::$_0::operator()()::{lambda()#1}::operator()()
    @     0x7fefbad3e003  std::__invoke_impl<>()
    @     0x7fefbad3dfa0  std::__invoke_r<>()
    @     0x7fefbad3de60  std::_Function_handler<>::_M_invoke()
    @     0x7fefbad40338  std::function<>::operator()()
    @     0x7fefbad2eae0  tensorflow::grappler::OpLevelCostEstimator::PredictNodeCosts()
    @     0x7fefbad2e37a  tensorflow::grappler::OpLevelCostEstimator::PredictCosts()
    @     0x7fefbad1b8a5  tensorflow::grappler::AnalyticalCostEstimator::PredictCosts()
    @     0x7fefbad17b3b  tensorflow::grappler::VirtualCluster::Run()
    @     0x7fefbac23b72  tensorflow::grappler::GraphMemory::InferStatically()
    @     0x7fefbac0604d  tensorflow::grappler::(anonymous namespace)::IdentifySwappingCandidates()
    @     0x7fefbabf9cc5  tensorflow::grappler::(anonymous namespace)::SwappingPass()
    @     0x7fefbabf5546  tensorflow::grappler::MemoryOptimizer::Optimize()
    @     0x7fefbaa4cf4f  tensorflow::grappler::MetaOptimizer::RunOptimizer()
    @     0x7fefbaa4bcc2  tensorflow::grappler::MetaOptimizer::OptimizeGraph()
    @     0x7fefbaa4db9c  tensorflow::grappler::MetaOptimizer::OptimizeGraph()
    @     0x7fefbaa4ea00  tensorflow::grappler::MetaOptimizer::OptimizeConsumeItem()
    @     0x7fefbaa50cef  tensorflow::grappler::RunMetaOptimizer()
    @     0x7fefba760621  tensorflow::GraphExecutionState::OptimizeGraph()
    @     0x7fefba75c50d  tensorflow::GraphExecutionState::BuildGraph()
    @     0x7fefb0c7c0dc  tensorflow::DirectSession::CreateGraphs()
    @     0x7fefb0c7ad04  tensorflow::DirectSession::CreateExecutors()
    @     0x7fefb0c78082  tensorflow::DirectSession::GetOrCreateExecutors()
    @     0x7fefb0c769ab  tensorflow::DirectSession::Run()
    @     0x7fefb0c7663e  tensorflow::DirectSession::Run()
    @     0x7fefb4f92467  tensorflow::SessionRef::Run()
    @     0x7fef94109085  TF_Run_Helper()
    @     0x7fef941129c9  TF_SessionRun
    @     0x7fefb4f830da  tensorflow::TF_SessionRun_wrapper_helper()
    @     0x7fefb4f8354b  tensorflow::TF_SessionRun_wrapper()
    @     0x7fef6965c9c3  pybind11_init__pywrap_tf_session()::$_46::operator()()
    @     0x7fef6965c726  pybind11::detail::argument_loader<>::call_impl<>()
    @     0x7fef6965c63c  pybind11::detail::argument_loader<>::call<>()
    @     0x7fef6965c53b  pybind11::cpp_function::initialize<>()::{lambda()#1}::operator()()
    @     0x7fef6965c439  pybind11::cpp_function::initialize<>()::{lambda()#1}::__invoke()
    @     0x7fef69685777  pybind11::cpp_function::dispatcher()
    @           0x528187  cfunction_call
Aborted (core dumped)
```
