Lutz Roeder 7 лет назад
Родитель
Сommit
9b3c114748
18 измененных файлов с 71 добавлено и 51 удалено
  1. 5 1
      src/caffe.js
  2. 1 1
      src/caffe2.js
  3. 4 4
      src/cntk.js
  4. 4 4
      src/coreml.js
  5. 5 1
      src/darknet.js
  6. 1 1
      src/keras.js
  7. 1 4
      src/mxnet.js
  8. 9 16
      src/onnx.js
  9. 2 2
      src/openvino.js
  10. 9 1
      src/paddle.js
  11. 3 3
      src/pytorch.js
  12. 3 3
      src/sklearn.js
  13. 3 3
      src/tf.js
  14. 2 2
      src/tflite.js
  15. 5 1
      src/torch.js
  16. 1 1
      src/view-sidebar.js
  17. 1 1
      src/view.js
  18. 12 2
      test/test.js

+ 5 - 1
src/caffe.js

@@ -484,7 +484,11 @@ caffe.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._type);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
+    }
+
+    get documentation() {
+        return '';
     }
 
     get name() { 

+ 1 - 1
src/caffe2.js

@@ -410,7 +410,7 @@ caffe2.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() {

+ 4 - 4
src/cntk.js

@@ -267,7 +267,7 @@ cntk.Function = class {
     }
 
     get description() {
-        return null;
+        return '';
     }
 
     get inputs() {
@@ -354,7 +354,7 @@ cntk.Connection = class {
     }
 
     get description() {
-        return null;
+        return '';
     }
 
     get initializer() {
@@ -501,11 +501,11 @@ cntk.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._function ? ('Function:' + this._operator) : this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() { 
-        return null;
+        return '';
     }
 
     get attributes() { 

+ 4 - 4
src/coreml.js

@@ -509,7 +509,7 @@ coreml.Node = class {
             this._group = group;
         }
         this._operator = operator;
-        this._name = name;
+        this._name = name || '';
         this._inputs = inputs;
         this._outputs = outputs;
         this._attributes = [];
@@ -534,7 +534,7 @@ coreml.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this.operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() {
@@ -568,7 +568,7 @@ coreml.Node = class {
             }
             return schema;
         }
-        return null;
+        return '';
     }
 
     get group() {
@@ -719,7 +719,7 @@ coreml.Node = class {
 
     _initializer(kind, name, shape, data) {
         var initializer = new coreml.Tensor(kind, name, shape, data);
-        var connection = new coreml.Connection(null, null, null, initializer);
+        var connection = new coreml.Connection('', null, null, initializer);
         var visible = true;
         var schema = this._metadata.getInputSchema(this._operator, name);
         if (schema && schema.hasOwnProperty('visible') && !schema.visible) {

+ 5 - 1
src/darknet.js

@@ -247,9 +247,13 @@ darknet.Node = class {
         return this._operator;
     }
 
+    get documentation() {
+        return '';
+    }
+
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get attributes() {

+ 1 - 1
src/keras.js

@@ -550,7 +550,7 @@ keras.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() {

+ 1 - 4
src/mxnet.js

@@ -539,10 +539,7 @@ mxnet.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator); 
-        if (schema && schema.category) {
-            return schema.category;
-        }
-        return null;
+        return schema && schema.category ? schema.category : '';
     }
 
     get documentation() {

+ 9 - 16
src/onnx.js

@@ -425,7 +425,7 @@ onnx.Connection = class {
     constructor(id, type, description, initializer) {
         this._id = id;
         this._type = type || null;
-        this._description = description || null;
+        this._description = description || '';
         this._initializer = initializer || null;
     }
 
@@ -460,12 +460,8 @@ onnx.Node = class {
         if (domain) {
             this._domain = domain;
         }
-        if (name) {
-            this._name = name;
-        }
-        if (description) {
-            this._description = description;
-        }
+        this._name = name || '';
+        this._description = description || '';
         this._attributes = [];
         if (attributes && attributes.length > 0) {
             attributes.forEach((attribute) => { 
@@ -481,11 +477,11 @@ onnx.Node = class {
     }
 
     get name() {
-        return this._name || null;
+        return this._name;
     }
 
     get description() {
-        return this._description || null;
+        return this._description;
     }
 
     get documentation() {
@@ -536,7 +532,7 @@ onnx.Node = class {
             }
             return schema;
         }
-        return null;
+        return '';
     }
 
     get domain() {
@@ -545,7 +541,7 @@ onnx.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get group() {
@@ -569,13 +565,10 @@ onnx.Attribute = class {
 
     constructor(metadata, imageFormat, operator, attribute) {
         this._name = attribute.name;
+        this._description = attribute.doc_string || '';
         this._type = null;
         this._value = null;
 
-        if (attribute.doc_string) {
-            this._description = this._attribute.doc_string;
-        }
-
         if (attribute.ints && attribute.ints.length > 0) {
             if (attribute.ints.length > 65536) {
                 this._value = () => '[...]';
@@ -681,7 +674,7 @@ onnx.Attribute = class {
     }
 
     get description() {
-        return this._description || null;
+        return this._description;
     }
 
     get visible() {

+ 2 - 2
src/openvino.js

@@ -412,7 +412,7 @@ openvino.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._type);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() {
@@ -453,7 +453,7 @@ openvino.Node = class {
             }
             return schema;
         }
-        return null;
+        return '';
     }
 
     get attributes() {

+ 9 - 1
src/paddle.js

@@ -249,9 +249,17 @@ paddle.Node = class {
         return this._operator;
     }
 
+    get name() {
+        return '';
+    }
+
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
+    }
+
+    get documentation() {
+        return '';
     }
 
     get attributes() {

+ 3 - 3
src/pytorch.js

@@ -713,7 +713,7 @@ pytorch.Node = class {
                 else if (parameter.value.storage) {
                     initializer = new pytorch.Tensor(parameter.value, littleEndian);
                 }
-                this._inputs.push(new pytorch.Argument(inputName || parameter.key, visible, [ new pytorch.Connection(null, null, initializer) ]));
+                this._inputs.push(new pytorch.Argument(inputName || parameter.key, visible, [ new pytorch.Connection('', null, initializer) ]));
             }
         });
 
@@ -742,7 +742,7 @@ pytorch.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get documentation() {
@@ -776,7 +776,7 @@ pytorch.Node = class {
             }
             return schema;
         }
-        return null;
+        return '';
     }
 
     get function() {

+ 3 - 3
src/sklearn.js

@@ -448,7 +448,7 @@ sklearn.Node = class {
         var operator = obj.__type__.split('.');
         this._type = operator.pop();
         this._package = operator.join('.');
-        this._name = name;
+        this._name = name || '';
         this._inputs = inputs;
         this._outputs = outputs;
         this._attributes = [];
@@ -529,7 +529,7 @@ sklearn.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this.operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get inputs() {
@@ -537,7 +537,7 @@ sklearn.Node = class {
             return new sklearn.Argument(input, [ new sklearn.Connection(input, null, null) ]);
         });
         this._initializers.forEach((initializer) => {
-            inputs.push(new sklearn.Argument(initializer.name, [ new sklearn.Connection(null, null, initializer) ]));
+            inputs.push(new sklearn.Argument(initializer.name, [ new sklearn.Connection('', null, initializer) ]));
         });
         return inputs;
     }

+ 3 - 3
src/tf.js

@@ -533,7 +533,7 @@ tf.Node = class {
     }
 
     get description() {
-        return null;
+        return '';
     }
 
     get domain() {
@@ -607,12 +607,12 @@ tf.Node = class {
             }
             return schema;
         }
-        return null;
+        return '';
     }
 
     get category() {
         var schema = this._graph.metadata.getSchema(this.operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get inputs() {

+ 2 - 2
src/tflite.js

@@ -281,7 +281,7 @@ tflite.Node = class {
     }
 
     get documentation() {
-        return null;
+        return '';
     }
 
     get group() {
@@ -290,7 +290,7 @@ tflite.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this.operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
     }
 
     get inputs() {

+ 5 - 1
src/torch.js

@@ -396,7 +396,11 @@ torch.Node = class {
 
     get category() {
         var schema = this._metadata.getSchema(this._operator);
-        return (schema && schema.category) ? schema.category : null;
+        return (schema && schema.category) ? schema.category : '';
+    }
+
+    get documentation() {
+        return '';
     }
 
     get attributes() {

+ 1 - 1
src/view-sidebar.js

@@ -429,7 +429,7 @@ sidebar.ConnectionView = class {
         else {
             var idLine = document.createElement('div');
             idLine.className = 'sidebar-view-item-value-line';
-            id = this._connection.id.split('\n').shift(); // custom connection id
+            id = id.split('\n').shift(); // custom connection id
             id = id || ' ';
             idLine.innerHTML = '<span class=\'sidebar-view-item-value-line-content\'>id: <b>' + id + '</b></span>';
             this._element.appendChild(idLine);

+ 1 - 1
src/view.js

@@ -675,7 +675,7 @@ view.View = class {
                         };
                     });
                     var types = input.connections.map(connection => connection.type || '').join('\n');
-                    var name = input.name;
+                    var name = input.name || '';
                     if (name.length > 16) {
                         name = name.split('/').pop();
                     }

+ 12 - 2
test/test.js

@@ -454,23 +454,29 @@ function loadModel(target, item, callback) {
         try {
             model.graphs.forEach((graph) => {
                 graph.inputs.forEach((input) => {
+                    input.name.toString();
                     input.connections.forEach((connection) => {
+                        connection.id.toString();
                         if (connection.type) {
                             connection.type.toString();
                         }
                     });
                 });
                 graph.outputs.forEach((output) => {
+                    output.name.toString();
                     output.connections.forEach((connection) => {
+                        connection.id.toString();
                         if (connection.type) {
                             connection.type.toString();
                         }
                     });
                 });
                 graph.nodes.forEach((node) => {
-                    node.documentation;
-                    node.category;
+                    node.name.toString();
+                    node.documentation.toString();
+                    node.category.toString();
                     node.attributes.forEach((attribute) => {
+                        attribute.name.toString();
                         var value = view.View.formatAttributeValue(attribute.value, attribute.type)
                         if (value && value.length > 1000) {
                             value = value.substring(0, 1000) + '...';
@@ -478,7 +484,9 @@ function loadModel(target, item, callback) {
                         value = value.split('<');
                     });
                     node.inputs.forEach((input) => {
+                        input.name.toString();
                         input.connections.forEach((connection) => {
+                            connection.id.toString();
                             if (connection.type) {
                                 connection.type.toString();
                             }
@@ -488,7 +496,9 @@ function loadModel(target, item, callback) {
                         });
                     });
                     node.outputs.forEach((output) => {
+                        output.name.toString();
                         output.connections.forEach((connection) => {
+                            connection.id.toString();
                             if (connection.type) {
                                 connection.type.toString();
                             }