Hello,
So, I have the model defined as below which I am converting to ONNX:
import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.onnxclass MyModel(nn.Module):def __init__(self):super(MyModel, self).__init__()def forward(self, x):return x[[1, 2], [2, 3]]x = torch.rand(10, 10)model = MyModel()torch.onnx.export(model,x,"test.onnx",verbose=True,input_names=['input'],output_names=['output'],opset_version=12)
graph(%input : Float(10:10, 10:1),%16 : Long(1:1)):%1 : Tensor = onnx::Shape(%input)%2 : Tensor = onnx::Constant[value={1}]()%3 : Tensor = onnx::Gather[axis=0](%1, %2)%4 : Tensor = onnx::Flatten[axis=2](%input)%5 : Long(2:1) = onnx::Constant[value= 1 2 [ CPULongType{2} ]]()%6 : LongTensor = onnx::Mul(%5, %3)%7 : Long(2:1) = onnx::Constant[value= 2 3 [ CPULongType{2} ]]()%8 : LongTensor = onnx::Add(%7, %6)%9 : Tensor = onnx::Gather[axis=0](%4, %8)%10 : Tensor = onnx::Shape(%8)%13 : Tensor = onnx::Reshape(%9, %16)%14 : Tensor = onnx::Concat[axis=0](%10)%output : Float(2:1) = onnx::Reshape(%13, %14) # onnx_test.py:56:0return (%output)
However, when I am using snpe-onnx-to-dlc to convert the model, I get the following error:
Traceback (most recent call last):File "path-to/snpe-1.41.0.2173/lib/python/qti/aisw/converters/onnx/onnx_to_ir.py", line 140, in convertself.graph)File "path-to/snpe-1.41.0.2173/lib/python/qti/aisw/converters/common/converter_ir/translation.py", line 51, in apply_method_to_opreturn translation.apply_method(method_name, *args)File "path-to/snpe-1.41.0.2173/lib/python/qti/aisw/converters/common/converter_ir/translation.py", line 17, in apply_methodreturn self.indexed_methods[method_name](*args)File "path-to/snpe-1.41.0.2173/lib/python/qti/aisw/converters/onnx/data_translations.py", line 204, in add_opgraph.add(ops[-1], input_names, output_names)File "path-to/snpe-1.41.0.2173/lib/python/qti/aisw/converters/common/converter_ir/op_graph.py", line 332, in addraise KeyError("Graph has no buffer %s, referred to as input for %s" % (name, op.name))KeyError: 'Graph has no buffer 1, referred to as input for Gather_2'2020-09-06 02:40:14,234 - 166 - ERROR - Node Gather_2: 'Graph has no buffer 1, referred to as input for Gather_2'
This code will pass if seting "return x[[1, 2], [2, 3]]" to "return x". Therefore, maybe the index op is not supported in snpe.
I am also facing the same issue "graph ha s no buffer 1362 , referrred to as input for concat_275" while converting onnx model to quantized moodel using qnn-onnx converter. If anyone knows the solution, please comment.
any has solutions? i have same error when convert with udo cfgs, i have no idea
I faced the same problem, when my SNPE 2.16.4.... && onnx1.11.0, when I use my onnx model which optset version is 12, it break down ,while i changed my model with optset 9, it works, the matter maybe the version of the onnx's optset and version of snpe, hope it will help.