I’m running into an issue with the onnx conversion of the ImageScaler Operation. The Onnx operator has 2 attributes ‘scale’ (single scalar value) and ‘bias’ (list of values, one per channel of ImageScaler input) nnvm/frontend/onnx.py is converting this into two operators, mul_scalar and broadcast_add.
nnvm/frontend/onnx.py:
284 class ImageScaler(OnnxOpConverter):
285
286 @classmethod
287 def _impl_v1(cls, inputs, attr, params):
288 channelScale = attr['scale']
289 bias_attr = attr['bias']
290 bias = SymbolTable().new_const(np.array(bias_attr).reshape([3, 1, 1]))
291 scaledChannel = _sym.__mul_scalar__(inputs[0], scalar=channelScale)
292 ret = _sym.broadcast_add(scaledChannel, bias)
293 return ret
The problem i’m having is i believe line 290 causes the nnvm.frontend.from_onnx(model) to create another variable named ‘_param_1’. If i don’t supply this in the input_shape_dict when calling nnvm.compiler.build() I will get an error. In addition the 2nd parameter from ‘from_onnx’ return value (which should be parameters) is empty, so when creating the runtime, even if i add to input_shape_dict a shape for ‘_param_1’ it’s value is not properly initialized and (I believe this is the reason) I get non-deterministic results for this graph.
Any ideas how I should change the ImageScalar converter?