Repository: pytorch
Issue: [Caffe2]: caffe2.python.caffe_translator.py script doesn't convert "Split" and "Slice" Layer
Labels: caffe2

## Issue description

I ran the caffe_translator.py script to convert my Caffe model to Caffe2.
My Caffe model has "Split" and "Slice" Layer.  The caffe_translator.py doesn't seem to handle them.
I had to hack on my own copy of caffe_translator.py to get it running and then manually edit the pbtxt file.

## Code example

Please try to provide a minimal example to repro the bug.
Error messages and stack traces are also helpful.

Example 1
$ python -m caffe2.python.caffe_translator IDN_x4_deploy.prototxt IDN_x4.caffemodel 
INFO:caffe_translator:Translate layer conv1
INFO:caffe_translator:Translate layer relu_conv1
INFO:caffe_translator:Translate layer conv2
INFO:caffe_translator:Translate layer relu_conv2
INFO:caffe_translator:Translate layer split1
Traceback (most recent call last):
  File "/home/jsun/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe_translator.py", line 212, in TranslateLayer
    caffe_ops, params = cls.registry_[layer.type](
KeyError: 'Split'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jsun/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/jsun/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jsun/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe_translator.py", line 912, in <module>
    input_dims=args.input_dims
  File "/home/jsun/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe_translator.py", line 284, in TranslateModel
    return TranslatorRegistry.TranslateModel(*args, **kwargs)
  File "/home/jsun/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe_translator.py", line 273, in TranslateModel
    net_params=net_params, input_dims=input_dims)
  File "/home/jsun/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe_translator.py", line 216, in TranslateLayer
    str(layer))
KeyError: 'No translator registered for layer: name: "split1"\ntype: "Split"\nbottom: "conv2"\ntop: "split1_1"\ntop: "split1_2"\n yet.'

Example 2
I get a similar stack-trace for "Slice" operator.

Traceback (most recent call last):
  File "/home/jsun/Code/IDE_caffe_to_caffe2/new/caffe_translator.py", line 212, in TranslateLayer
    caffe_ops, params = cls.registry_[layer.type](
KeyError: 'Slice'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jsun/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/jsun/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jsun/Code/IDE_caffe_to_caffe2/new/caffe_translator.py", line 917, in <module>
    input_dims=args.input_dims
  File "/home/jsun/Code/IDE_caffe_to_caffe2/new/caffe_translator.py", line 284, in TranslateModel
    return TranslatorRegistry.TranslateModel(*args, **kwargs)
  File "/home/jsun/Code/IDE_caffe_to_caffe2/new/caffe_translator.py", line 273, in TranslateModel
    net_params=net_params, input_dims=input_dims)
  File "/home/jsun/Code/IDE_caffe_to_caffe2/new/caffe_translator.py", line 216, in TranslateLayer
    str(layer))
KeyError: 'No translator registered for layer: name: "slice1"\ntype: "Slice"\nbottom: "conv3_3"\ntop: "slice1_1"\ntop: "slice1_2"\nslice_param {\n  slice_point: 16\n  axis: 1\n}\n yet.'



## System Info
Please copy and paste the output from our

$ python collect_env.py 
Collecting environment information...
PyTorch version: 0.4.0
Is debug build: No
CUDA used to build PyTorch: 9.1.85

OS: Ubuntu 18.04 LTS
GCC version: (Ubuntu 6.4.0-17ubuntu1) 6.4.0 20180424
CMake version: version 3.9.4

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.1.85
GPU models and configuration: GPU 0: GeForce GTX 1070
Nvidia driver version: 396.24
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a
/usr/local/MATLAB/R2018a/bin/glnxa64/libcudnn.so.7.0.3
/usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn.so.7.0.5
/usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn_static.a
/usr/local/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb

Versions of relevant libraries:
[pip3] guided-filter-pytorch (1.1.1)
[pip3] numpy (1.14.3)
[pip3] numpydoc (0.7.0)
[pip3] torch (0.5.0a0+833b1e6)
[pip3] torchvision (0.2.1)
[conda] cuda90                    1.0                  h6433d27_0    pytorch
[conda] cuda91                    1.0                  h4c16780_0    pytorch
[conda] guided-filter-pytorch     1.1.1                     <pip>
[conda] magma-cuda90              2.3.0                         1    pytorch
[conda] pytorch                   0.4.0           py36_cuda9.1.85_cudnn7.1.2_1  [cuda91]  pytorch
[conda] torch                     0.5.0a0+833b1e6           <pip>
[conda] torchvision               0.2.1                    py36_1    pytorch