Created
January 27, 2022 07:08
-
-
Save nihui/2292e695bb24e0b2dbb08240e9ace347 to your computer and use it in GitHub Desktop.
libtorch inference test
This file contains hidden or 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> | |
int main() | |
{ | |
c10::InferenceMode guard(true); | |
torch::NoGradGuard no_grad; | |
torch::jit::Module mod2 = torch::jit::load("stylegan.pt"); | |
mod2.eval(); | |
at::Tensor t = torch::ones({1, 18, 512}, torch::kFloat32); | |
std::vector<torch::jit::IValue> inputs; | |
inputs.push_back(t); | |
auto outputs = mod2.forward(inputs).toTensor(); | |
const int ndim = (int)outputs.dim(); | |
fprintf(stderr, "ndim = %d\n", ndim); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment