Problem Converting Caffe model to dlc using SNPE

548 views Asked by At

I am facing an issue in converting my caffe model to dlc using SNPE.

Specifically in the "Scale" layer.

The first two layers are as follows

name: "First"
  input: "data"
  input_shape {
  dim: 1
  dim: 3
  dim: xxx
  dim: xxx
} 

layer {
  name: "data/Scale"
  type: "Scale"
  bottom: "data"
  top: "data/Scale"
  scale_param {
    filler: {
      value: 0.0078125   
    }
    bias_term: true
    bias_filler: {
      value: -1
    }
  }
  param {
    lr_mult: 0
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}

layer {
  name: "Conv2d_0/convolution"
  type: "Convolution"
  convolution_param {
    num_output: 32
    pad: 1
    kernel_size: 3
    stride: 2
  }
  bottom: 'data/Scale'
  top: "Conv2d_0/convolution"
}

I get the following error:

('Encountered Error:', 'list index out of range')

Stack Trace:
Traceback (most recent call last):

  File "/home/nithin.ga/SNPE_19/snpe-1.19.2/bin/x86_64-linux-clang/snpe-caffe-to-dlc", line 115, in <module>
    args.enable_strict_validation)

  File "/home/nithin.ga/SNPE_19/snpe-1.19.2/lib/python/snpe/snpe_caffe_to_dlc.py", line 1145, in convert
    self.convert_caffe_new(self.spec)

  File "/home/nithin.ga/SNPE_19/snpe-1.19.2/lib/python/snpe/snpe_caffe_to_dlc.py", line 1327, in convert_caffe_new
    layer_seq = self._blob_connectivity_map.check_s_folding(layer)

  File "/home/nithin.ga/SNPE_19/snpe-1.19.2/lib/python/snpe/snpe_caffe_to_dlc.py", line 459, in check_s_folding

output_layer = self._blobs[prev_layer_output_blob]['output_of_layers'][0]
IndexError: list index out of range
1

There are 1 answers

0
Gino Mempin On

Here is the documentation for the Scale layer limitation of SNPE:

https://developer.qualcomm.com/docs/snpe/limitations.html

Batch normalization (+ Scaling)

  • Caffe: Scaling (scale_layer) is optional. If present, it extends functionality of Batch normalization (batch_norm_layer). If not present, batch_norm_layer will still be converted as per Caffe specification. scale_layer used anywhere else in the network but immediately after the batch_norm_layer is not supported.

There is support for scaling, but only if it's part of the data layer:

https://developer.qualcomm.com/docs/snpe/network_layers.html

Scale (Image)

Input image scaling, maintains aspect ratio. This function is primarily intended for images, but technically any 2D input data can be processed if it makes sense. Scaling parameters are provided as an option to the model converter tool.

There is no such Caffe layer by itself. This functionality is technically part of the Caffe data provider.