Repository: pytorch
Issue: linker error when trying to use Metal backend in PyTorch Mobile
Labels: module: build,triaged,module: arm

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

## To Reproduce

I'm following this [guide](https://github.com/pytorch/tutorials/blob/master/prototype_source/ios_gpu_workflow.rst). I was able to export the model with Metal backend. 

Then I removed build folder and re-compiled the library using 'IOS_ARCH=arm64 USE_PYTORCH_METAL=1 ./scripts/build_ios.sh'. Then I tried to use the ios benchmark app (after running 'ruby setup.rb'). Here are the linker errors in xcode:

```
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_MPSImageDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
  "_OBJC_CLASS_$_MPSCNNLogSoftMax", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSImageTranspose", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNPoolingAverage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNPoolingMax", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronTanH", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSImage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      __OBJC_$_CATEGORY_MPSImage_$_Tensor in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      __OBJC_$_CATEGORY_MPSImage_$_Shaders in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSImageWrapper.mm.o)
  "_OBJC_CLASS_$_MPSCNNFullyConnected", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronReLU", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNConvolution", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNUpsamplingNearest", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronSigmoid", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNConvolutionDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSTemporaryImage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
  "_MPSSupportsMTLDevice", referenced from:
      -[MPSCNNContext available] in libtorch_cpu.a(MPSCNNContext.mm.o)
  "_OBJC_CLASS_$_MPSCNNDepthWiseConvolutionDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
  "_vImageConvert_Planar16FtoPlanarF", referenced from:
      at::native::metal::fp16_to_fp32(std::__1::vector<unsigned short, std::__1::allocator<unsigned short> > const&) in libtorch_cpu.a(MetalUtils.mm.o)
  "_vImageConvert_PlanarFtoPlanar16F", referenced from:
      at::native::metal::fp32_to_fp16(std::__1::vector<float, std::__1::allocator<float> > const&) in libtorch_cpu.a(MetalUtils.mm.o)
ld: symbol(s) not found for architecture arm64
```

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

Should compile.

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0): 26391143b6578c24131b652753e12d617008d0f0
 - OS (e.g., Linux): Mac 10.15.7, Xcode 12.3
 - How you installed PyTorch (`conda`, `pip`, source):
 - Build command you used (if compiling from source):
 - Python version:
 - CUDA/cuDNN version:
 - GPU models and configuration:
 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->


cc @malfet @seemethere @walterddr