Hello,
I'm converting Onnx to Dlc using snpe1.64 and I found a strange behavior of output shape inference of Expand operation.
In the file snpe-1.64.0.3605/lib/python/qti/aisw/converters/onnx/data_translations.py at the class OnnxExpandTranslation, your logic to find output shape is not always correct.
# ------------------------------------------------------------------------------# Expand# ------------------------------------------------------------------------------class OnnxExpandTranslation(OnnxTranslationBase):def __init__(self):OnnxTranslationBase.__init__(self)self.register_op_schema('Expand', [8, 13])def extract_parameters(self, src_op, converter_context):graph = converter_context.ir_graphsrc_input_names = list(map(str, src_op.input))shape_constant_op = self.fetch_constant_op(src_input_names[1], converter_context, dtype=np.int32, fail_if_not_found=True)log_debug1(code_to_message.get_debugging_message("DEBUG_STATIC_OP")(src_input_names[1]))output_shape = [int(dim_size) for dim_size in shape_constant_op.tensor]return op_adapter.ExpandOp(src_op.name,output_shape)def extract_input_names(self, src_op, converter_context):return [str(src_op.input[0])]
In this code, you use the value of constant tensor in Expand Operation as the output shape, but according to documentation of Onnx (https://github.com/onnx/onnx/blob/main/docs/Operators.md#Expand), the output shape should also follow broadcast rule.
For exemple:
If you have an input with shape (3, 1), and your constant tensor is (2, 1, 6), you should have output shape equal to (2, 3, 6) instead of (2, 1, 6) in your implementation. You can read the example in Onnx documentation for more information.
Dear customer,
I assume your issue is the incorrect dimension between ONNX and SNPE.
SNPE supported to NHWC but ONNX default is NCHW so that you need to convert SNPE result(NHWC) to ONNX format(NCHW). Then start to your outputs comparsion.
BR.
Wei
Hi weihuan
So, that means expand ops is supported rite? but i am also trying onnx to dlc converter and i am getting error like (converter does not support op type expand).
and for scatter_nd ops i am also getting error that converter does not support op type scatter_nd.
I saw in SNPE sdk documentation inside revision history (https://developer.qualcomm.com/sites/default/files/docs/snpe/revision_hi...) that from snpe-1.59.0 both expand and scatter_nd are supported. But not sure why i am getting these error. can you please help me to fix that.
Thanks
Rajan
Dear customer,
The ops of Scatter sill don't support on SNPE yet. You can try to wirte SNPE UDL or SNPE UDO if you want to support you feature ops.
BR.
Wei