Failed to run on iOS - Couldn't find an operator for `aten::conv1d`
Labels: triaged, module: ios

### 🐛 Describe the bug

Hi, I'm testing one of my projects with `libtorch 1.11.0` for iOS simulator and I'm facing the following issue.

```python
Caused by:
    Internal torch error:
    Couldn't find an operator for aten::conv1d(Tensor input, Tensor weight, Tensor? bias, int[] stride, int[] padding, int[] dilation, int groups) -> Tensor. Do you have to update a set of hardcoded JIT ops?
    The above operation failed shape propagation in this context:
    /home/aalvarez/Projects/main/apps/lmrescore/trace-gpt2.py(32): forward
    /home/aalvarez/.virtualenvs/lmrescore-u7Iy2esc-py3.10/lib/python3.10/site-packages/torch/nn/modules/module.py(1092): _slow_forward
    /home/aalvarez/.virtualenvs/lmrescore-u7Iy2esc-py3.10/lib/python3.10/site-packages/torch/nn/modules/module.py(1108): _call_impl
    /home/aalvarez/.virtualenvs/lmrescore-u7Iy2esc-py3.10/lib/python3.10/site-packages/torch/jit/_trace.py(939): trace_module
    /home/aalvarez/.virtualenvs/lmrescore-u7Iy2esc-py3.10/lib/python3.10/site-packages/torch/jit/_trace.py(735): trace
    /home/aalvarez/Projects/main/apps/lmrescore/trace-gpt2.py(45): <module>
    Serialized   File "code/__torch__.py", line 17
        transformer = model0.transformer
        position_ids = self.position_ids
        _0 = ops.prim.NumToTensor(torch.size(input_ids, 1))
                                  ~~~~~~~~~~ <--- HERE
        _1 = int(_0)
        position_ids0 = torch.slice(torch.unsqueeze(position_ids, 0), 1, 0, _1)
 ```

The same works for `libtorch 1.10.2`.
I believe the compilation is OK because I see the same exported symbols for both version (1.10.2 and 1.11.0) regarding `conv1d`

Here is the output of `libtorch_cpu.a` for v1.11.0. 
```
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:autocast_mode.cpp.o:                  U at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:autocast_mode.cpp.o: 00000000000178d6 T at::autocast::WrapFunction_<(at::autocast::CastPolicy)0, (c10::DeviceType)0, at::Tensor (at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long), &(at::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)), at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long> >::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:autocast_mode.cpp.o: 0000000000002034 T at::autocast::WrapFunction_<(at::autocast::CastPolicy)0, (c10::DeviceType)1, at::Tensor (at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long), &(at::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)), at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long> >::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Convolution.cpp.o: 0000000000002556 T at::native::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Convolution.cpp.o: 0000000000001048 T at::native::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d110 b guard variable for at::_ops::conv1d_padding::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d0f8 b guard variable for at::_ops::conv1d_padding::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d0b0 b guard variable for at::_ops::conv1d::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d098 b guard variable for at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 0000000000007c9e T at::_ops::conv1d_padding::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 0000000000007b5a T at::_ops::conv1d_padding::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 00000000000076da T at::_ops::conv1d::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000000758c T at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000000767c t at::_ops::create_conv1d_typed_handle()
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 0000000000007c4a t at::_ops::create_conv1d_padding_typed_handle()
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d100 b at::_ops::conv1d_padding::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d0e8 b at::_ops::conv1d_padding::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d0a0 b at::_ops::conv1d::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000010d088 b at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)::op
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o: 0000000000001f07 t at::(anonymous namespace)::(anonymous namespace)::wrapper__conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o: 0000000000002045 t at::(anonymous namespace)::(anonymous namespace)::wrapper_padding_conv1d_padding(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o: 0000000000002010 T at::compositeimplicitautograd::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o: 0000000000001ed2 T at::compositeimplicitautograd::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o:                  U at::native::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::basic_string_view<char>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:RegisterCompositeImplicitAutograd.cpp.o:                  U at::native::conv1d(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:helper.cpp.o: 0000000000003424 T torch::jit::is_conv1d_module(torch::jit::Match const&, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, torch::jit::Value*, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, torch::jit::Value*> > > const&)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:insert_observers.cpp.o:                  U torch::jit::is_conv1d_module(torch::jit::Match const&, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, torch::jit::Value*, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, torch::jit::Value*> > > const&)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:external_functions.cpp.o:                  U at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:external_functions.cpp.o: 0000000000003f20 T _nnc_aten_conv1d
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:external_functions.cpp.o: 000000000000226b T _nnc_aten_quantized_conv1d
```

Essentially, `at::_ops::conv1d::call` is found
```
libtorch-1.11.0-ios-fat/lib/libtorch_cpu.a:Operators_3.cpp.o: 000000000000758c T at::_ops::conv1d::call(at::Tensor const&, at::Tensor const&, c10::optional<at::Tensor> const&, c10::ArrayRef<long long>, c10::ArrayRef<long long>, c10::ArrayRef<long long>, long long)
```
 Also in the linking I `force_load` libraries:
 ```bash
     external/libtorch_cpu_ios_fl/lib/libtorch.a \
    external/libtorch_cpu_ios_fl/lib/libtorch_cpu.a \
    external/libtorch_cpu_ios_fl/lib/libc10.a \
    external/libtorch_cpu_ios_fl/lib/libclog.a \
    external/libtorch_cpu_ios_fl/lib/libcpuinfo.a \
    external/libtorch_cpu_ios_fl/lib/libpthreadpool.a \
    external/libtorch_cpu_ios_fl/lib/libpytorch_qnnpack.a \
    external/libtorch_cpu_ios_fl/lib/libXNNPACK.a \
...
    -force_load \
    external/libtorch_cpu_ios_fl/lib/libtorch.a \
    -force_load \
    external/libtorch_cpu_ios_fl/lib/libtorch_cpu.a \
    -force_load \
    external/libtorch_cpu_ios_fl/lib/libc10.a \
    -force_load \
    external/libtorch_cpu_ios_fl/lib/libpytorch_qnnpack.a \
    -force_load \
    external/libtorch_cpu_ios_fl/lib/libXNNPACK.a \
```

The compilation was done with the following confguration:

```json
    "cacheVariables": {
        "CMAKE_BUILD_TYPE": "MinSizeRel",
        "CMAKE_CXX_COMPILER_LAUNCHER": {
          "type": "FILEPATH",
          "value": "/Users/xdev/.cargo/bin/sccache"
        },
        "CMAKE_C_COMPILER_LAUNCHER": {
          "type": "FILEPATH",
          "value": "/Users/xdev/.cargo/bin/sccache"
        },
        "CMAKE_TOOLCHAIN_FILE": {
          "type": "FILEPATH",
          "value": "${sourceDir}/cmake/iOS.cmake"
        },
        "CMAKE_THREAD_LIBS_INIT": "-lpthread",
        "CMAKE_HAVE_THREADS_LIBRARY": "1",
        "CMAKE_USE_PTHREADS_INIT": "1",
        "PYTHON_EXECUTABLE": {
          "type": "FILEPATH",
          "value": "python3"
        },
        "CMAKE_CXX_FLAGS": "-fobjc-arc",
        "TRACING_BASED": false,
        "BUILD_BINARY": false,
        "BUILD_CUSTOM_PROTOBUF": false,
        "BUILD_LITE_INTERPRETER": false,
        "BUILD_PYTHON": false,
        "BUILD_SHARED_LIBS": false,
        "BUILD_TEST": false,
        "USE_CUDA": false,
        "USE_GFLAGS": false,
        "USE_LEVELDB": false,
        "USE_LITE_INTERPRETER_PROFILER": false,
        "USE_LMDB": false,
        "USE_MKLDNN": false,
        "USE_MPI": false,
        "USE_NNPACK": false,
        "USE_NUMPY": false,
        "USE_OPENCV": false,
        "IOS_PLATFORM": "SIMULATOR",
        "IOS_ARCH": "x86_64",
        "CMAKE_CXX_FLAGS": "-fobjc-arc -mios-simulator-version-min=15.0",
        "CMAKE_C_FLAGS": "-fobjc-arc -mios-simulator-version-min=15.0"
   }
```

### Versions

```zsh
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: macOS 12.3 (x86_64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2)
CMake version: version 3.23.1
Libc version: N/A

Python version: 3.9.12 (main, May  8 2022, 18:05:47)  [Clang 13.1.6 (clang-1316.0.21.2)] (64-bit runtime)
Python platform: macOS-12.3-x86_64-i386-64bit
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

Versions of relevant libraries:
[pip3] numpy==1.22.3
[conda] Could not collect
```