diff --git a/source/onnx.js b/source/onnx.js index cd1dc55977..4872cdb0e8 100644 --- a/source/onnx.js +++ b/source/onnx.js @@ -432,6 +432,11 @@ onnx.Attribute = class { this._description = attribute.doc_string || ''; this._type = null; this._value = null; + if (attribute.ref_attr_name) { + this._value = attribute.ref_attr_name; + this._type = 'reference'; + return; + } switch (attribute.type) { case onnx.AttributeType.UNDEFINED: break; @@ -1959,7 +1964,10 @@ onnx.JsonReader = class { if (value.type && this._attributeTypes.has(value.type)) { value.type = this._attributeTypes.get(value.type); } - if (value.type === onnx.AttributeType.FLOATS || Array.isArray(value.floats)) { + if (value.refAttrName) { + value.ref_attr_name = value.refAttrName; + delete value.refAttrName; + } else if (value.type === onnx.AttributeType.FLOATS || Array.isArray(value.floats)) { value.floats = value.floats.map((value) => parseFloat(value)); } else if (value.type === onnx.AttributeType.INTS || Array.isArray(value.ints)) { value.ints = value.ints.map((value) => parseInt(value, 10)); diff --git a/test/models.json b/test/models.json index ee3afd2c38..90a6e907ad 100644 --- a/test/models.json +++ b/test/models.json @@ -3640,6 +3640,49 @@ "format": "ONNX v3", "link": "https://github.com/lutzroeder/netron/issues/6" }, + { + "type": "onnx", + "target": "issue_119.onnx", + "source": "https://github.com/lutzroeder/netron/files/10349170/issue_119.onnx.zip[issue_119.onnx]", + "format": "ONNX v4", + "link": "https://github.com/lutzroeder/netron/issues/119" + }, + { + "type": "onnx", + "target": "issue_168_if.pbtxt", + "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_if.pbtxt]", + "format": "ONNX v3", + "link": "https://github.com/lutzroeder/netron/issues/168" + }, + { + "type": "onnx", + "target": "issue_168_loop.pbtxt", + "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_loop.pbtxt]", + "format": "ONNX v3", + "link": "https://github.com/lutzroeder/netron/issues/168" + }, + { + "type": "onnx", + "target": "issue_168_scan.pbtxt", + "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_scan.pbtxt]", + "format": "ONNX v3", + "link": "https://github.com/lutzroeder/netron/issues/168" + }, + { + "type": "onnx", + "target": "issue_589.onnx.zip", + "source": "https://github.com/lutzroeder/netron/files/10349190/issue_589.onnx.zip", + "format": "ONNX v6", + "action": "skip-render", + "link": "https://github.com/lutzroeder/netron/issues/589" + }, + { + "type": "onnx", + "target": "issue_845.onnx", + "source": "https://github.com/lutzroeder/netron/files/10349194/issue_845.onnx.zip[issue_845.onnx]", + "format": "ONNX v4", + "link": "https://github.com/lutzroeder/netron/issues/6" + }, { "type": "onnx", "target": "issue_1029.onnx", @@ -3647,6 +3690,20 @@ "format": "ONNX v8", "link": "https://github.com/lutzroeder/netron/issues/1029" }, + { + "type": "onnx", + "target": "issue_1138.json", + "source": "https://github.com/lutzroeder/netron/files/12343742/issue_1138.json.zip[issue_1138.json]", + "format": "ONNX JSON v9", + "link": "https://github.com/lutzroeder/netron/issues/1138" + }, + { + "type": "onnx", + "target": "issue_1138.onnx", + "source": "https://github.com/lutzroeder/netron/files/12343684/issue_1138.onnx.zip[issue_1138.onnx]", + "format": "ONNX v9", + "link": "https://github.com/lutzroeder/netron/issues/1138" + }, { "type": "onnx", "target": "Kmeans.onnx", @@ -3720,49 +3777,6 @@ "format": "ONNX JSON v8", "link": "https://github.com/lutzroeder/netron/issues/6" }, - { - "type": "onnx", - "target": "issue_119.onnx", - "source": "https://github.com/lutzroeder/netron/files/10349170/issue_119.onnx.zip[issue_119.onnx]", - "format": "ONNX v4", - "link": "https://github.com/lutzroeder/netron/issues/119" - }, - { - "type": "onnx", - "target": "issue_168_if.pbtxt", - "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_if.pbtxt]", - "format": "ONNX v3", - "link": "https://github.com/lutzroeder/netron/issues/168" - }, - { - "type": "onnx", - "target": "issue_168_loop.pbtxt", - "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_loop.pbtxt]", - "format": "ONNX v3", - "link": "https://github.com/lutzroeder/netron/issues/168" - }, - { - "type": "onnx", - "target": "issue_168_scan.pbtxt", - "source": "https://github.com/lutzroeder/netron/files/10349183/issue_168.zip[issue_168_scan.pbtxt]", - "format": "ONNX v3", - "link": "https://github.com/lutzroeder/netron/issues/168" - }, - { - "type": "onnx", - "target": "issue_589.onnx.zip", - "source": "https://github.com/lutzroeder/netron/files/10349190/issue_589.onnx.zip", - "format": "ONNX v6", - "action": "skip-render", - "link": "https://github.com/lutzroeder/netron/issues/589" - }, - { - "type": "onnx", - "target": "issue_845.onnx", - "source": "https://github.com/lutzroeder/netron/files/10349194/issue_845.onnx.zip[issue_845.onnx]", - "format": "ONNX v4", - "link": "https://github.com/lutzroeder/netron/issues/6" - }, { "type": "onnx", "target": "optional_1.onnx",