Need help… New in Torch
Wrote a code seeing here and there…
Doesn’t getting solved from 2 days… Please help it is emergency
#include <torch/torch.h>
#include <torch/script.h>
#include <iostream>
#include <memory>
#include <dirent.h>

using namespace std;

int main(int argc, const char* argv[]) {
  
  // Create the device we pass around based on whether CUDA is available.
  torch::Device device(torch::kCPU);
  if (torch::cuda::is_available()) {
    std::cout << "CUDA is available! Training on GPU." << std::endl;
    device = torch::Device(torch::kCUDA);
  }

  if (argc != 2) {
    std::cerr << "usage: LMtesting <path-to-exported-script-module>\n";
    return -1;
  }

  torch::jit::script::Module module;
  try {
    // Deserialize the ScriptModule from a file using torch::jit::load().
    module = torch::jit::load(argv[1]);
  }
  catch (const c10::Error& e) {
    std::cerr << "error loading the model\n";
    return -1;
  }

  std::cout << "ok\n";
  std::cout << "Language Model\n\n";

  // Hyper parameters 

  const int64_t embed_size = 128;
  const int64_t hidden_size = 1024;
  const int64_t num_layers = 1;
  const int64_t num_samples = 1000;  // the number of words to be sampled
  const int64_t batch_size = 20;
  const int64_t sequence_length = 30;
  const size_t num_epochs = 5;
  const double learning_rate = 0.002;

  vector<torch::jit::IValue> inputs;
  vector<float> data(sequence_length*batch_size, 1.0);
  // Geting the error in next 3 lines
  torch::Tensor data_tensor = torch::from_blob(data.data(), {sequence_length,batch_size}.to(at::Device("cuda:0")); 
  torch::Tensor h0 = torch::from_blob(vector<float>(num_layers* batch_size * hidden_size, 0.0), {num_layers, batch_size, hidden_size}).to(at::Device("cuda:0"));
  torch::Tensor c0 = torch::from_blob(vector<float>(num_layers* batch_size * hidden_size, 0.0), {num_layers, batch_size, hidden_size}).to(at::Device("cuda:0"));
  
  inputs.push_back(data_tensor);
  inputs.push_back(h0);

  // Getting error in next 2 lines
  inputs.push(c0);
  torch::Tensor output = module->forward(inputs).toTensor().cpu();
  auto accessor = output.accessor<float, 2>();
}