Skip to content

Commit

Permalink
Remove Graph.operators (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Mar 5, 2019
1 parent e7d9190 commit d9bfa5c
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 124 deletions.
6 changes: 0 additions & 6 deletions src/caffe.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ caffe.Graph = class {
this._nodes = [];
this._inputs = [];
this._outputs = [];
this._operators = {};

var layers = [];
switch (version) {
Expand Down Expand Up @@ -233,7 +232,6 @@ caffe.Graph = class {
var lastTop = null;
layers.forEach((layer) => {
var node = new caffe.Node(metadata, layer, version);
this._operators[node.operator] = (this._operators[node.operator] || 0) + 1;
if (layer.top.length == 1 &&
layer.bottom.length >= 1 &&
layer.top[0].split('\n').shift() == layer.bottom[0].split('\n').shift() &&
Expand Down Expand Up @@ -306,10 +304,6 @@ caffe.Graph = class {
}
}

get operators() {
return this._operators;
}

get name() {
return this._name;
}
Expand Down
6 changes: 0 additions & 6 deletions src/caffe2.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ caffe2.Graph = class {
this._name = netDef.name || '';
this._type = netDef.type || '';
this._nodes = [];
this._operators = {};

var initializers = {};
netDef.external_input.forEach((input) => {
Expand Down Expand Up @@ -213,7 +212,6 @@ caffe2.Graph = class {
var lastNode = null;
var lastOutput = null;
netDef.op.forEach((op) => {
this._operators[op.type] = (this._operators[op.type] || 0) + 1;
var node = new caffe2.Node(metadata, op, initializers);
if (op.input.length == 1 &&
op.output.length >= 1 &&
Expand Down Expand Up @@ -267,10 +265,6 @@ caffe2.Graph = class {
return this._nodes;
}

get operators() {
return this._operators;
}

toString() {
return 'graph(' + this.name + ')';
}
Expand Down
7 changes: 0 additions & 7 deletions src/coreml.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ coreml.Graph = class {
this._inputs = [];
this._outputs = [];
this._nodes = [];
this._operators = {};

if (this._description) {
this._inputs = this._description.input.map((input) => {
Expand All @@ -124,10 +123,6 @@ coreml.Graph = class {
this._type = this._loadModel(model, {}, '');
}

get operators() {
return this._operators;
}

get name() {
return '';
}
Expand Down Expand Up @@ -171,7 +166,6 @@ coreml.Graph = class {
predictedProbabilitiesName = predictedProbabilitiesName ? predictedProbabilitiesName : '?';
var labelProbabilityInput = this._updateOutput(labelProbabilityLayerName, labelProbabilityLayerName + ':labelProbabilityLayerName');
var operator = classifier.ClassLabels;
this._operators[operator] = (this._operators[operator] || 0) + 1;
this._nodes.push(new coreml.Node(this._metadata, this._group, operator, null, classifier[operator], [ labelProbabilityInput ], [ predictedProbabilitiesName, predictedFeatureName ]));
}
}
Expand Down Expand Up @@ -381,7 +375,6 @@ coreml.Graph = class {
}

_createNode(scope, group, operator, name, data, inputs, outputs) {
this._operators[operator] = (this._operators[operator] || 0) + 1;
inputs = inputs.map((input) => scope[input] ? scope[input].connection : input);
outputs = outputs.map((output) => {
if (scope[output]) {
Expand Down
7 changes: 0 additions & 7 deletions src/keras.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ keras.Graph = class {
this._outputs = [];
this._nodes = [];
this._groups = false;
this._operators = {};

switch (model.class_name) {
case 'Sequential':
Expand All @@ -250,10 +249,6 @@ keras.Graph = class {
}
}

get operators() {
return this._operators;
}

get name() {
return this._name;
}
Expand Down Expand Up @@ -366,7 +361,6 @@ keras.Graph = class {

if (config.layers) {
config.layers.forEach((layer) => {
this._operators[layer.class_name] = (this._operators[layer.class_name] || 0) + 1;
if (nodeMap[layer.name]) {
this._loadNode(layer, layer._inputs, layer._outputs, weights, group);
}
Expand All @@ -385,7 +379,6 @@ keras.Graph = class {
var layers = config.layers ? config.layers : config;

layers.forEach((layer) => {
this._operators[layer.class_name] = (this._operators[layer.class_name] || 0) + 1;
var name = index.toString();
var nodeInputs = [ connection ];
if (index == 0) {
Expand Down
6 changes: 0 additions & 6 deletions src/mxnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ mxnet.Graph = class {
{
this._metadata = metadata;
this._nodes = [];
this._operators = [];

var nodes = symbol.nodes;
nodes.forEach((node) => {
Expand All @@ -313,7 +312,6 @@ mxnet.Graph = class {
if (operator == 'tvm_op' && attrs && attrs.func_name) {
operator = attrs.func_name;
}
this._operators[operator] = (this._operators[operator] || 0) + 1;
}
});

Expand Down Expand Up @@ -387,10 +385,6 @@ mxnet.Graph = class {
});
}

get operators() {
return this._operators;
}

get name() {
return '';
}
Expand Down
6 changes: 0 additions & 6 deletions src/onnx.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ onnx.Graph = class {
this._nodes = [];
this._inputs = [];
this._outputs = [];
this._operators = {};
this._imageFormat = imageFormat;

if (graph) {
Expand All @@ -264,7 +263,6 @@ onnx.Graph = class {
var nodes = [];
var outputCountMap = {};
graph.node.forEach((node) => {
this._operators[node.op_type] = (this._operators[node.op_type] || 0) + 1;
node.output.forEach((output) => {
outputCountMap[output] = (outputCountMap[output] || 0) + 1;
});
Expand Down Expand Up @@ -369,10 +367,6 @@ onnx.Graph = class {
return this._description;
}

get operators() {
return this._operators;
}

get groups() {
return false;
}
Expand Down
12 changes: 0 additions & 12 deletions src/openvino.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ openvino.Graph = class {

layers.forEach((layer) => {
var operator = layer.getAttribute('type');
this._registerOperator(operator);

switch (operator) {
case 'Input':
var connections = [];
Expand Down Expand Up @@ -160,10 +158,6 @@ openvino.Graph = class {
return this._nodes;
}

get operators() {
return this._operators;
}

_connection(layer, precision, port, map) {
var id = layer + ':' + port.getAttribute('id');
if (map) {
Expand All @@ -181,10 +175,6 @@ openvino.Graph = class {
return connection;
}

_registerOperator(operator) {
this._operators[operator] = (this._operators[operator] || 0) + 1;
}

_replaceTensorIteratorWithSubgraph(layers, edges) {
const tiNodes = layers.filter((node) => node.getAttribute('type') === 'TensorIterator');

Expand Down Expand Up @@ -230,8 +220,6 @@ openvino.Graph = class {
});
});

const operator = nestedLayer.getAttribute('type');
this._registerOperator(operator);
this._nodes.push(nestedNode);
});

Expand Down
8 changes: 0 additions & 8 deletions src/tf.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ tf.Graph = class {
this._version = null;
this._metadata = new tf.GraphMetadata(metadata, metaGraph.meta_info_def);
this._name = name;
this._operators = {};
this._inputs = [];
this._outputs = [];
this._nodes = [];
Expand All @@ -233,9 +232,6 @@ tf.Graph = class {
}
var nodes = graph.node
if (nodes) {
nodes.forEach((node) => {
this._operators[node.op] = (this._operators[node.op] || 0) + 1;
});
var nodeMap = {};
this._namespaces = {};
nodes.forEach((node) => {
Expand Down Expand Up @@ -336,10 +332,6 @@ tf.Graph = class {
}
}

get operators() {
return this._operators;
}

get name() {
return this._name;
}
Expand Down
6 changes: 0 additions & 6 deletions src/tflite.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ tflite.Graph = class {
this._nodes = [];
this._inputs = [];
this._outputs = [];
this._operators = {};
var connections = [];
var names = [];
for (var i = 0; i < graph.tensorsLength(); i++) {
Expand All @@ -122,7 +121,6 @@ tflite.Graph = class {
var opcodeIndex = operator.opcodeIndex();
var operatorName = (opcodeIndex < operatorCodeList.length) ? operatorCodeList[opcodeIndex] : ('(' + opcodeIndex.toString() + ')');
var node = new tflite.Node(metadata, operator, operatorName, j.toString(), connections);
this._operators[node.operator] = (this._operators[node.operator] || 0) + 1;
this._nodes.push(node);
}
for (var k = 0; k < graph.inputsLength(); k++) {
Expand All @@ -135,10 +133,6 @@ tflite.Graph = class {
}
}

get operators() {
return this._operators;
}

get name() {
return this._name;
}
Expand Down
60 changes: 0 additions & 60 deletions src/view-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,6 @@ sidebar.ModelSidebar = class {
this.addProperty('description', new sidebar.ValueTextView(graph.description));
}

if (graph.operators) {
var item = new sidebar.NameValueView('operators', new sidebar.GraphOperatorListView(graph.operators));
this._elements.push(item.element);
}

if (graph.inputs.length > 0) {
this.addHeader('Inputs');
graph.inputs.forEach((input) => {
Expand Down Expand Up @@ -694,61 +689,6 @@ sidebar.ModelSidebar = class {
}
};

sidebar.GraphOperatorListView = class {

constructor(operators) {

this._element = document.createElement('div');
this._element.className = 'sidebar-view-item-value';

var count = 0;
this._list = [];
Object.keys(operators).forEach((operator) => {
this._list.push({ name: operator, count: operators[operator] });
count += operators[operator];
});
this._list = this._list.sort((a, b) => { return (a.name > b.name) - (a.name < b.name); });
this._list = this._list.map((item) => { return item.name + ': <b>' + item.count.toString() + '</b>'; });

this._expander = document.createElement('div');
this._expander.className = 'sidebar-view-item-value-expander';
this._expander.innerText = '+';
this._expander.addEventListener('click', () => {
this.toggle();
});

this._element.appendChild(this._expander);

var countLine = document.createElement('div');
countLine.className = 'sidebar-view-item-value-line';
countLine.innerHTML = 'Total: <b>' + count.toString() + '</b>';
this._element.appendChild(countLine);
}

get elements() {
return [ this._element ];
}

toggle() {
if (this._expander) {
if (this._expander.innerText == '+') {
this._expander.innerText = '-';

var valueLine = document.createElement('div');
valueLine.className = 'sidebar-view-item-value-line-border';
valueLine.innerHTML = this._list.join('<br/>');
this._element.appendChild(valueLine);
}
else {
this._expander.innerText = '+';
while (this._element.childElementCount > 2) {
this._element.removeChild(this._element.lastChild);
}
}
}
}
};

sidebar.OperatorDocumentationSidebar = class {

constructor(documentation) {
Expand Down

0 comments on commit d9bfa5c

Please sign in to comment.