Lutz Roeder 4 лет назад
Родитель
Сommit
2fc3aeea8a

+ 0 - 4
source/armnn.js

@@ -214,10 +214,6 @@ armnn.Node = class {
         return this._name;
     }
 
-    get domain() {
-        return null;
-    }
-
     get group() {
         return null;
     }

+ 4 - 4
source/barracuda.js

@@ -142,7 +142,7 @@ barracuda.Node = class {
         this._outputs = [];
         this._attributes = [];
         const inputs = Array.prototype.slice.call(this._type.inputs || [ 'input' ]);
-        if (this._type.inputs && this._type.inputs.length === 1 && this._type.inputs[0] === 'inputs') {
+        if (this._type.inputs && this._type.inputs.length === 1 && this._type.inputs[0].name === 'inputs') {
             this._inputs.push(new barracuda.Parameter('inputs', layer.inputs.map((input) => {
                 const initializer = initializers.has(input) ? initializers.get(input) : null;
                 return new barracuda.Argument(input, initializer ? initializer.type : null, initializer);
@@ -152,7 +152,7 @@ barracuda.Node = class {
             for (let i = 0; i < layer.inputs.length; i++) {
                 const input = layer.inputs[i];
                 const initializer = initializers.has(input) ? initializers.get(input) : null;
-                this._inputs.push(new barracuda.Parameter(inputs.length > 0 ? inputs.shift() : i.toString(), [
+                this._inputs.push(new barracuda.Parameter(inputs.length > 0 ? inputs.shift().name : i.toString(), [
                     new barracuda.Argument(input, initializer ? initializer.type : null, initializer)
                 ]));
             }
@@ -161,7 +161,7 @@ barracuda.Node = class {
             for (let i = 0; i < layer.tensors.length; i++) {
                 const tensor = layer.tensors[i];
                 const initializer = new barracuda.Tensor(tensor);
-                this._inputs.push(new barracuda.Parameter(inputs.length > 0 ? inputs.shift() : i.toString(), [
+                this._inputs.push(new barracuda.Parameter(inputs.length > 0 ? inputs.shift().name : i.toString(), [
                     new barracuda.Argument(tensor.name, initializer.type, initializer)
                 ]));
             }
@@ -661,7 +661,7 @@ barracuda.Metadata = class {
     }
 
     _register(id, name, category, inputs) {
-        this._map.set(id, { name: name, category: category, inputs: inputs });
+        this._map.set(id, { name: name, category: category, inputs: (inputs || []).map((input) => { return { name: input }; }) });
     }
 
     type(name) {

+ 0 - 4
source/mnn.js

@@ -265,10 +265,6 @@ mnn.Node = class {
         return this._name;
     }
 
-    get domain() {
-        return null;
-    }
-
     get group() {
         return null;
     }

Разница между файлами не показана из-за своего большого размера
+ 6 - 6
source/onnx-metadata.json


+ 100 - 33
source/onnx.js

@@ -191,7 +191,7 @@ onnx.ModelFactory = class {
                     return '';
                 }
             }
-            if (Array.from(tags.keys()).every((tag) => tag <= 20) &&
+            if (Array.from(tags.keys()).every((tag) => tag <= 100) &&
                 Array.from(tags.values()).every((type) => type < 5)) {
                 // TensorProto
                 if (tags.get(1) === 0 && tags.get(2) === 0 && tags.get(9) === 2) {
@@ -245,7 +245,7 @@ onnx.ModelFactory = class {
             const buffer = stream.peek(Math.min(stream.length, 32));
             if (buffer[0] === 0x08 && buffer[1] < 0x0A && buffer[2] === 0x12) {
                 const producers = [
-                    'BrainwaveCompiler',
+                    'backend-test', 'BrainwaveCompiler',
                     'CNTK',
                     'keras2onnx', 'Kneron', 'kneron_formatter', 'kneron_kl530_test_case',
                     'darknet to ONNX example',
@@ -343,6 +343,9 @@ onnx.Model = class {
             const context = {};
             context.metadata = new onnx.GraphMetadata(metadata, imports);
             context.imageFormat = imageFormat;
+            for (const func of model.functions || []) {
+                context.metadata.add(new onnx.Function(context, func));
+            }
             context.graphs = new Map();
             context.graph = function(graph) {
                 graph.key = graph.key || (key++).toString();
@@ -574,7 +577,7 @@ onnx.Graph = class {
                 }
             }
             for (const node of nodes) {
-                const schema = context.metadata.type(node.op_type);
+                const schema = context.metadata.type(node.op_type, node.domain);
                 const inputs = [];
                 node.input = node.input || [];
                 for (let i = 0; i < node.input.length; ) {
@@ -686,14 +689,18 @@ onnx.Argument = class {
 
 onnx.Node = class {
 
-    constructor(context, type, domain, name, description, attributes, inputs, outputs) {
-        this._type = context.metadata.type(type) || { name: type };
-        this._domain = domain || '';
+    constructor(context, op_type, domain, name, description, attributes, inputs, outputs) {
+        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);
+            this._type.name = op_type;
+            this._type.module = domain;
+        }
         this._name = name || '';
         this._description = description || '';
         this._inputs = inputs;
         this._outputs = outputs;
-        this._attributes = (attributes || []).map((attribute) => new onnx.Attribute(context, type, attribute));
+        this._attributes = (attributes || []).map((attribute) => new onnx.Attribute(context, op_type, domain, attribute));
     }
 
     get type() {
@@ -708,10 +715,6 @@ onnx.Node = class {
         return this._description;
     }
 
-    get domain() {
-        return this._domain;
-    }
-
     get group() {
         return null;
     }
@@ -731,7 +734,7 @@ onnx.Node = class {
 
 onnx.Attribute = class {
 
-    constructor(context, operator, attribute) {
+    constructor(context, op_type, domain, attribute) {
         this._name = attribute.name;
         this._description = attribute.doc_string || '';
         this._type = null;
@@ -746,7 +749,7 @@ onnx.Attribute = class {
                 this._type = 'int64';
                 break;
             case onnx.AttributeType.STRING:
-                switch (operator) {
+                switch (op_type) {
                     case 'Int8GivenTensorFill':
                         this._value = Array.from(attribute.s);
                         break;
@@ -796,7 +799,7 @@ onnx.Attribute = class {
                 throw new onnx.Error("Unknown attribute type '" + attribute.type + "'.");
         }
 
-        const metadata = context.metadata.attribute(operator, attribute.name);
+        const metadata = context.metadata.attribute(op_type, domain, attribute.name);
         if (metadata && Object.prototype.hasOwnProperty.call(metadata, 'default') && this._value == metadata.default) {
             this._visible = false;
         }
@@ -1248,6 +1251,42 @@ onnx.OpaqueType = class {
     }
 };
 
+onnx.Function = class {
+
+    constructor(context, func) {
+        this._name = func.name;
+        this._domain = func.domain;
+        this._description = func.doc_string;
+        this._inputs = func.input.map((input) => { return { name: input }; });
+        this._outputs = func.output.map((output) => { return { name: output }; });
+        this._attributes = func.attribute.map((attribtue) => { return { name: attribtue }; });
+    }
+
+    get name() {
+        return this._name;
+    }
+
+    get module() {
+        return this._domain;
+    }
+
+    get description() {
+        return this._description;
+    }
+
+    get inputs() {
+        return this._inputs;
+    }
+
+    get outputs() {
+        return this._outputs;
+    }
+
+    get attributes() {
+        return this._attributes;
+    }
+};
+
 onnx.GraphMetadata = class {
 
     constructor(metadata, imports) {
@@ -1255,19 +1294,42 @@ onnx.GraphMetadata = class {
         this._imports = imports;
         this._cache = new Map();
         this._attributeCache = new Map();
+        this._functions = new Map();
+    }
+
+    add(func) {
+        if (!this._functions.has(func.module)) {
+            this._functions.set(func.module, new Map());
+        }
+        const map = this._functions.get(func.module);
+        if (map.has(func.name)) {
+            throw new onnx.Error("Duplicate function identifier '" + func.module + '.' + func.name + "'.");
+        }
+        map.set(func.name, func);
     }
 
-    type(name) {
-        if (!this._cache.has(name)) {
-            this._cache.set(name, this._metadata.type(name, this._imports));
+    type(name, domain) {
+        domain = domain || 'ai.onnx';
+        const key = domain + ':' + name;
+        if (!this._cache.has(key)) {
+            let value = this._metadata.type(name, domain, this._imports);
+            if (!value) {
+                if (this._functions.has(domain)) {
+                    const map = this._functions.get(domain);
+                    if (map.has(name)) {
+                        value = map.get(name);
+                    }
+                }
+            }
+            this._cache.set(key, value);
         }
-        return this._cache.get(name);
+        return this._cache.get(key);
     }
 
-    attribute(type, name) {
-        const key = type + ':' + name;
+    attribute(type, domain, name) {
+        const key = domain + ':' + type + ':' + name;
         if (!this._attributeCache.has(key)) {
-            const schema = this.type(type);
+            const schema = this.type(type, domain);
             if (schema && schema.attributes && schema.attributes.length > 0) {
                 for (const attribute of schema.attributes) {
                     this._attributeCache.set(type + ':' + attribute.name, attribute);
@@ -1301,25 +1363,30 @@ onnx.Metadata = class {
         if (data) {
             const metadata = JSON.parse(data);
             for (const item of metadata) {
-                const name = item.name;
-                if (this._map.has(name)) {
-                    this._map.get(name).push(item);
+                if (!this._map.has(item.module)) {
+                    this._map.set(item.module, new Map());
                 }
-                else {
-                    this._map.set(name, [ item ]);
+                const map = this._map.get(item.module);
+                if (!map.has(item.name)) {
+                    map.set(item.name, []);
                 }
+                map.get(item.name).push(item);
             }
         }
     }
 
-    type(name, imports) {
+    type(name, domain, imports) {
+        domain = domain || 'ai.onnx';
         let current = null;
-        if (this._map.has(name)) {
-            for (const metadata of this._map.get(name)) {
-                const matchVersion = current ? current.version : -1;
-                const importVersion = imports.get(metadata.domain) || 0;
-                if (importVersion >= metadata.version && matchVersion < metadata.version) {
-                    current = metadata;
+        if (this._map.has(domain)) {
+            const map = this._map.get(domain);
+            if (map.has(name)) {
+                for (const metadata of map.get(name)) {
+                    const matchVersion = current ? current.version : -1;
+                    const importVersion = imports.get(metadata.module) || 0;
+                    if (importVersion >= metadata.version && matchVersion < metadata.version) {
+                        current = metadata;
+                    }
                 }
             }
         }

+ 0 - 2
source/openvino-metadata.json

@@ -475,7 +475,6 @@
       },
       {
         "default": 1,
-        "description": null,
         "name": "num_orient_classes",
         "required": true,
         "type": "int32"
@@ -496,7 +495,6 @@
       },
       {
         "default": 1,
-        "description": null,
         "name": "interpolate_orientation",
         "required": true,
         "type": "int32"

+ 12 - 12
source/pytorch-metadata.json

@@ -3117,7 +3117,7 @@
       { "name": "size", "type": "int64[]" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3171,7 +3171,7 @@
     "attributes": [
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null },
       { "name": "memory_format", "type": "MemoryFormat", "optional": true, "default": null }
     ],
@@ -3187,7 +3187,7 @@
     "attributes": [
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null },
       { "name": "memory_format", "type": "MemoryFormat", "optional": true, "default": null }
     ],
@@ -3204,7 +3204,7 @@
       { "name": "end", "type": "Scalar" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3218,7 +3218,7 @@
       { "name": "end", "type": "Scalar" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3233,7 +3233,7 @@
       { "name": "step", "type": "Scalar" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3952,7 +3952,7 @@
       { "name": "size", "type": "int64[]" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3965,7 +3965,7 @@
       { "name": "high", "type": "int64", "optional": true, "default": null },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null },
       { "name": "memory_format", "type": "MemoryFormat", "optional": true, "default": null }
     ],
@@ -3980,7 +3980,7 @@
       { "name": "generator", "type": "Generator", "optional": true, "default": null },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -3995,7 +3995,7 @@
       { "name": "generator", "type": "Generator" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -4009,7 +4009,7 @@
       { "name": "high", "type": "int64", "optional": true, "default": null },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [
@@ -4022,7 +4022,7 @@
       { "name": "size", "type": "int64[]" },
       { "name": "dtype", "type": "ScalarType", "optional": true, "default": null },
       { "name": "layout", "type": "Layout", "optional": true, "default": null },
-      { "name": "device", "type": "Device", "optiona": true, "default": null },
+      { "name": "device", "type": "Device", "optional": true, "default": null },
       { "name": "pin_memory", "type": "boolean", "optional": true, "default": null }
     ],
     "outputs": [

+ 0 - 4
source/tf.js

@@ -1341,10 +1341,6 @@ tf.Node = class {
         return '';
     }
 
-    get domain() {
-        return null;
-    }
-
     get inputs() {
         return this._inputs;
     }

+ 0 - 4
source/tflite.js

@@ -392,10 +392,6 @@ tflite.Node = class {
         return this._location;
     }
 
-    get domain() {
-        return null;
-    }
-
     get group() {
         return null;
     }

+ 175 - 33
source/view-sidebar.js

@@ -136,7 +136,8 @@ sidebar.NodeSidebar = class {
 
         if (node.type) {
             let showDocumentation = null;
-            if (node.type && Object.keys(node.type).length > 1) {
+            const type = node.type;
+            if (type && (type.description || type.inputs || type.outputs || type.attributes)) {
                 showDocumentation = {};
                 showDocumentation.text = '?';
                 showDocumentation.callback = () => {
@@ -144,6 +145,9 @@ sidebar.NodeSidebar = class {
                 };
             }
             this._addProperty('type', new sidebar.ValueTextView(this._host, node.type.name, showDocumentation));
+            if (node.type.module) {
+                this._addProperty('module', new sidebar.ValueTextView(this._host, node.type.module));
+            }
         }
 
         if (node.name) {
@@ -154,10 +158,6 @@ sidebar.NodeSidebar = class {
             this._addProperty('location', new sidebar.ValueTextView(this._host, node.location));
         }
 
-        if (node.domain) {
-            this._addProperty('domain', new sidebar.ValueTextView(this._host, node.domain));
-        }
-
         if (node.description) {
             this._addProperty('description', new sidebar.ValueTextView(this._host, node.description));
         }
@@ -1028,45 +1028,187 @@ sidebar.DocumentationSidebar = class {
         return element;
     }
 
-    static formatDocumentation(data) {
-        if (data) {
-            data = JSON.parse(JSON.stringify(data));
+    static formatDocumentation(source) {
+        if (source) {
             const generator = new markdown.Generator();
-            if (data.summary) {
-                data.summary = generator.html(data.summary);
+            const target = {};
+            if (source.name !== undefined) {
+                target.name = source.name;
+            }
+            if (source.module !== undefined) {
+                target.module = source.module;
             }
-            if (data.description) {
-                data.description = generator.html(data.description);
+            if (source.category !== undefined) {
+                target.category = source.category;
             }
-            if (data.attributes) {
-                for (const attribute of data.attributes) {
-                    if (attribute.description) {
-                        attribute.description = generator.html(attribute.description);
+            if (source.summary !== undefined) {
+                target.summary = generator.html(source.summary);
+            }
+            if (source.description !== undefined) {
+                target.description = generator.html(source.description);
+            }
+            if (Array.isArray(source.attributes)) {
+                target.attributes = source.attributes.map((source) => {
+                    const target = {};
+                    target.name = source.name;
+                    if (source.type !== undefined) {
+                        target.type = source.type;
                     }
-                }
+                    if (source.option !== undefined) {
+                        target.option = source.option;
+                    }
+                    if (source.optional !== undefined) {
+                        target.optional = source.optional;
+                    }
+                    if (source.required !== undefined) {
+                        target.required = source.required;
+                    }
+                    if (source.minimum !== undefined) {
+                        target.minimum = source.minimum;
+                    }
+                    if (source.src !== undefined) {
+                        target.src = source.src;
+                    }
+                    if (source.src_type !== undefined) {
+                        target.src_type = source.src_type;
+                    }
+                    if (source.description !== undefined) {
+                        target.description = generator.html(source.description);
+                    }
+                    if (source.default !== undefined) {
+                        target.default = source.default;
+                    }
+                    if (source.visible !== undefined) {
+                        target.visible = source.visible;
+                    }
+                    return target;
+                });
             }
-            if (data.inputs) {
-                for (const input of data.inputs) {
-                    if (input.description) {
-                        input.description = generator.html(input.description);
+            if (Array.isArray(source.inputs)) {
+                target.inputs = source.inputs.map((source) => {
+                    const target = {};
+                    target.name = source.name;
+                    if (source.type !== undefined) {
+                        target.type = source.type;
                     }
-                }
+                    if (source.description !== undefined) {
+                        target.description = generator.html(source.description);
+                    }
+                    if (source.default !== undefined) {
+                        target.default = source.default;
+                    }
+                    if (source.src !== undefined) {
+                        target.src = source.src;
+                    }
+                    if (source.list !== undefined) {
+                        target.list = source.list;
+                    }
+                    if (source.isRef !== undefined) {
+                        target.isRef = source.isRef;
+                    }
+                    if (source.typeAttr !== undefined) {
+                        target.typeAttr = source.typeAttr;
+                    }
+                    if (source.numberAttr !== undefined) {
+                        target.numberAttr = source.numberAttr;
+                    }
+                    if (source.typeListAttr !== undefined) {
+                        target.typeListAttr = source.typeListAttr;
+                    }
+                    if (source.option !== undefined) {
+                        target.option = source.option;
+                    }
+                    if (source.optional !== undefined) {
+                        target.optional = source.optional;
+                    }
+                    if (source.visible !== undefined) {
+                        target.visible = source.visible;
+                    }
+                    return target;
+                });
             }
-            if (data.outputs) {
-                for (const output of data.outputs) {
-                    if (output.description) {
-                        output.description = generator.html(output.description);
+            if (Array.isArray(source.outputs)) {
+                target.outputs = source.outputs.map((source) => {
+                    const target = {};
+                    target.name = source.name;
+                    if (source.type) {
+                        target.type = source.type;
                     }
-                }
+                    if (source.description !== undefined) {
+                        target.description = generator.html(source.description);
+                    }
+                    if (source.list !== undefined) {
+                        target.list = source.list;
+                    }
+                    if (source.typeAttr !== undefined) {
+                        target.typeAttr = source.typeAttr;
+                    }
+                    if (source.typeListAttr !== undefined) {
+                        target.typeListAttr = source.typeAttr;
+                    }
+                    if (source.numberAttr !== undefined) {
+                        target.numberAttr = source.numberAttr;
+                    }
+                    if (source.isRef !== undefined) {
+                        target.isRef = source.isRef;
+                    }
+                    if (source.option !== undefined) {
+                        target.option = source.option;
+                    }
+                    return target;
+                });
             }
-            if (data.references) {
-                for (const reference of data.references) {
-                    if (reference) {
-                        reference.description = generator.html(reference.description);
+            if (Array.isArray(source.references)) {
+                target.references = source.references.map((source) => {
+                    if (source) {
+                        target.description = generator.html(source.description);
                     }
-                }
+                    return target;
+                });
+            }
+            if (source.version !== undefined) {
+                target.version = source.version;
+            }
+            if (source.operator !== undefined) {
+                target.operator = source.operator;
+            }
+            if (source.identifier !== undefined) {
+                target.identifier = source.identifier;
+            }
+            if (source.package !== undefined) {
+                target.package = source.package;
+            }
+            if (source.support_level !== undefined) {
+                target.support_level = source.support_level;
+            }
+            if (source.min_input !== undefined) {
+                target.min_input = source.min_input;
+            }
+            if (source.max_input !== undefined) {
+                target.max_input = source.max_input;
+            }
+            if (source.min_output !== undefined) {
+                target.min_output = source.min_output;
+            }
+            if (source.max_input !== undefined) {
+                target.max_output = source.max_output;
+            }
+            if (source.inputs_range !== undefined) {
+                target.inputs_range = source.inputs_range;
+            }
+            if (source.outputs_range !== undefined) {
+                target.outputs_range = source.outputs_range;
+            }
+            if (source.examples !== undefined) {
+                target.examples = source.examples;
+            }
+            if (source.constants !== undefined) {
+                target.constants = source.constants;
+            }
+            if (source.type_constraints !== undefined) {
+                target.type_constraints = source.type_constraints;
             }
-            return data;
+            return target;
         }
         return '';
     }

+ 1 - 1
source/view.js

@@ -908,7 +908,7 @@ view.View = class {
 
     showNodeDocumentation(node) {
         const type = node.type;
-        if (type && Object.keys(type).length > 1) {
+        if (type && (type.description || type.inputs || type.outputs || type.attributes)) {
             const documentationSidebar = new sidebar.DocumentationSidebar(this._host, type);
             documentationSidebar.on('navigate', (sender, e) => {
                 this._host.openURL(e.link);

+ 3 - 3
source/xmodel.js

@@ -438,7 +438,7 @@ xmodel.Metadata = class {
                 if (input_arg.annotation) {
                     input.description = input_arg.annotation;
                 }
-                return input_arg;
+                return input;
             });
             schema.attributes = op_def.attrs.map((attr) => {
                 const attribute = {};
@@ -446,10 +446,10 @@ xmodel.Metadata = class {
                 const value = xmodel.Utility.attribute(attr.default_value);
                 attribute.default = value.value;
                 if (attr.annotation) {
-                    attr.description = attr.annotation;
+                    attribute.description = attr.annotation;
                 }
                 this._attributeCache.set(name + ':' + attr.name, attribute);
-                return attr;
+                return attribute;
             });
             if (categories.has(name)) {
                 schema.category = categories.get(name);

+ 1 - 4
test/models.js

@@ -674,13 +674,10 @@ function loadModel(target, item) {
                 if (!node.type || typeof node.type.name != 'string') {
                     throw new Error("Invalid node type '" + JSON.stringify(node.type) + "'.");
                 }
+                sidebar.DocumentationSidebar.formatDocumentation(node.type);
                 node.name.toString();
                 node.name.length;
                 node.description;
-                if (node.metadata) {
-                    throw new Error("Invalid metadata object '" + node.type.name + "'.");
-                }
-                sidebar.DocumentationSidebar.formatDocumentation(node.metadata);
                 node.attributes.slice();
                 for (const attribute of node.attributes) {
                     attribute.name.toString();

+ 2 - 2
test/models.json

@@ -3241,8 +3241,8 @@
   {
     "type":   "onnx",
     "target": "model_local_func_test.onnx",
-    "source": "https://github.com/lutzroeder/netron/files/6836872/model_local_func_test.onnx.zip[model_local_func_test.onnx]",
-    "format": "ONNX v7",
+    "source": "https://github.com/lutzroeder/netron/files/6845111/model_local_func_test.onnx.zip[model_local_func_test.onnx]",
+    "format": "ONNX v8",
     "link":   "https://github.com/lutzroeder/netron/issues/773"
   },
   {

+ 2 - 2
tools/onnx-script.py

@@ -138,9 +138,9 @@ def generate_json(schemas, json_file):
         json_schema = {}
         json_schema['name'] = schema.name
         if schema.domain:
-            json_schema['domain'] = schema.domain
+            json_schema['module'] = schema.domain
         else:
-            json_schema['domain'] = 'ai.onnx'
+            json_schema['module'] = 'ai.onnx'
         json_schema['version'] = schema.since_version
         json_schema['support_level'] = generate_json_support_level_name(schema.support_level)
         if schema.doc:

Некоторые файлы не были показаны из-за большого количества измененных файлов