Files
pytorch/binaries/lite_interpreter_model_load.cc
Ailing Zhang 24c904951c Replace AutoNonVariableTypeMode with InferenceMode in fbcode. (#55114)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55114

Test Plan: CI

Reviewed By: ezyang, bhosmer

Differential Revision: D27472768

fbshipit-source-id: 76f17ef7de40f6e04e2968f8958027b5f93e1c0c
2021-04-02 11:45:53 -07:00

34 lines
1.1 KiB
C++

#include "ATen/ATen.h"
#include <torch/csrc/jit/api/module.h>
#include <torch/csrc/autograd/generated/variable_factories.h>
#include <torch/csrc/jit/mobile/import.h>
#include <torch/csrc/jit/mobile/module.h>
#include <torch/csrc/jit/serialization/import.h>
#include "torch/script.h"
C10_DEFINE_string(model, "", "The given bytecode model to check if it is supported by lite_interpreter.");
int main(int argc, char** argv) {
c10::SetUsageMessage(
"Check if exported bytecode model is runnable by lite_interpreter.\n"
"Example usage:\n"
"./lite_interpreter_model_load"
" --model=<model_file>");
if (!c10::ParseCommandLineFlags(&argc, &argv)) {
std::cerr << "Failed to parse command line flags!" << std::endl;
return 1;
}
if (FLAGS_model.empty()) {
std::cerr << FLAGS_model << ":Model file is not provided\n";
return -1;
}
// TODO: avoid having to set this guard for custom mobile build with mobile
// interpreter.
c10::InferenceMode mode;
torch::jit::mobile::Module bc = torch::jit::_load_for_mobile(FLAGS_model);
return 0;
}