Kaynağa Gözat

Add ONNX test file (#188)

Lutz Roeder 4 yıl önce
ebeveyn
işleme
7bed649be5
2 değiştirilmiş dosya ile 16 ekleme ve 6 silme
  1. 9 6
      source/onnx.js
  2. 7 0
      test/models.json

+ 9 - 6
source/onnx.js

@@ -552,6 +552,7 @@ onnx.Argument = class {
 onnx.Node = class {
 
     constructor(context, op_type, domain, name, description, attributes, inputs, outputs) {
+        attributes = attributes || [];
         this._type = context.metadata.type(op_type, domain) || { name: op_type, module: domain };
         if (this.type.module !== domain && !(this._type instanceof onnx.Function)) {
             this._type = Object.assign({}, this.type);
@@ -560,18 +561,20 @@ onnx.Node = class {
         }
         this._name = name || '';
         this._description = description || '';
-        this._chain = [];
         this._inputs = inputs;
         this._outputs = outputs;
-        this._attributes = (attributes || []).map((attribute) => new onnx.Attribute(context, op_type, domain, attribute));
-        attributes = Object.fromEntries(attributes.map((entry) => [ entry.name, entry ]));
+        this._attributes = attributes.map((attribute) => new onnx.Attribute(context, op_type, domain, attribute));
+        this._chain = [];
         const identifier = domain ? domain + '.' + op_type : op_type;
         switch (identifier) {
-            case 'com.microsoft.FusedConv':
-                if (attributes.activation) {
-                    this._chain.push(new onnx.Node(context, attributes.activation.s, '', '', '', [], [], []));
+            case 'com.microsoft.FusedConv': {
+                const activation = attributes.find((attribute) => attribute.name === 'activation');
+                if (activation) {
+                    const type = context.decodeText(activation.s);
+                    this._chain.push(new onnx.Node(context, type, '', '', '', [], [], []));
                 }
                 break;
+            }
         }
     }
 

+ 7 - 0
test/models.json

@@ -3346,6 +3346,13 @@
     "action": "skip-render",
     "link":   "https://github.com/lutzroeder/netron/issues/589"
   },
+  {
+    "type":   "onnx",
+    "target": "maskDet_opt.onnx",
+    "source": "https://github.com/lutzroeder/netron/files/8238283/maskDet_opt.onnx.zip[maskDet_opt.onnx]",
+    "format": "ONNX v4",
+    "link":   "https://github.com/lutzroeder/netron/issues/188"
+  },
   {
     "type":   "onnx",
     "target": "maskrcnn.onnx.zip",