Skip to content

A model with two function nodes fails to pass ONNXchecker after ONNX infer_shape #318

@titaiwangms

Description

@titaiwangms

A model with two function nodes fails to pass ONNXchecker after ONNX infer_shape.

Error messages:

C.check_model(protobuf_string, full_check)
onnx.onnx_cpp2py_export.checker.ValidationError: Field 'shape' of 'type' is required but missing.

ONNX model proto:

ir_version: 7
producer_name: "pytorch"
producer_version: "2.0.0"
graph {
  node {
    output: "1"
    name: "Constant_0"
    op_type: "Constant"
    attribute {
      name: "value"
      t {
        data_type: 7
        raw_data: "\001\000\000\000\000\000\000\000"
      }
      type: TENSOR
    }
    doc_string: ""
  }
  node {
    input: "arg0_1"
    input: "1"
    output: "3"
    name: "aten_add_1"
    op_type: "aten_add"
    doc_string: ""
    domain: "onnx-script"
  }
  node {
    input: "3"
    output: "4"
    name: "aten_sigmoid_2"
    op_type: "aten_sigmoid"
    doc_string: ""
    domain: "onnx-script"
  }
  name: "torch_jit"
  input {
    name: "arg0_1"
    type {
      tensor_type {
        elem_type: 1
        shape {
          dim {
            dim_value: 1
          }
          dim {
            dim_value: 4
          }
          dim {
            dim_value: 2
          }
          dim {
            dim_value: 3
          }
        }
      }
    }
  }
  output {
    name: "4"
    type {
      tensor_type {
        elem_type: 1
      }
    }
  }
  value_info {
    name: "3"
    type {
      tensor_type {
        elem_type: 1
      }
    }
  }
  value_info {
    name: "1"
    type {
      tensor_type {
        elem_type: 7
        shape {
        }
      }
    }
  }
}
opset_import {
  version: 14
}
opset_import {
  domain: "onnx-script"
  version: 1
}
functions {
  name: "aten_add"
  input: "self"
  input: "other"
  output: "return_val"
  attribute: "alpha"
  node {
    output: "alpha"
    name: "n0"
    op_type: "Constant"
    attribute {
      name: "value_float"
      type: FLOAT
      ref_attr_name: "alpha"
    }
    domain: ""
  }
  node {
    output: "tmp"
    name: "n1"
    op_type: "Constant"
    attribute {
      name: "value"
      t {
        data_type: 7
        int64_data: 1
        name: "tmp"
      }
      type: TENSOR
    }
    domain: ""
  }
  node {
    input: "tmp"
    input: "alpha"
    output: "tmp_cast"
    name: "n2"
    op_type: "CastLike"
    domain: ""
  }
  node {
    input: "alpha"
    input: "tmp_cast"
    output: "tmp_0"
    name: "n3"
    op_type: "Equal"
    domain: ""
  }
  node {
    input: "tmp_0"
    output: "cond"
    name: "n4"
    op_type: "Not"
    domain: ""
  }
  node {
    input: "cond"
    output: "other_4"
    name: "n5"
    op_type: "If"
    attribute {
      name: "then_branch"
      g {
        node {
          output: "alpha_1"
          name: "n0"
          op_type: "Constant"
          attribute {
            name: "value_float"
            type: FLOAT
            ref_attr_name: "alpha"
          }
          domain: ""
        }
        node {
          input: "other"
          input: "alpha_1"
          output: "other_2"
          name: "n1"
          op_type: "Mul"
          domain: ""
        }
        name: "thenGraph_4"
        output {
          name: "other_2"
          type {
          }
        }
      }
      type: GRAPH
    }
    attribute {
      name: "else_branch"
      g {
        node {
          input: "other"
          output: "other_3"
          name: "n0"
          op_type: "Identity"
          domain: ""
        }
        name: "elseGraph_4"
        output {
          name: "other_3"
          type {
          }
        }
      }
      type: GRAPH
    }
    domain: ""
  }
  node {
    input: "self"
    input: "other_4"
    output: "return_val"
    name: "n6"
    op_type: "Add"
    domain: ""
  }
  opset_import {
    domain: ""
    version: 18
  }
  domain: "onnx-script"
}
functions {
  name: "aten_sigmoid"
  input: "self"
  output: "return_val"
  node {
    input: "self"
    output: "return_val"
    name: "n0"
    op_type: "Sigmoid"
    domain: ""
  }
  opset_import {
    domain: ""
    version: 18
  }
  domain: "onnx-script"
}

cc @gramalingam @liqunfu

Metadata

Metadata

Assignees

Labels

module: torchlibRelated to the torch/aten function lib in development

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions