Created
July 30, 2019 00:36
-
-
Save sanketgujar/baf27851fb1b849ced78cf0668411dd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <torch/script.h> // One-stop header. | |
#include <iostream> | |
#include <memory> | |
int main(int argc, const char* argv[]) { | |
if (argc != 2) { | |
std::cerr << "usage: example-app <path-to-exported-script-module>\n"; | |
return -1; | |
} | |
// Deserialize the ScriptModule from a file using torch::jit::load(). | |
std::shared_ptr < torch::jit::script::Module > module = torch::jit::load(argv[1]); | |
assert(module != nullptr); | |
std::cout << "ok\n"; | |
module->to(at::kCUDA); | |
std::vector < torch::jit::IValue > inputs; | |
inputs.push_back(torch::ones({1, 36, 1240, 700}).cuda()); | |
at::Tensor output = module->forward(inputs).toTensor(); | |
// std::cout << output.slice(/*dim=*/1, /*start=*/0, /*end=*/5) << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment