Repository: pytorch
Issue: Cannot build Caffe2 with TensorRT
Labels: caffe2

## 🐛 Bug

I am trying to build the Caffe2 (master branch) with TensorRT by the following command:
```
cmake .. -DUSE_TENSORRT=ON -DCAFFE2_LINK_LOCAL_PROTOBUF=OFF
sudo make -j8
```

However, I faced with the following errors:
```
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_op_trt.cc: In member function ‘virtual bool caffe2::TensorRTOp::RunOnDevice()’:
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_op_trt.cc:202:47: error: invalid initialization of reference of type ‘const std::vector<long int>&’ from expression of type ‘const c10::ArrayRef<long int>’
         auto chw = CheckDims(dims, tensor_dims);
                                               ^
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_op_trt.cc:16:9: note: in passing argument 2 of ‘int64_t caffe2::{anonymous}::CheckDims(const nvinfer1::Dims&, const std::vector<long int>&)’
 int64_t CheckDims(
         ^
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc: In function ‘void caffe2::{anonymous}::BlobToTensorProto(const string&, caffe2::Workspace*, caffe2::CUDAContext*, onnx_c2::TensorProto*)’:
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:102:59: error: no matching function for call to ‘caffe2::Tensor::Tensor(const caffe2::Tensor&, caffe2::CUDAContext*&)’
     const auto cpu_tensor = TensorCPU(cuda_tensor, context);
                                                           ^
In file included from /home/alex/workspace/pytorch_master/caffe2/core/blob.h:14:0,
                 from /home/alex/workspace/pytorch_master/caffe2/core/operator.h:14,
                 from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.h:9,
                 from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:1:
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:81:3: note: candidate: caffe2::Tensor::Tensor(const caffe2::Tensor&, caffe2::DeviceType)
   Tensor(const Tensor& src, DeviceType type)
   ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:81:3: note:   no known conversion for argument 2 from ‘caffe2::CUDAContext*’ to ‘caffe2::DeviceType {aka c10::DeviceType}’
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:72:12: note: candidate: caffe2::Tensor::Tensor(const std::vector<int>&, caffe2::DeviceType)
   explicit Tensor(const vector<int>& dims, DeviceType type)
            ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:72:12: note:   no known conversion for argument 1 from ‘const caffe2::Tensor’ to ‘const std::vector<int>&’
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:68:12: note: candidate: caffe2::Tensor::Tensor(c10::IntList, c10::Device)
   explicit Tensor(at::IntList dims, at::Device device): Tensor(device) {
            ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:68:12: note:   no known conversion for argument 1 from ‘const caffe2::Tensor’ to ‘c10::IntList {aka c10::ArrayRef<long int>}’
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:59:12: note: candidate: caffe2::Tensor::Tensor(c10::IntList, caffe2::DeviceType)
   explicit Tensor(at::IntList dims, DeviceType type) : Tensor(type) {
            ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:59:12: note:   no known conversion for argument 1 from ‘const caffe2::Tensor’ to ‘c10::IntList {aka c10::ArrayRef<long int>}’
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:45:12: note: candidate: caffe2::Tensor::Tensor(c10::Device)
   explicit Tensor(at::Device device)
            ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:45:12: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:29:3: note: candidate: caffe2::Tensor::Tensor()
   Tensor() : impl_() {}
   ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:29:3: note:   candidate expects 0 arguments, 2 provided
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:23:18: note: candidate: caffe2::Tensor::Tensor(const caffe2::Tensor&)
 class CAFFE2_API Tensor final {
                  ^
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:23:18: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:23:18: note: candidate: caffe2::Tensor::Tensor(caffe2::Tensor&&)
/home/alex/workspace/pytorch_master/caffe2/core/tensor.h:23:18: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc: In member function ‘void caffe2::TensorRTTransformer::Transform(caffe2::Workspace*, caffe2::NetDef*, const std::unordered_map<std::__cxx11::basic_string<char>, caffe2::TensorShape>&)’:
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:476:44: error: no matching function for call to ‘caffe2::onnx::OnnxExporter::OnnxExporter(std::nullptr_t, bool)’
   onnx::OnnxExporter exporter(nullptr, true);
                                            ^
In file included from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.h:11:0,
                 from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:1:
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:42:3: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(caffe2::onnx::DummyName*)
   OnnxExporter(DummyName* dummy = nullptr) {
   ^
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:42:3: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(const caffe2::onnx::OnnxExporter&)
 class CAFFE2_API OnnxExporter {
                  ^
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(caffe2::onnx::OnnxExporter&&)
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:507:45: error: no matching function for call to ‘caffe2::onnx::OnnxExporter::OnnxExporter(std::nullptr_t, bool)’
   onnx::OnnxExporter exporter2(nullptr, true);
                                             ^
In file included from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.h:11:0,
                 from /home/alex/workspace/pytorch_master/caffe2/contrib/tensorrt/tensorrt_tranformer.cc:1:
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:42:3: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(caffe2::onnx::DummyName*)
   OnnxExporter(DummyName* dummy = nullptr) {
   ^
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:42:3: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(const caffe2::onnx::OnnxExporter&)
 class CAFFE2_API OnnxExporter {
                  ^
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note:   candidate expects 1 argument, 2 provided
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note: candidate: caffe2::onnx::OnnxExporter::OnnxExporter(caffe2::onnx::OnnxExporter&&)
/home/alex/workspace/pytorch_master/caffe2/onnx/onnx_exporter.h:36:18: note:   candidate expects 1 argument, 2 provided
caffe2/CMakeFiles/caffe2_gpu.dir/build.make:200511: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/contrib/tensorrt/tensorrt_op_trt.cc.o' failed
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/contrib/tensorrt/tensorrt_op_trt.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
caffe2/CMakeFiles/caffe2_gpu.dir/build.make:200559: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/contrib/tensorrt/tensorrt_tranformer.cc.o' failed
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/contrib/tensorrt/tensorrt_tranformer.cc.o] Error 1
CMakeFiles/Makefile2:2058: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
```

It seems that code in caffe2/contrib/tensorrt is deprecated

Is there a way to solve this issue?

## Environment

OS: Ubuntu 16.04.5 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
CMake version: version 3.12.2
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.0.176
GPU models and configuration: GPU 0: GeForce GTX 1050 Ti
Nvidia driver version: 384.130
TensorRT: 5.0 GA