-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack.cpp
More file actions
29 lines (22 loc) · 688 Bytes
/
hack.cpp
File metadata and controls
29 lines (22 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <torch/script.h>
#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;
// }
torch::jit::script::Module module;
try {
module = torch::jit::load("./traced_resnet_model.pt");
}
catch (const c10::Error& e) {
std::cerr << "error loading the model\n";
return -1;
}
std::vector<torch::jit::IValue> inputs;
inputs.push_back(torch::ones({1, 3, 224, 224}));
at::Tensor output = module.forward(inputs).toTensor();
std::cout << output.slice(/*dim=*/1, /*start=*/0, /*end=*/5) << '\n';
std::cout << "ok\n";
}