LiteModuleLoader equivellent module in android native

Hi All,

In libtorch, we use the torch::jit::load to read a torchscript model saved by pytorch. I’d like to know what is the equivalent function in the pytorch_android_lite. In the HelloWorld example, LiteModuleLoader is called to restore the saved model, but I am not sure what is the suggested way to do so on the native c++ side.

Thanks for helping.

The c++ api is torch::jit::_load_for_mobile. You can find more information in the iOS example: (Prototype) Introduce lite interpreter workflow in Android and iOS — PyTorch Tutorials 1.9.0+cu102 documentation

Thanks for replying. The including list in the example actually helped me.

//#import <LibTorch/LibTorch.h>
#include "ATen/ATen.h"
#include "caffe2/core/timer.h"
#include "caffe2/utils/string_utils.h"
#include "torch/csrc/autograd/grad_mode.h"
#include "torch/script.h"
#include <torch/csrc/jit/mobile/function.h>
#include <torch/csrc/jit/mobile/import.h>
#include <torch/csrc/jit/mobile/interpreter.h>
#include <torch/csrc/jit/mobile/module.h>
#include <torch/csrc/jit/mobile/observer.h>
1 Like