Placeholder tensor is empty
Labels: triaged, module: mps

### 🐛 Describe the bug

I am running detectron2 on a MacBook 14" with and M1 Pro processor, using the MPS GPU support.

When running inference on an image using the detection2 predictor as follows

```python
im = cv2.imread(d["file_name"])
outputs = predictor(im) 
```
I get the following error, which suggests to report a bug to PyTorch, therefore this issue.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In [9], line 7
      5 print(im.shape)
      6 #im = np.array(Image.open(d["file_name"]))
----> 7 outputs = predictor(im)  # format is documented at https://detectron2.readthedocs.io/tutorials/models.html#model-output-format
      8 v = Visualizer(im[:, :, ::-1],
      9                metadata=balloon_metadata, 
     10                scale=0.5, 
     11                instance_mode=ColorMode.IMAGE_BW   # remove the colors of unsegmented pixels. This option is only available for segmentation models
     12 )
     13 out = v.draw_instance_predictions(outputs["instances"].to("cpu"))

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/engine/defaults.py:317, in DefaultPredictor.__call__(self, original_image)
    314 image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))
    316 inputs = {"image": image, "height": height, "width": width}
--> 317 predictions = self.model([inputs])[0]
    318 return predictions

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/module.py:1357, in Module._call_impl(self, *input, **kwargs)
   1352 # If we don't have any hooks, we want to skip the rest of the logic in
   1353 # this function, and just call forward.
   1354 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1355         or _global_backward_pre_hooks or _global_backward_hooks
   1356         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1357     return forward_call(*input, **kwargs)
   1358 # Do not call functions when jit is used
   1359 full_backward_hooks, non_full_backward_hooks = [], []

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/meta_arch/rcnn.py:150, in GeneralizedRCNN.forward(self, batched_inputs)
    127 """
    128 Args:
    129     batched_inputs: a list, batched outputs of :class:`DatasetMapper` .
   (...)
    147         "pred_boxes", "pred_classes", "scores", "pred_masks", "pred_keypoints"
    148 """
    149 if not self.training:
--> 150     return self.inference(batched_inputs)
    152 images = self.preprocess_image(batched_inputs)
    153 if "instances" in batched_inputs[0]:

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/meta_arch/rcnn.py:213, in GeneralizedRCNN.inference(self, batched_inputs, detected_instances, do_postprocess)
    210         assert "proposals" in batched_inputs[0]
    211         proposals = [x["proposals"].to(self.device) for x in batched_inputs]
--> 213     results, _ = self.roi_heads(images, features, proposals, None)
    214 else:
    215     detected_instances = [x.to(self.device) for x in detected_instances]

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/module.py:1357, in Module._call_impl(self, *input, **kwargs)
   1352 # If we don't have any hooks, we want to skip the rest of the logic in
   1353 # this function, and just call forward.
   1354 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1355         or _global_backward_pre_hooks or _global_backward_hooks
   1356         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1357     return forward_call(*input, **kwargs)
   1358 # Do not call functions when jit is used
   1359 full_backward_hooks, non_full_backward_hooks = [], []

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/roi_heads/roi_heads.py:750, in StandardROIHeads.forward(***failed resolving arguments***)
    747 pred_instances = self._forward_box(features, proposals)
    748 # During inference cascaded prediction is used: the mask and keypoints heads are only
    749 # applied to the top scoring box detections.
--> 750 pred_instances = self.forward_with_given_boxes(features, pred_instances)
    751 return pred_instances, {}

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/roi_heads/roi_heads.py:776, in StandardROIHeads.forward_with_given_boxes(self, features, instances)
    773 assert not self.training
    774 assert instances[0].has("pred_boxes") and instances[0].has("pred_classes")
--> 776 instances = self._forward_mask(features, instances)
    777 instances = self._forward_keypoint(features, instances)
    778 return instances

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/roi_heads/roi_heads.py:846, in StandardROIHeads._forward_mask(self, features, instances)
    844 else:
    845     features = {f: features[f] for f in self.mask_in_features}
--> 846 return self.mask_head(features, instances)

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/module.py:1357, in Module._call_impl(self, *input, **kwargs)
   1352 # If we don't have any hooks, we want to skip the rest of the logic in
   1353 # this function, and just call forward.
   1354 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1355         or _global_backward_pre_hooks or _global_backward_hooks
   1356         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1357     return forward_call(*input, **kwargs)
   1358 # Do not call functions when jit is used
   1359 full_backward_hooks, non_full_backward_hooks = [], []

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/roi_heads/mask_head.py:197, in BaseMaskRCNNHead.forward(self, x, instances)
    183 def forward(self, x, instances: List[Instances]):
    184     """
    185     Args:
    186         x: input region feature(s) provided by :class:`ROIHeads`.
   (...)
    195         A dict of losses in training. The predicted "instances" in inference.
    196     """
--> 197     x = self.layers(x)
    198     if self.training:
    199         return {"loss_mask": mask_rcnn_loss(x, instances, self.vis_period) * self.loss_weight}

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/modeling/roi_heads/mask_head.py:289, in MaskRCNNConvUpsampleHead.layers(self, x)
    287 def layers(self, x):
    288     for layer in self:
--> 289         x = layer(x)
    290     return x

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/module.py:1357, in Module._call_impl(self, *input, **kwargs)
   1352 # If we don't have any hooks, we want to skip the rest of the logic in
   1353 # this function, and just call forward.
   1354 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1355         or _global_backward_pre_hooks or _global_backward_hooks
   1356         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1357     return forward_call(*input, **kwargs)
   1358 # Do not call functions when jit is used
   1359 full_backward_hooks, non_full_backward_hooks = [], []

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/detectron2/layers/wrappers.py:119, in Conv2d.forward(self, x)
    117     x = self.norm(x)
    118 if self.activation is not None:
--> 119     x = self.activation(x)
    120 return x

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/module.py:1357, in Module._call_impl(self, *input, **kwargs)
   1352 # If we don't have any hooks, we want to skip the rest of the logic in
   1353 # this function, and just call forward.
   1354 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1355         or _global_backward_pre_hooks or _global_backward_hooks
   1356         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1357     return forward_call(*input, **kwargs)
   1358 # Do not call functions when jit is used
   1359 full_backward_hooks, non_full_backward_hooks = [], []

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/modules/activation.py:102, in ReLU.forward(self, input)
    101 def forward(self, input: Tensor) -> Tensor:
--> 102     return F.relu(input, inplace=self.inplace)

File ~/opt/anaconda3/envs/torch-gpu/lib/python3.8/site-packages/torch/nn/functional.py:1457, in relu(input, inplace)
   1455     result = torch.relu_(input)
   1456 else:
-> 1457     result = torch.relu(input)
   1458 return result

RuntimeError: [srcBuf length] > 0 INTERNAL ASSERT FAILED at "/Users/runner/work/_temp/anaconda/conda-bld/pytorch_1666163570052/work/aten/src/ATen/native/mps/OperationUtils.mm":242, please report a bug to PyTorch. Placeholder tensor is empty!
```

Thanks

### Versions

PyTorch version: 1.14.0.dev20221019
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.6 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.102)
CMake version: version 3.24.2
Libc version: N/A

Python version: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:14)  [Clang 12.0.1 ] (64-bit runtime)
Python platform: macOS-12.6-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.1
[pip3] pytorch-lightning==1.7.7
[pip3] torch==1.14.0.dev20221019
[pip3] torchaudio==0.13.0.dev20221019
[pip3] torchmetrics==0.10.0
[pip3] torchnet==0.0.4
[pip3] torchvision==0.15.0.dev20221019
[conda] numpy                     1.23.1           py38h42add53_0  
[conda] numpy-base                1.23.1           py38hadd41eb_0  
[conda] pytorch                   1.14.0.dev20221019         py3.8_0    pytorch-nightly
[conda] pytorch-lightning         1.7.7                    pypi_0    pypi
[conda] torchaudio                0.13.0.dev20221019        py38_cpu    pytorch-nightly
[conda] torchmetrics              0.10.0                   pypi_0    pypi
[conda] torchnet                  0.0.4                    pypi_0    pypi
[conda] torchvision               0.15.0.dev20221019        py38_cpu    pytorch-nightly

cc @kulinseth @albanD @malfet @DenisVieriu97 @razarmehr @abhudev