Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onnx转mlir模型时 KeyError: 'operand /backbone/norm1/Div_output_0 not found' #200

Open
jkl375 opened this issue Dec 11, 2024 · 1 comment

Comments

@jkl375
Copy link

jkl375 commented Dec 11, 2024

自己的onnx模型转mlir模型时 KeyError: 'operand /backbone/norm1/Div_output_0 not found'

root@909fed522ed3:/app# sh convert.sh 
2024/12/11 14:33:42 - INFO : TPU-MLIR UNKNOWN.UNKNOWN-20241211
2024/12/11 14:33:42 - INFO : 
         _____________________________________________________ 
        | preprocess:                                           |
        |   (x - mean) * scale                                  |
        '-------------------------------------------------------'
  config Preprocess args : 
        resize_dims           : same to net input dims
        keep_aspect_ratio     : False
        keep_ratio_mode       : letterbox
        pad_value             : 0
        pad_type              : center
        --------------------------
        mean                  : [0.0, 0.0, 0.0]
        scale                 : [1.0, 1.0, 1.0]
        --------------------------
        pixel_format          : bgr
        channel_format        : nchw

2024/12/11 14:33:43 - INFO : Input_shape assigned
2024/12/11 14:33:54 - INFO : ConstantFolding finished
2024/12/11 14:33:54 - INFO : skip_fuse_bn:False
2024/12/11 14:34:03 - INFO : Onnxsim opt finished
2024/12/11 14:34:05 - INFO : ConstantFolding finished
Traceback (most recent call last):
  File "/app/tpu-mlir-master/python/tools/model_transform.py", line 416, in <module>
    tool.model_transform(args.mlir, args.add_postprocess, args.patterns_count)
  File "/app/tpu-mlir-master/python/tools/model_transform.py", line 57, in model_transform
    self.converter.generate_mlir(mlir_origin)
  File "/app/tpu-mlir-master/python/transform/OnnxConverter.py", line 737, in generate_mlir
    self.onnxop_factory.get(n.op_type, lambda x: NoneAndRaise(x))(n)
  File "/app/tpu-mlir-master/python/transform/OnnxConverter.py", line 233, in <lambda>
    "Mul": lambda node: self.convert_mul_op(node),
  File "/app/tpu-mlir-master/python/transform/OnnxConverter.py", line 1163, in convert_mul_op
    self.convert_mul_op(onnx_node)
  File "/app/tpu-mlir-master/python/transform/OnnxConverter.py", line 1166, in convert_mul_op
    op0 = self.getOp(lhs)
  File "/app/tpu-mlir-master/python/transform/BaseConverter.py", line 60, in getOp
    return self.getOperand(name)
  File "/app/tpu-mlir-master/python/transform/BaseConverter.py", line 54, in getOperand
    raise KeyError("operand {} not found".format(name))
KeyError: 'operand /backbone/norm1/Div_output_0 not found'
@aidreamwin
Copy link

我遇到相同的问题:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_transform.py", line 407, in <module>
    tool.model_transform(args.mlir, args.add_postprocess, args.patterns_count)
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_transform.py", line 57, in model_transform
    self.converter.generate_mlir(mlir_origin)
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/transform/OnnxConverter.py", line 733, in generate_mlir
    self.onnxop_factory.get(n.op_type, lambda x: NoneAndRaise(x))(n)
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/transform/OnnxConverter.py", line 235, in <lambda>
    "Pad": lambda node: self.convert_pad_op(node),
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/transform/OnnxConverter.py", line 1626, in convert_pad_op
    pads = list(self.getWeight(onnx_node.inputs[1]))
  File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/transform/BaseConverter.py", line 84, in getWeight
    raise KeyError("No {} tensor in model".format(name))
KeyError: 'No /pool1/pad/Reshape_1_output_0 tensor in model'

模型结构如下:
modules['pad'] = nn.ZeroPad2d([1, 1, 1, 1])
modules['conv'] = nn.Conv2d(in_channels, out_channels, kernel_size, stride, 0, bias=True)
mlir v1.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants