Skip to content

Commit

Permalink
Update attribute visible
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Jul 16, 2023
1 parent 658cd7a commit cd7697a
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 102 deletions.
5 changes: 0 additions & 5 deletions source/armnn.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ armnn.Model = class {
return 'Arm NN';
}

get description() {
return '';
}

get graphs() {
return this._graphs;
}
Expand All @@ -83,7 +79,6 @@ armnn.Graph = class {
this._nodes = [];
this._inputs = [];
this._outputs = [];

const counts = new Map();
for (const layer of graph.layers) {
const base = armnn.Node.getBase(layer);
Expand Down
4 changes: 0 additions & 4 deletions source/barracuda.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ barracuda.Attribute = class {
get value() {
return this._value;
}

get visible() {
return true;
}
};

barracuda.Tensor = class {
Expand Down
4 changes: 0 additions & 4 deletions source/bigdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ bigdl.Attribute = class {
get value() {
return this._value;
}

get visible() {
return true;
}
};

bigdl.Tensor = class {
Expand Down
2 changes: 1 addition & 1 deletion source/caffe.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ caffe.Attribute = class {
this._value = new caffe.TensorShape(value.dim.map((dim) => dim.toNumber()));
this._type = 'shape';
}
if (metadata && Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata && metadata.visible === false) {
this._visible = false;
}
if (metadata && Object.prototype.hasOwnProperty.call(metadata, 'default')) {
Expand Down
2 changes: 1 addition & 1 deletion source/caffe2.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ caffe2.Attribute = class {
}

if (metadata) {
if (Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata.visible === false) {
this._visible = false;
} else if (metadata.default !== undefined) {
if (this._value == metadata.default || (this._value && this._value.toString() == metadata.default.toString())) {
Expand Down
4 changes: 2 additions & 2 deletions source/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ circle.Node = class {
if (input.option == 'variadic') {
count = inputs.length - inputIndex;
}
if (Object.prototype.hasOwnProperty.call(input, 'visible') && !input.visible) {
if (input && input.visible === false) {
inputVisible = false;
}
}
Expand Down Expand Up @@ -415,7 +415,7 @@ circle.Attribute = class {
this._value = circle.Utility.enum(this._type, this._value);
}
if (metadata) {
if (Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
value = this._value;
Expand Down
14 changes: 7 additions & 7 deletions source/cntk.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ cntk.Node = class {

cntk.Attribute = class {

constructor(schema, name, value) {
constructor(metadata, name, value) {
this._name = name;
this._value = value;
this._type = null;
Expand All @@ -463,18 +463,18 @@ cntk.Attribute = class {
}
this._value = axis;
}
if (schema) {
if (schema.type) {
this._type = schema.type;
if (metadata) {
if (metadata.type) {
this._type = metadata.type;
const type = cntk_v1[this._type] || cntk_v2[this._type];
if (type && type[this._value]) {
this._value = type[this._value];
}
}
if (Object.prototype.hasOwnProperty.call(schema, 'visible') && !schema.visible) {
if (metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
let defaultValue = schema.default;
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
let defaultValue = metadata.default;
value = this._value;
if (typeof value == 'function') {
value = value();
Expand Down
2 changes: 1 addition & 1 deletion source/coreml.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ coreml.Attribute = class {
if (this._type && coreml.proto) {
this._value = coreml.Utility.enum(this._type, this._value);
}
if (Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
if (Array.isArray(value)) {
Expand Down
12 changes: 6 additions & 6 deletions source/darknet.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,11 @@ darknet.Node = class {

darknet.Attribute = class {

constructor(schema, name, value) {
constructor(metadata, name, value) {
this._name = name;
this._value = value;
if (schema) {
this._type = schema.type || '';
if (metadata) {
this._type = metadata.type || '';
switch (this._type) {
case '':
case 'string': {
Expand Down Expand Up @@ -967,10 +967,10 @@ darknet.Attribute = class {
throw new darknet.Error("Unsupported attribute type '" + this._type + "'.");
}
}
if (Object.prototype.hasOwnProperty.call(schema, 'visible') && !schema.visible) {
if (metadata && metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
if (this._value == schema.default) {
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
if (this._value == metadata.default) {
this._visible = false;
}
}
Expand Down
9 changes: 3 additions & 6 deletions source/dl4j.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,11 @@ dl4j.Node = class {

dl4j.Attribute = class {

constructor(schema, name, value) {
constructor(metadata, name, value) {
this._name = name;
this._value = value;
this._visible = false;
if (schema) {
if (schema.visible) {
this._visible = true;
}
if (metadata && metadata.visible === false) {
this._visible = false;
}
}

Expand Down
4 changes: 3 additions & 1 deletion source/hailo.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ hailo.Attribute = class {
this._name = name;
this._value = value;
this._type = metadata && metadata.type ? metadata.type : '';
this._visible = metadata && metadata.visible !== false ? true : false;
if (metadata && metadata.visible === false) {
this._visible = false;
}
if (name === 'original_names') {
this._visible = false;
}
Expand Down
4 changes: 2 additions & 2 deletions source/keras.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ keras.Attribute = class {
if (metadata.type) {
this._type = metadata.type;
}
if (Object.prototype.hasOwnProperty.call(metadata, 'visible')) {
this._visible = metadata.visible;
if (metadata.visible === false) {
this._visible = false;
} else if (metadata.default !== undefined) {
if (Array.isArray(value)) {
if (Array.isArray(metadata.default)) {
Expand Down
4 changes: 0 additions & 4 deletions source/mediapipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ mediapipe.Argument = class {
return this._name;
}

get visible() {
return true;
}

get value() {
return this._value;
}
Expand Down
4 changes: 0 additions & 4 deletions source/mlnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ mlnet.Attribute = class {
get value() {
return this._value;
}

get visible() {
return true;
}
};

mlnet.TensorType = class {
Expand Down
2 changes: 1 addition & 1 deletion source/ncnn.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ ncnn.Attribute = class {
break;
}
}
if (Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata && metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
if (this._value == metadata.default || (this._value && this._value.toString() == metadata.default.toString())) {
Expand Down
4 changes: 0 additions & 4 deletions source/om.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ om.Attribute = class {
get value() {
return this._value;
}

get visible() {
return true;
}
};

om.Argument = class {
Expand Down
2 changes: 1 addition & 1 deletion source/openvino.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ openvino.Attribute = class {
throw new openvino.Error("Unsupported attribute type '" + schema.type + "'.");
}
}
if (Object.prototype.hasOwnProperty.call(schema, 'visible') && schema.visible == false) {
if (schema && schema.visible == false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
let defaultValue = schema.default;
Expand Down
5 changes: 4 additions & 1 deletion source/pytorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ pytorch.Attribute = class {
constructor(metadata, name, value) {
this._name = name;
this._value = value;

if (this._name === 'training') {
this._visible = false;
this._type = 'boolean';
Expand Down Expand Up @@ -3991,6 +3990,10 @@ pytorch.nnapi.Graph = class {
const args = new Map();
const arg = (operand) => {
if (!args.has(operand.index)) {




const value = new pytorch.nnapi.Argument(operand);
args.set(operand.index, value);
}
Expand Down
8 changes: 0 additions & 8 deletions source/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ message.Argument = class {
get value() {
return this._value;
}

get visible() {
return true;
}
};

message.Value = class {
Expand Down Expand Up @@ -201,10 +197,6 @@ message.Attribute = class {
get type() {
return this._type;
}

get visible() {
return true;
}
};

message.TensorType = class {
Expand Down
16 changes: 8 additions & 8 deletions source/tengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ tengine.Node = class {

tengine.Attribute = class {

constructor(schema, key, value) {
constructor(metadata, key, value) {
this._type = '';
this._name = key;
this._value = value;
if (schema) {
this._name = schema.name;
if (schema.type) {
this._type = schema.type;
if (metadata) {
this._name = metadata.name;
if (metadata.type) {
this._type = metadata.type;
}
if (Object.prototype.hasOwnProperty.call(schema, 'visible') && !schema.visible) {
if (metadata.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
if (this._value == schema.default || (this._value && this._value.toString() == schema.default.toString())) {
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
if (this._value == metadata.default || (this._value && this._value.toString() == metadata.default.toString())) {
this._visible = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/tf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ tf.Attribute = class {
}
}
if (schema) {
if (Object.prototype.hasOwnProperty.call(schema, 'visible') && !schema.visible) {
if (schema.visible === false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(schema, 'default')) {
const equals = (value, defaultValue) => {
Expand Down
21 changes: 11 additions & 10 deletions source/tflite.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,29 +295,30 @@ tflite.Node = class {
let inputIndex = 0;
while (inputIndex < inputs.length) {
let count = 1;
let inputName = null;
let inputVisible = true;
const inputArguments = [];
let name = null;
let visible = true;
const values = [];
if (this._type && this._type.inputs && inputIndex < this._type.inputs.length) {
const input = this._type.inputs[inputIndex];
inputName = input.name;
name = input.name;
if (input.list) {
count = inputs.length - inputIndex;
}
if (Object.prototype.hasOwnProperty.call(input, 'visible') && !input.visible) {
inputVisible = false;
if (input.visible === false) {
visible = false;
}
}
const inputArray = inputs.slice(inputIndex, inputIndex + count);
for (const index of inputArray) {
const value = args(index);
if (value) {
inputArguments.push(value);
values.push(value);
}
}
inputIndex += count;
inputName = inputName ? inputName : inputIndex.toString();
this._inputs.push(new tflite.Argument(inputName, inputVisible, inputArguments));
name = name ? name : inputIndex.toString();
const argument = new tflite.Argument(name, visible, values);
this._inputs.push(argument);
}
for (let k = 0; k < outputs.length; k++) {
const index = outputs[k];
Expand Down Expand Up @@ -428,7 +429,7 @@ tflite.Attribute = class {
this._value = tflite.Utility.enum(this._type, this._value);
}
if (metadata) {
if (Object.prototype.hasOwnProperty.call(metadata, 'visible') && !metadata.visible) {
if (metadata && metadata.visible == false) {
this._visible = false;
} else if (Object.prototype.hasOwnProperty.call(metadata, 'default')) {
value = this._value;
Expand Down
Loading

0 comments on commit cd7697a

Please sign in to comment.