Browse Source

Update onnx.js

Lutz Roeder 3 years ago
parent
commit
eb2bb2f378
1 changed files with 22 additions and 19 deletions
  1. 22 19
      source/onnx.js

+ 22 - 19
source/onnx.js

@@ -1886,26 +1886,29 @@ onnx.Runtime.Reader = class {
     }
 
     _type(type) {
-        const value = type.value;
-        if (value && value instanceof onnx.schema.TensorTypeAndShape) {
-            return {
-                tensor_type: { elem_type: value.elem_type, shape: this._shape(value.shape) },
-                denotation: value.denotation
-            };
-        }
-        if (value && value instanceof onnx.schema.SequenceType) {
-            return {
-                sequence_type: { elem_type: this._type(value.elem_type) },
-                denotation: value.denotation
-            };
-        }
-        if (value && value instanceof onnx.schema.MapType) {
-            return {
-                map_type: { key_type: value.key_type, value_type: this._type(value.value_type) },
-                denotation: value.denotation
-            };
+        if (type) {
+            const value = type.value;
+            if (value && value instanceof onnx.schema.TensorTypeAndShape) {
+                return {
+                    tensor_type: { elem_type: value.elem_type, shape: this._shape(value.shape) },
+                    denotation: value.denotation
+                };
+            }
+            if (value && value instanceof onnx.schema.SequenceType) {
+                return {
+                    sequence_type: { elem_type: this._type(value.elem_type) },
+                    denotation: value.denotation
+                };
+            }
+            if (value && value instanceof onnx.schema.MapType) {
+                return {
+                    map_type: { key_type: value.key_type, value_type: this._type(value.value_type) },
+                    denotation: value.denotation
+                };
+            }
+            throw new onnx.Error("Unsupported type value '" + JSON.stringify(type.value));
         }
-        throw new onnx.Error("Unsupported type value '" + JSON.stringify(type.value));
+        return null;
     }
 
     _shape(shape) {