Repository: pytorch
Issue: Torchscript Inference with DLL Creation
Labels: oncall: jit

## Issue description

I am developing in Windows 10 with Visual Studio 2019 and am trying to create a callable DLL.  I created a simple C++ test project running the basic Torchscript example, and it seems to work fine.  I then try to create a callable DLL and seem to run into

## Code example

`
#include "pch.h"
#include <torch/script.h>
#include <torch/torch.h>
#include <memory>
#include <iomanip>
#include <iostream>
#include <fstream>

extern "C"
{
    __declspec(dllexport) void PerformInference() {

        // Load up GPU stuff
        torch::DeviceType device_type;
        if (torch::cuda::is_available()) {
            std::cout << "CUDA available! Training on GPU." << std::endl;
            device_type = torch::kCUDA;
        }
        else {
            std::cout << "Training on CPU." << std::endl;
            device_type = torch::kCPU;
        }
        torch::Device device(device_type);
        torch::jit::script::Module module;
        std::cout << "Attempting to load resnet model.." << std::endl;
        try {
            // Deserialize the ScriptModule from a file using torch::jit::load().
            module = torch::jit::load("C:\\PyTorchPictureTest\\Model\\traced_resnet_model_pretrained.pt");
            std::cout << "Successfully loaded resnet model" << std::endl;

            module.to(at::kCUDA);
            std::cout << "Moved model to gpu" << std::endl;

            std::vector<torch::jit::IValue> inputs;
            inputs.push_back(torch::ones({ 1, 3, 224, 224 }).to(torch::kCUDA));
            torch::Tensor out_tensor = module.forward(inputs).toTensor();
            std::cout << out_tensor << '\n';
            torch::Tensor out_tensor_cpu = out_tensor.to(torch::kCPU);

            torch::Tensor out_tensor_cpu2 = out_tensor.cpu();
            std::cout << "\n" << std::endl;
            std::cout << out_tensor.sizes() << std::endl;
            std::cout << out_tensor.sizes()[0] << std::endl;
            std::cout << out_tensor.sizes()[1] << std::endl;
            std::cout << "\n" << std::endl;

            // Write tensor to file
            std::ofstream myfile("example.txt");
            if (myfile.is_open())
            {
                for (int i = 0; i < out_tensor.sizes()[1] - 1; i++) {
                    myfile << out_tensor[0][i].item<float_t>() << "\n";
                }
                myfile << out_tensor[0][out_tensor.sizes()[1] - 1].item<float_t>() << "\n";
                myfile.close();
            }
            else std::cout << "Unable to open file";

        }
        catch (const c10::Error & e) {
            std::cerr << "error loading the model\n";
            return -1;
        }
    }
}
`

## Errors generated
1297 Errors

A few listed below

interned_strings.h, line 374: Code E0040, expected an identifier
TensorBody.h, line 607: Code E0106, invalid type for bit field 
TensorBody.h, line 610: Code E0106, invalid type for bit field 
TensorBody.h, line 620: Code E0757, member "at::Tensor::int64_t" is not a type name

## Library information and build dependencies
- LibTorch C++
- OS: Windows 10
- PyTorch version: 1.4.0, downloaded pre-built binaries from PyTorch Website (did not build from source)
- Python version:
- CUDA/cuDNN version: CUDA 10.1
- Other: Visual Studio 2019

Again, when I run the same code as a Visual C++ project, it seems to run fine.
For my DLL project, I have used the same project file template to create another DLL (one that does not use LibTorch C++) and it seems to work fine.

I would appreciate any insight.  Thanks in advance.

cc @suo