Repository: pytorch
Issue: error when trying to call "torch::jit::load"method, use Metal backend in PyTorch Mobile
Labels: oncall: mobile,module: ios

I'm following this [guide](https://pytorch.org/tutorials/prototype/ios_gpu_workflow.html).
 - PyTorch Version (e.g., 1.0):1.8.1
 - OS (e.g., Linux):macOS11.2.1，Xcode 12.5
 - How you installed PyTorch (`conda`, `pip`, source):conda
 - Build command you used (if compiling from source):
 - Python version:3.8
 - CUDA/cuDNN version:
 - GPU models and configuration:
 - Any other relevant information:

Model Preparation:
    traced_script_module = torch.jit.trace(pmodel, example)
    traced_script_module_optimized = optimize_for_mobile(traced_script_module, backend="metal")
    traced_script_module_optimized.save("./model_metal.pt")

iOS:
    torch::jit::script::Module _impl;
    _impl = torch::jit::load(filePath.UTF8String);
    _impl.eval();

When load model, Here are the errors in xcode:
torch::jit::script::Module _impl = torch::jit::load(path.UTF8String);

errors:


Undefined symbols for architecture arm64:
  "torch::jit::Object::find_method(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      torch::jit::Object::get_method(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in TorchModule.o
  "torch::jit::Method::operator()(std::__1::vector<c10::IValue, std::__1::allocator<c10::IValue> >, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, c10::IValue, 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, c10::IValue> > > const&)", referenced from:
      torch::jit::Module::forward(std::__1::vector<c10::IValue, std::__1::allocator<c10::IValue> >) in TorchModule.o
  "torch::jit::Module::train(bool)", referenced from:
      torch::jit::Module::eval() in TorchModule.o
  "torch::jit::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, c10::optional<c10::Device>)", referenced from:
      -[TorchModule initWithFileAtPath:] in TorchModule.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)



Showing Recent Errors Only
Undefined symbol: torch::jit::Object::find_method(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const


Showing Recent Errors Only
Undefined symbol: torch::jit::Method::operator()(std::__1::vector<c10::IValue, std::__1::allocator<c10::IValue> >, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, c10::IValue, 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, c10::IValue> > > const&)


Showing Recent Errors Only
Undefined symbol: torch::jit::Module::train(bool)


Showing Recent Errors Only
Undefined symbol: torch::jit::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, c10::optional<c10::Device>)








cc @gmagogsfm