Repository: pytorch/TensorRT

Issue:
🐛 [Bug] Encountered bug when using `torch.ops.aten.cat` converter
##  Bug Description

When compiling the [T5-Base Model](https://huggingface.co/t5-base) model via the `aten` path, the following error is encountered:

```
IndexError: tuple index out of range
While executing %cat_default : [#users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%arg0, %arg1, %arg2],), kwargs = {_itensor_to_tensor_meta: {<tensorrt.tensorrt.ITensor object at 0x7ff49c2fae30>: None, <tensorrt.tensorrt.ITensor object at 0x7ff49c2e6e30>: None, <tensorrt.tensorrt.ITensor object at 0x7ff49c2e1f30>: None}})
```

## To Reproduce

Steps to reproduce the behavior:

1. Initialize model: `T5Model.from_pretrained("t5-base").eval().cuda()`
2. Initialize three input tensors, for example: `torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda")` ("input_ids", "attention_mask", "decoder_input_ids")
3. (Optional) Use the `transformers` tools to trace the model via: `transformers.utils.fx.symbolic_trace(model, input_names=["input_ids", "attention_mask", "decoder_input_ids"])`
4. Compile the model using FX

## Expected behavior

Model should compile via the `aten` path

## Environment

- Transformers: 4.26.1
 - Torch-TensorRT Version (e.g. 1.0.0): b3f433a
 - PyTorch Version (e.g. 1.0): 2.1.0.dev20230419+cu117
- CPU Architecture: Intel Xeon CPU
- OS: Ubuntu 20.04
- How you installed PyTorch: pip
- Build command you used: `python setup.py develop`
- Are you using local sources or building from archives: local
- Python version: 3.8.13
- CUDA version: 11.7


Discussion:

Resolving patch:
diff --git a/py/torch_tensorrt/fx/converters/aten_ops_converters.py b/py/torch_tensorrt/fx/converters/aten_ops_converters.py
--- a/py/torch_tensorrt/fx/converters/aten_ops_converters.py
+++ b/py/torch_tensorrt/fx/converters/aten_ops_converters.py
@@ -358,7 +358,7 @@ def aten_ops_cat(
 ) -> Union[TRTTensor, Sequence[TRTTensor]]:
     kwargs_new = {
         "tensors": args[0],
-        "dim": args[1],
+        "dim": args[1] if len(args) >= 2 else 0,
     }
     return acc_ops_converters.acc_ops_cat(network, target, None, kwargs_new, name)
 


Test patch:
diff --git a/py/torch_tensorrt/fx/test/converters/aten_op/test_cat_aten.py b/py/torch_tensorrt/fx/test/converters/aten_op/test_cat_aten.py
--- a/py/torch_tensorrt/fx/test/converters/aten_op/test_cat_aten.py
+++ b/py/torch_tensorrt/fx/test/converters/aten_op/test_cat_aten.py
@@ -9,7 +9,7 @@ class TestCatConverter(DispatchTestCase):
     @parameterized.expand(
         [
             ("pos", 1),
-            # ("neg", -2), #dim can not have dynamic input
+            ("neg", -2),
         ]
     )
     def test_cat(self, _, dim):
@@ -27,7 +27,7 @@ def forward(self, x, y, z):
     @parameterized.expand(
         [
             ("pos", 1),
-            # ("neg", -2), #dim can not have dynamic input
+            ("neg", -2),
         ]
     )
     def test_cat_dynamic_shape(self, _, dim):
@@ -53,6 +53,41 @@ def forward(self, x, y):
             expected_ops={torch.ops.aten.cat.default},
         )
 
+    def test_cat_no_dim(self):
+        class Cat(nn.Module):
+            def forward(self, x, y, z):
+                return torch.cat((x, y, z))
+
+        inputs = [torch.randn(2, 1, 3), torch.randn(1, 1, 3), torch.randn(3, 1, 3)]
+        self.run_test(
+            Cat(),
+            inputs,
+            expected_ops={torch.ops.aten.cat.default},
+        )
+
+    def test_cat_dynamic_shape_no_dim(self):
+        class Cat(nn.Module):
+            def forward(self, x, y):
+                return torch.cat((x, y))
+
+        input_specs = [
+            InputTensorSpec(
+                shape=(-1, 16, 3),
+                dtype=torch.float32,
+                shape_ranges=[((2, 16, 3), (3, 16, 3), (32, 16, 3))],
+            ),
+            InputTensorSpec(
+                shape=(-1, 16, 3),
+                dtype=torch.float32,
+                shape_ranges=[((2, 16, 3), (3, 16, 3), (32, 16, 3))],
+            ),
+        ]
+        self.run_test_with_dynamic_shape(
+            Cat(),
+            input_specs,
+            expected_ops={torch.ops.aten.cat.default},
+        )
+
 
 if __name__ == "__main__":
     run_tests()