diff --git a/src/caffe-model.js b/src/caffe-model.js
index a53a2462b7..b9b8537a64 100644
--- a/src/caffe-model.js
+++ b/src/caffe-model.js
@@ -118,7 +118,7 @@ class CaffeGraph {
this._inputs.push({
id: input,
name: input,
- type: 'T'
+ type: null
});
});
}
@@ -155,7 +155,7 @@ class CaffeGraph {
this._outputs.push({
id: keys[0],
name: keys[0],
- type: 'T'
+ type: null
});
}
else if (outputs.length == 1) {
@@ -163,7 +163,7 @@ class CaffeGraph {
this._outputs.push({
id: 'output',
name: 'output',
- type: 'T'
+ type: null
});
}
}
@@ -294,7 +294,7 @@ class CaffeNode {
input.connections.forEach((connection) => {
if (connection.id instanceof CaffeTensor) {
connection.initializer = connection.id;
- connection.type = connection.initializer.type.toString();
+ connection.type = connection.initializer.type;
connection.id = '';
}
});
diff --git a/src/caffe2-model.js b/src/caffe2-model.js
index af8acf4d62..6b852e4fb2 100644
--- a/src/caffe2-model.js
+++ b/src/caffe2-model.js
@@ -117,7 +117,7 @@ class Caffe2Graph {
this._inputs.push({
id: input,
name: input,
- type: 'T'
+ type: null
});
}
});
@@ -127,7 +127,7 @@ class Caffe2Graph {
this._outputs.push({
id: output,
name: output,
- type: 'T'
+ type: null
});
});
}
@@ -214,7 +214,7 @@ class Caffe2Node {
var initializer = this._initializers[connection.id];
if (initializer) {
connection.initializer = initializer;
- connection.type = initializer.type.toString();
+ connection.type = initializer.type;
}
});
});
diff --git a/src/coreml-model.js b/src/coreml-model.js
index 8b5ec89359..64deb8714e 100644
--- a/src/coreml-model.js
+++ b/src/coreml-model.js
@@ -378,13 +378,13 @@ class CoreMLGraph {
result = 'image(' + CoreMLGraph.formatColorSpace(type.imageType.colorSpace) + ',' + type.imageType.width.toString() + 'x' + type.imageType.height.toString() + ')';
break;
case 'dictionaryType':
- result = 'map<' + type.dictionaryType.KeyType.replace('KeyType', '') + ',double>';
+ result = 'map<' + type.dictionaryType.KeyType.replace('KeyType', '') + ',float64>';
break;
case 'stringType':
result = 'string';
break;
case 'doubleType':
- result = 'double';
+ result = 'float64';
break;
case 'int64Type':
result = 'int64';
@@ -477,7 +477,7 @@ class CoreMLNode {
name: initializer.name,
connections: [ {
id: '',
- type: initializer.type.toString(),
+ type: initializer.type,
initializer: initializer, } ]
};
if (!CoreMLOperatorMetadata.operatorMetadata.getInputVisible(this._operator, initializer.name)) {
diff --git a/src/keras-model.js b/src/keras-model.js
index 304cda2542..9081d0144f 100644
--- a/src/keras-model.js
+++ b/src/keras-model.js
@@ -281,7 +281,7 @@ class KerasGraph {
if (addGraphOutput) {
this._outputs.push({
id: inputName,
- type: 'T',
+ type: null,
name: inputName
});
}
@@ -340,7 +340,7 @@ class KerasGraph {
if (connection) {
this._outputs.push({
id: connection,
- type: 'T',
+ type: null,
name: connection
});
}
@@ -363,19 +363,20 @@ class KerasGraph {
}
_loadInput(layer, input) {
- input.type = '';
+ input.type = null;
if (layer && layer.config) {
+ var dataType = '?';
+ var shape = [];
var config = layer.config;
if (config.dtype) {
- input.type = config.dtype;
+ dataType = config.dtype;
delete config.dtype;
}
if (config.batch_input_shape) {
- var shape = config.batch_input_shape;
- shape = shape.map(s => s == null ? '?' : s).join(',');
- input.type = input.type + '[' + shape + ']';
+ shape = config.batch_input_shape.map(s => s == null ? '?' : s);
delete config.batch_input_shape;
}
+ input.type = new KerasTensorType(dataType, shape);
}
}
}
@@ -471,7 +472,7 @@ class KerasNode {
input.connections.forEach((connection) => {
var initializer = this._initializers[connection.id];
if (initializer) {
- connection.type = initializer.type.toString();
+ connection.type = initializer.type;
connection.initializer = initializer;
}
});
diff --git a/src/mxnet-model.js b/src/mxnet-model.js
index 064645a52e..e44f422887 100644
--- a/src/mxnet-model.js
+++ b/src/mxnet-model.js
@@ -293,10 +293,10 @@ class MXNetGraph {
var output = {};
output.id = MXNetGraph._updateOutput(nodes, head);
output.name = nodes[output.id[0]] ? nodes[output.id[0]].name : ('output' + ((index == 0) ? '' : (index + 1).toString()));
- output.type = 'T';
+ output.type = null;
var outputSignature = outputs[output.name];
if (outputSignature && outputSignature.data_shape) {
- output.type = '?' + '[' + outputSignature.data_shape.toString() + ']';
+ output.type = new MXNetTensorType(null, outputSignature.data_shape);
}
this._outputs.push(output);
});
@@ -315,10 +315,10 @@ class MXNetGraph {
var input = {};
input.id = argument.outputs[0];
input.name = argument.name;
- input.type = 'T';
+ input.type = null;
var inputSignature = inputs[input.name];
if (inputSignature && inputSignature.data_shape) {
- input.type = '?' + '[' + inputSignature.data_shape.toString() + ']';
+ input.type = new MXNetTensorType(null, inputSignature.data_shape);
}
this._inputs.push(input);
}
@@ -464,7 +464,7 @@ class MXNetNode {
var initializer = this._initializers[connection.id];
if (initializer) {
connection.id = initializer.name || connection.id;
- connection.type = initializer.type.toString();
+ connection.type = initializer.type;
connection.initializer = initializer;
}
});
@@ -674,7 +674,7 @@ class MXNetTensorType {
}
toString() {
- return this.dataType + (this._shape ? ('[' + this._shape.map((dimension) => dimension.toString()).join(',') + ']') : '');
+ return (this.dataType || '?') + (this._shape ? ('[' + this._shape.map((dimension) => dimension.toString()).join(',') + ']') : '');
}
}
diff --git a/src/onnx-model.js b/src/onnx-model.js
index 20a1ceb7d7..599feaf1bb 100644
--- a/src/onnx-model.js
+++ b/src/onnx-model.js
@@ -252,7 +252,7 @@ class OnnxGraph {
var initializer = this._initializerMap[connection.id];
if (initializer) {
connection.initializer = initializer;
- connection.type = connection.type || initializer.type.toString();
+ connection.type = connection.type || initializer.type;
}
return connection;
});
@@ -499,6 +499,7 @@ class OnnxTensor {
this._tensor = tensor;
this._id = id;
this._kind = kind || null;
+ this._type = new OnnxTensorType(this._tensor.dataType, this._tensor.dims.map((dim) => dim), null);
}
get id() {
@@ -514,7 +515,7 @@ class OnnxTensor {
}
get type() {
- return new OnnxTensorType(this._tensor);
+ return this._type;
}
get value() {
@@ -744,37 +745,8 @@ class OnnxTensor {
static _formatType(type, imageFormat) {
if (!type) {
- return { value: '?' };
+ return null;
}
- var value = {};
- switch (type.value) {
- case 'tensorType':
- var tensorType = type.tensorType;
- var text = OnnxTensor._formatElementType(tensorType.elemType);
- if (tensorType.shape && tensorType.shape.dim) {
- text += '[' + tensorType.shape.dim.map((dimension) => {
- if (dimension.dimParam) {
- return dimension.dimParam;
- }
- return dimension.dimValue.toString();
- }).join(',') + ']';
- }
- value = text;
- break;
- case 'mapType':
- var keyType = OnnxTensor._formatElementType(type.mapType.keyType);
- var valueType = OnnxTensor._formatType(type.mapType.valueType);
- value = 'map<' + keyType + ',' + valueType.value + '>';
- break;
- case 'sequenceType':
- var elemType = OnnxTensor._formatType(type.sequenceType.elemType);
- value = 'sequence<' + elemType.value + '>';
- break;
- default:
- // debugger
- value = '?';
- break;
- }
var denotation = '';
switch (type.denotation) {
case 'TENSOR':
@@ -790,21 +762,30 @@ class OnnxTensor {
denotation = 'Text';
break;
}
- return { value: value, denotation: denotation };
+ switch (type.value) {
+ case 'tensorType':
+ var shape = [];
+ if (type.tensorType.shape && type.tensorType.shape.dim) {
+ shape = type.tensorType.shape.dim.map((dim) => {
+ return dim.dimParam ? dim.dimParam : dim.dimValue;
+ });
+ }
+ return new OnnxTensorType(type.tensorType.elemType, shape, denotation);
+ case 'mapType':
+ return new OnnxMapType(type.mapType.keyType, OnnxTensor._formatType(type.mapType.valueType, imageFormat), denotation);
+ case 'sequenceType':
+ return new OnnxSequenceType(OnnxTensor._formatType(type.sequenceType.elemType, imageFormat), denotation);
+ }
+ return null;
}
}
class OnnxTensorType {
- constructor(tensor) {
- this._dataType = '?';
- if (tensor.hasOwnProperty('dataType')) {
- this._dataType = OnnxTensor._formatElementType(tensor.dataType);
- }
- this._shape = [];
- if (tensor.hasOwnProperty('dims')) {
- this._shape = tensor.dims.map((dimension) => dimension);
- }
+ constructor(dataType, shape, denotation) {
+ this._dataType = OnnxTensor._formatElementType(dataType);
+ this._shape = shape;
+ this._denotation = denotation || null;
}
get dataType() {
@@ -815,10 +796,58 @@ class OnnxTensorType {
return this._shape;
}
+ get denotation() {
+ return this._denotation;
+ }
+
toString() {
- return this.dataType + (this._shape ? ('[' + this._shape.map((dimension) => dimension.toString()).join(',') + ']') : '');
+ return this.dataType + ((this._shape && this._shape.length) ? ('[' + this._shape.join(',') + ']') : '');
}
+}
+
+class OnnxSequenceType {
+
+ constructor(elementType, denotation) {
+ this._elementType = elementType;
+ this._denotation = denotation;
+ }
+
+ get elementType() {
+ return this._elementType;
+ }
+
+ get dennotation() {
+ return this._dennotation;
+ }
+
+ toString() {
+ return 'sequence<' + this._elementType.toString() + '>';
+ }
+}
+class OnnxMapType {
+
+ constructor(keyType, valueType, denotation) {
+ this._keyType = OnnxTensor._formatElementType(keyType);
+ this._valueType = valueType;
+ this._denotation = denotation;
+ }
+
+ get keyType() {
+ return this._keyType;
+ }
+
+ get valueType() {
+ return this._valueType;
+ }
+
+ get denotation() {
+ return this._denotation;
+ }
+
+ toString() {
+ return 'map<' + this._keyType + ',' + this._valueType.toString() + '>';
+ }
}
class OnnxGraphOperatorMetadata {
diff --git a/src/tf-model.js b/src/tf-model.js
index 21266b798a..e51fe1e86b 100644
--- a/src/tf-model.js
+++ b/src/tf-model.js
@@ -414,7 +414,7 @@ class TensorFlowNode {
input.connections.forEach((connection) => {
var initializer = this._graph._getInitializer(connection.id);
if (initializer) {
- connection.type = initializer.type.toString();
+ connection.type = initializer.type;
connection.initializer = initializer;
}
});
@@ -503,9 +503,6 @@ class TensorFlowAttribute {
return TensorFlowTensor.formatTensorShape(value.shape);
}
else if (value.hasOwnProperty('s')) {
- if (value.s.length == 0) {
- return '';
- }
if (value.s.filter(c => c <= 32 && c >= 128).length == 0) {
return '"' + TensorFlowOperatorMetadata.textDecoder.decode(value.s) + '"';
}
@@ -581,6 +578,7 @@ class TensorFlowTensor {
if (kind) {
this._kind = kind;
}
+ this._type = new TensorFlowTensorType(this._tensor.dtype, this._tensor.tensorShape);
}
get id() {
@@ -592,7 +590,7 @@ class TensorFlowTensor {
}
get type() {
- return new TensorFlowTensorType(this._tensor.dtype, this._tensor.tensorShape);
+ return this._type;
}
get kind() {
diff --git a/src/tflite-model.js b/src/tflite-model.js
index f1aad34291..f97315dddd 100644
--- a/src/tflite-model.js
+++ b/src/tflite-model.js
@@ -129,7 +129,7 @@ class TensorFlowLiteGraph {
results.push({
id: tensorIndex.toString(),
name: tensor.name(),
- type: new TensorFlowLiteTensorType(tensor).toString()
+ type: new TensorFlowLiteTensorType(tensor)
});
}
return results;
@@ -144,7 +144,7 @@ class TensorFlowLiteGraph {
results.push({
id: tensorIndex.toString(),
name: tensor.name(),
- type: new TensorFlowLiteTensorType(tensor).toString()
+ type: new TensorFlowLiteTensorType(tensor)
});
}
return results;
@@ -208,7 +208,7 @@ class TensorFlowLiteNode {
input.connections.forEach((connection) => {
var tensorIndex = connection.id;
var tensor = this._graph._graph.tensors(tensorIndex);
- connection.type = new TensorFlowLiteTensorType(tensor).toString();
+ connection.type = new TensorFlowLiteTensorType(tensor);
var initializer = this._graph.getInitializer(tensorIndex);
if (initializer) {
connection.initializer = initializer;
diff --git a/src/view-sidebar.js b/src/view-sidebar.js
index 41328888ee..191500cd87 100644
--- a/src/view-sidebar.js
+++ b/src/view-sidebar.js
@@ -281,9 +281,14 @@ class NodeAttributeView {
});
this._element.appendChild(this._expander);
}
-
var value = this._attribute.value;
- if (value.length > 1000) {
+ if (this._attribute.tensor) {
+ value = '[...]';
+ }
+ if (value && typeof value !== 'string') {
+ value = value.toString();
+ }
+ if (value && value.length > 1000) {
value = value.substring(0, 1000) + '...';
}
var valueLine = document.createElement('div');
@@ -408,21 +413,26 @@ class NodeConnectionView {
}
}
- var type = this._connection.type || '?';
- if (typeof type == 'string') {
- type = { value: type };
+ var type = '?';
+ var denotation = null;
+ if (this._connection.type) {
+ if (typeof this._connection.type == 'string') {
+ debugger;
+ }
+ type = this._connection.type.toString();
+ denotation = this._connection.type.denotation || null;
}
-
- if (type.value) {
+
+ if (type) {
var typeLine = document.createElement('div');
typeLine.className = 'sidebar-view-item-value-line-border';
- typeLine.innerHTML = 'type: ' + type.value + '
';
+ typeLine.innerHTML = 'type: ' + type + '
';
this._element.appendChild(typeLine);
}
- if (type.denotation) {
+ if (denotation) {
var denotationLine = document.createElement('div');
denotationLine.className = 'sidebar-view-item-value-line-border';
- denotationLine.innerHTML = 'denotation: ' + type.denotation + '
';
+ denotationLine.innerHTML = 'denotation: ' + denotation + '
';
this._element.appendChild(denotationLine);
}
@@ -680,12 +690,17 @@ class GraphArgumentView {
this._element = document.createElement('div');
this._element.className = 'sidebar-view-item-value';
- var type = this._argument.type || '?';
- if (typeof type == 'string') {
- type = { value: type };
+ var type = '?';
+ var denotation = null;
+ if (this._argument.type) {
+ if (typeof this._argument.type == 'string') {
+ debugger;
+ }
+ type = this._argument.type.toString();
+ denotation = this._argument.type.denotation || null;
}
- if (argument.description || type.denotation) {
+ if (argument.description || denotation) {
this._expander = document.createElement('div');
this._expander.className = 'sidebar-view-item-value-expander';
this._expander.innerText = '+';
@@ -697,10 +712,10 @@ class GraphArgumentView {
var typeLine = document.createElement('div');
typeLine.className = 'sidebar-view-item-value-line';
- typeLine.innerHTML = 'type: ' + type.value.split('<').join('<').split('>').join('>') + '
';
+ typeLine.innerHTML = 'type: ' + type.split('<').join('<').split('>').join('>') + '
';
this._element.appendChild(typeLine);
- if (argument.description || type.denotation) {
+ if (argument.description || denotation) {
this.toggle();
}
}
@@ -713,15 +728,13 @@ class GraphArgumentView {
if (this._expander.innerText == '+') {
this._expander.innerText = '-';
- var type = this._argument.type || '?';
- if (typeof type == 'string') {
- type = { value: type };
- }
+ var type = this._argument.type;
+ var denotation = (type && type.denotation) ? type.denotation : null;
- if (type.denotation) {
+ if (denotation) {
var denotationLine = document.createElement('div');
denotationLine.className = 'sidebar-view-item-value-line-border';
- denotationLine.innerHTML = 'denotation: ' + type.denotation + '
';
+ denotationLine.innerHTML = 'denotation: ' + denotation + '
';
this._element.appendChild(denotationLine);
}
diff --git a/src/view.js b/src/view.js
index 976a647b7c..6fea36192a 100644
--- a/src/view.js
+++ b/src/view.js
@@ -511,7 +511,7 @@ class View {
if (this._showDetails) {
if (!input.hidden) {
- var types = input.connections.map(connection => connection.type ? connection.type : '').join('\n');
+ var types = input.connections.map(connection => connection.type || '').join('\n');
formatter.addItem(input.name, inputId, [ inputClass ], types, () => {
this.showNodeProperties(node, input);
});