MCPcopy Create free account
hub / github.com/XiaoMi/mace / __init__

Method __init__

tools/python/transform/caffe_converter.py:172–237  ·  view source on GitHub ↗
(self, option, src_model_file, src_weight_file)

Source from the content-addressed store, hash-verified

170 }
171
172 def __init__(self, option, src_model_file, src_weight_file):
173 self._op_converters = {
174 'Input': self.convert_nop,
175 'Convolution': self.convert_conv2d,
176 'Deconvolution': self.convert_deconv2d,
177 'Eltwise': self.convert_elementwise,
178 'Add': self.convert_add,
179 'ReLU': self.convert_activation,
180 'ReLU6': self.convert_activation,
181 'TanH': self.convert_activation,
182 'Sigmoid': self.convert_activation,
183 'PReLU': self.convert_activation,
184 'Clip': self.convert_activation,
185 'ELU': self.convert_activation,
186 'Pooling': self.convert_pooling,
187 'Concat': self.convert_concat,
188 'Slice': self.convert_slice,
189 'Softmax': self.convert_softmax,
190 'InnerProduct': self.convert_fully_connected,
191 'Interp': self.convert_interp,
192 'BatchNorm': self.convert_folded_batchnorm,
193 'GroupNorm': self.convert_group_norm,
194 'Crop': self.convert_crop,
195 'Scale': self.convert_scale,
196 'ShuffleChannel': self.convert_channel_shuffle,
197 'Permute': self.convert_permute,
198 'Flatten': self.convert_flatten,
199 'PriorBox': self.convert_prior_box,
200 'Reshape': self.convert_reshape,
201 'L2Normalization': self.convert_lpnorm,
202 'L1Normalization': self.convert_lpnorm,
203 'MVN': self.convert_MVN,
204 'Bias': self.convert_bias,
205 'ArgMax': self.convert_argmax,
206 'ResizeNearest': self.convert_resize_nearest,
207 'NonlocalReshape': self.convert_nonlocal_reshape,
208 'MatMul': self.convert_matmul,
209 'DetectionOutput': self.convert_detection_output,
210 }
211 self._option = option
212 self._converter_info = dict()
213 self._mace_net_def = mace_pb2.NetDef()
214 ConverterUtil.set_filter_format(self._mace_net_def, DataFormat.OIHW)
215 ConverterUtil.add_data_format_arg(self._mace_net_def, DataFormat.NCHW)
216 ConverterUtil.set_framework_type(
217 self._mace_net_def, FrameworkType.CAFFE.value)
218 self._caffe_net = CaffeNet()
219 self._caffe_layers = caffe_pb2.NetParameter()
220 caffe_weights = caffe_pb2.NetParameter()
221
222 # parse prototxt
223 with open(src_model_file, 'r') as f:
224 google.protobuf.text_format.Merge(
225 str(f.read()), self._caffe_layers)
226 self.filter_test_layers(self._caffe_layers)
227 for layer in self._caffe_layers.layer:
228 self._caffe_net.add_layer(layer)
229

Callers

nothing calls this directly

Calls 7

filter_test_layersMethod · 0.95
CaffeNetClass · 0.85
add_data_format_argMethod · 0.80
set_framework_typeMethod · 0.80
add_layerMethod · 0.80
add_blobMethod · 0.80
set_filter_formatMethod · 0.45

Tested by

no test coverage detected