Repository: pytorch
Issue: Error: no matching constructor for initialization of 'at::OptionalIntArrayRef'
Labels: module: build,triaged,module: macos

### 🐛 Describe the bug

I am using the PyTorch C++.  My code includes the line

```c++
Tensor realGrid = torch::fft::irfftn(recipGrid, {gridSize[0], gridSize[1], gridSize[2]}, c10::nullopt, "forward");
```

where `recipGrid` is a 3D tensor and `gridSize` is an array of ints.  Using gcc on Linux this compiles and works as expected.  But compiling with clang on Mac, it fails with a compilation error:

```
/Users/peastman/workspace/NNPOps/src/pytorch/pme/pmeCPU.cpp:302:57: error: no matching constructor for initialization of 'at::OptionalIntArrayRef' (aka 'OptionalArrayRef<long long>')
        Tensor realGrid = torch::fft::irfftn(recipGrid, {gridSize[0], gridSize[1], gridSize[2]}, c10::nullopt, "forward");
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:71:22: note: candidate template ignored: could not match 'initializer_list<type-parameter-0-0>' against 'int'
  constexpr explicit OptionalArrayRef(
                     ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:67:22: note: candidate constructor template not viable: no known conversion from 'int' to 'c10::in_place_t' for 1st argument
  constexpr explicit OptionalArrayRef(in_place_t ip, Args&&... args) noexcept
                     ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:26:13: note: candidate constructor not viable: requires 1 argument, but 3 were provided
  constexpr OptionalArrayRef(nullopt_t) noexcept {}
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:28:3: note: candidate constructor not viable: requires single argument 'other', but 3 arguments were provided
  OptionalArrayRef(const OptionalArrayRef& other) = default;
  ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:30:3: note: candidate constructor not viable: requires single argument 'other', but 3 arguments were provided
  OptionalArrayRef(OptionalArrayRef&& other) = default;
  ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:32:13: note: candidate constructor not viable: requires single argument 'other', but 3 arguments were provided
  constexpr OptionalArrayRef(const optional<ArrayRef<T>>& other) noexcept
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:35:13: note: candidate constructor not viable: requires single argument 'other', but 3 arguments were provided
  constexpr OptionalArrayRef(optional<ArrayRef<T>>&& other) noexcept
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:38:13: note: candidate constructor not viable: requires single argument 'value', but 3 arguments were provided
  constexpr OptionalArrayRef(const T& value) noexcept
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:50:13: note: candidate constructor template not viable: requires single argument 'value', but 3 arguments were provided
  constexpr OptionalArrayRef(U&& value) noexcept(
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:62:22: note: candidate constructor template not viable: requires single argument 'value', but 3 arguments were provided
  constexpr explicit OptionalArrayRef(U&& value) noexcept(
                     ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/c10/util/OptionalArrayRef.h:24:13: note: candidate constructor not viable: requires 0 arguments, but 3 were provided
  constexpr OptionalArrayRef() noexcept {}
            ^
/Users/peastman/miniconda3/envs/openmm/lib/python3.9/site-packages/torch/include/torch/csrc/api/include/torch/fft.h:186:44: note: passing argument to parameter 's' here
                   at::OptionalIntArrayRef s=c10::nullopt,
                                           ^
1 error generated.
```

### Versions

PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.3.1 (arm64)
GCC version: Could not collect
Clang version: 14.0.3 (clang-1403.0.22.14.1)
CMake version: version 3.22.2
Libc version: N/A

Python version: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:06)  [Clang 11.1.0 ] (64-bit runtime)
Python platform: macOS-13.3.1-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

CPU:
Apple M1 Pro

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.6
[pip3] openmmtorch==1.0
[pip3] torch==1.12.1
[pip3] torchani==2.2.3.dev2+g3dfbaf4
[conda] numpy                     1.21.6           py39h690d673_0    conda-forge
[conda] openmmtorch               1.0                      pypi_0    pypi
[conda] pytorch                   1.12.1          cpu_py39hf1faf6a_1    conda-forge
[conda] torchani                  2.2.3.dev2+g3dfbaf4           dev_0    <develop>


cc @malfet @seemethere @albanD