File: main.cpp

package info (click to toggle)
pytorch-text 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,560 kB
  • sloc: python: 14,197; cpp: 2,404; sh: 214; makefile: 20
file content (24 lines) | stat: -rw-r--r-- 616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <torch/nn/functional/activation.h>
#include <torch/script.h>

#include <iostream>
#include <string>
#include <vector>

int main(int argc, const char* argv[]) {
  std::cout << "Loading model...\n";

  torch::jit::script::Module module;
  try {
    module = torch::jit::load(argv[1]);
  } catch (const c10::Error& e) {
    return -1;
  }

  torch::NoGradGuard no_grad; // ensures that autograd is off
  torch::jit::IValue tokens_ivalue = module.forward(std::vector<c10::IValue>(
      1, "The green grasshopper jumped over the fence"));
  std::cout << "Result: " << tokens_ivalue << std::endl;

  return 0;
}