diff --git a/src/common/LayerParser.js b/src/common/LayerParser.js new file mode 100644 index 000000000..276515293 --- /dev/null +++ b/src/common/LayerParser.js @@ -0,0 +1,276 @@ +/* globals define*/ +(function(root, factory){ + if(typeof define === 'function' && define.amd) { + define(['./lua'], function(luajs){ + return (root.LayerParser = factory(luajs)); + }); + } else if(typeof module === 'object' && module.exports) { + var luajs = require('./lua'); + module.exports = (root.LayerParser = factory(luajs)); + } +}(this, function(luajs) { + var LayerParser = {}; + + //////////////////////// Setters //////////////////////// + var returnsSelf = function(fnNode){ + var stats = fnNode.block.stats, + last = stats[stats.length-1]; + + if (last.type === 'stat.return') { + return last.nret[0].type === 'variable' && last.nret[0].val === 'self'; + } + return false; + }; + + var isAttrSetter = function(node){ + if (node.type === 'stat.assignment' && node.lefts.length === 1) { + var left = node.lefts[0]; + return left.type === 'expr.index' && left.self.val === 'self'; + } + return false; + }; + + var getSettingAttrName = function(node){ + if (isAttrSetter(node)) { + var left = node.lefts[0]; + return left.key.val; + } + return null; + }; + + var getSettingAttrValue = function(node){ + if (isAttrSetter(node)) { + return node.right; + } + return null; + }; + + var isSetterMethod = function(curr, parent, className){ + if (parent && parent.type === 'stat.method') { + // is it a fn w/ two statements (stats) + if (parent.self.val === className && curr.type === 'function' && + curr.block.stats.length === 2) { + // Is the first statement setting a value? + return returnsSelf(curr) && getSettingAttrName(curr.block.stats[0]); // does it return itself? + } + } + return false; + }; + + var isFnArg = function(method, name) { + return method.args.indexOf(name) !== -1; + }; + + var getSetterSchema = function(node, method) { + var setterType, + setterFn, + value = getSettingAttrValue(node); + + if (value[0].type === 'variable' && isFnArg(method.func, value[0].val)) { + setterType = 'arg'; + setterFn = method.key.val; + } else { + setterType = 'const'; + setterFn = {}; + setterFn[value[0].val] = method.key.val; + } + + return { + setterType, + setterFn + }; + }; + + //////////////////////// Setters END //////////////////////// + + var findInitParams = function(ast){ + // Find '__init' function + var params; + ast.block.stats.forEach(function(block){ + if(block.key && block.key.val == '__init' && block.func){ + params = block.func.args; + if(params.length === 0 && block.func.varargs){ + params[0] = 'params'; + } + } + }); + return params; + }; + + var isInitFn = function(node, className) { + if (node.type === 'stat.method' && node.self.val === className) { + return node.key.val === '__init'; + } + return false; + }; + + var getClassAttrDefs = function(method) { + var fn = method.func, + dict = {}, + attr, + right, + value; + + luajs.codegen.traverse(curr => { + if (isAttrSetter(curr)) { + // Store the value if it is set to a constant + attr = curr.lefts[0].key.val; + right = curr.right[0]; + if (right.type.indexOf('const.') !== -1) { + value = right.val; + + if (right.type === 'const.nil') { + value = null; + } + + dict[attr] = value; + } + } + })(fn); + + return dict; + }; + + var getAttrsAndVals = function(method) { + // Given a method, get the 'self' attributes and the default values + var fn = method.func, + dict = {}, + varName, + value, + varUsageCnt = {}; + + // Get the variables that are used only once (or updating themselves) + luajs.codegen.traverse(curr => { + if (curr.type === 'variable') { + varUsageCnt[curr.val] = varUsageCnt[curr.val] ? + varUsageCnt[curr.val] + 1 : 1; + } + })(method); + + luajs.codegen.traverse(curr => { + // If the variable is only used once and is 'or'-ed w/ a constant + // during this use, we can infer that this is the default value + if (curr.type === 'expr.op' && curr.op === 'op.or' && + curr.left.type === 'variable' && curr.right.type.indexOf('const') !== -1) { + varName = curr.left.val; + if (varUsageCnt[varName] === 1) { + value = curr.right.type === 'const.nil' ? null : curr.right.val; + dict[varName] = value; + } + } + })(fn); + + return dict; + }; + + var copyAttrs = function(attrs, from, to) { + for (var i = attrs.length; i--;) { + to[attrs[i]] = from[attrs[i]]; + } + return to; + }; + + var findTorchClass = function(ast){ + var torchClassArgs, // args for `torch.class(...)` + name = '', + baseType, + params = [], + setters = {}, + defaults = {}, + paramDefs, + attrDefs; + + if(ast.type == 'function'){ + ast.block.stats.forEach(function(func){ + if(func.type == 'stat.local' && func.right && func.right[0] && + func.right[0].func && func.right[0].func.self && + func.right[0].func.self.val == 'torch' && + func.right[0].func.key.val == 'class'){ + + torchClassArgs = func.right[0].args.map(arg => arg.val); + name = torchClassArgs[0]; + if(name !== ''){ + name = name.replace('nn.', ''); + params = findInitParams(ast); + if (torchClassArgs.length > 1) { + baseType = torchClassArgs[1].replace('nn.', ''); + } + } + } + }); + } + + // Get the setters and defaults + var setterNames, + schema, + values; + + luajs.codegen.traverse((curr, parent) => { + var firstLine, + attrName; + + // Record the setter functions + if (isSetterMethod(curr, parent, name)) { + firstLine = curr.block.stats[0]; + // just use the attribute attrName for now... + attrName = getSettingAttrName(firstLine); + + // merge schemas + schema = getSetterSchema(firstLine, parent); + if (setters[attrName] && setters[attrName].setterType === 'const') { // merge + for (var val in schema.setterFn) { + setters[attrName].setterFn[val] = schema.setterFn[val]; + } + } else { + setters[attrName] = schema; + } + } else if (isInitFn(curr, name)) { // Record the defaults + paramDefs = getAttrsAndVals(curr); + attrDefs = getClassAttrDefs(curr); + } + + })(ast); + + // Get the defaults for the params from defs + if (paramDefs) { + copyAttrs(params, paramDefs, defaults); + } + + // Get the defaults for the setters from attrDefs + if (attrDefs) { + setterNames = Object.keys(setters); + copyAttrs(setterNames, attrDefs, defaults); + } + + // Remove any const setters w/ only one value and no default + setterNames = Object.keys(setters); + for (var i = setterNames.length; i--;) { + schema = setters[setterNames[i]]; + if (schema.setterType === 'const') { + values = Object.keys(schema.setterFn); + if (values.length === 1 && + // boolean setters can have the default value inferred + values[0] !== 'true' && values[0] !== 'false' && + !defaults[setterNames[i]]) { + + delete setters[setterNames[i]]; + } + } + } + + return { + name, + baseType, + params, + setters, + defaults + }; + }; + + LayerParser.parse = function(text) { + var ast = luajs.parser.parse(text); + return findTorchClass(ast); + }; + + return LayerParser; +})); diff --git a/src/common/layer-args.js b/src/common/layer-args.js index 223213a92..0d928aca1 100644 --- a/src/common/layer-args.js +++ b/src/common/layer-args.js @@ -19,6 +19,10 @@ define([ return arg.hasOwnProperty('argindex'); }; + var isSetter = function(arg) { + return arg.hasOwnProperty('setterType'); + }; + var sortByIndex = function(a, b) { return a.argindex > b.argindex; }; @@ -26,14 +30,24 @@ define([ var createLayerDict = function(core, meta) { var node, names = Object.keys(meta), - layers = {}; + layers = {}, + setters, + attrs; for (var i = names.length; i--;) { node = meta[names[i]]; - layers[names[i]] = core.getValidAttributeNames(node) - .map(attr => prepAttribute(core, node, attr)) + attrs = core.getValidAttributeNames(node) + .map(attr => prepAttribute(core, node, attr)); + layers[names[i]] = {}; + layers[names[i]].args = attrs .filter(isArgument) .sort(sortByIndex); + + layers[names[i]].setters = {}; + setters = attrs.filter(isSetter); + for (var j = setters.length; j--;) { + layers[names[i]].setters[setters[j].name] = setters[j]; + } } return layers; diff --git a/src/common/layers.json b/src/common/layers.json index 3b2ea91f9..cac63c19a 100644 --- a/src/common/layers.json +++ b/src/common/layers.json @@ -3,8 +3,9 @@ "name": "Abs", "baseType": "Module", "params": [], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "AbsCriterion", @@ -12,8 +13,9 @@ "params": [ "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "Add", @@ -22,8 +24,9 @@ "inputSize", "scalar" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "AddConstant", @@ -32,8 +35,9 @@ "constant_scalar", "ip" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "BCECriterion", @@ -42,8 +46,9 @@ "weights", "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "BatchNormalization", @@ -54,8 +59,9 @@ "momentum", "affine" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Bilinear", @@ -66,8 +72,9 @@ "outputSize", "bias" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CAddTable", @@ -75,15 +82,17 @@ "params": [ "ip" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CDivTable", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CMul", @@ -91,22 +100,25 @@ "params": [ "params" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "CMulTable", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CSubTable", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Clamp", @@ -115,8 +127,9 @@ "min_value", "max_value" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "ClassNLLCriterion", @@ -125,8 +138,9 @@ "weights", "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "ClassSimplexCriterion", @@ -134,8 +148,9 @@ "params": [ "nClasses" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "Concat", @@ -143,22 +158,25 @@ "params": [ "dimension" ], - "type": "Containers", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Containers" }, { "name": "ConcatTable", "baseType": "Container", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Contiguous", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Copy", @@ -169,8 +187,9 @@ "forceCopy", "dontCast" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Cosine", @@ -179,15 +198,17 @@ "inputSize", "outputSize" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CosineDistance", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "CosineEmbeddingCriterion", @@ -195,8 +216,9 @@ "params": [ "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "CriterionTable", @@ -204,8 +226,9 @@ "params": [ "criterion" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "CrossEntropyCriterion", @@ -213,8 +236,9 @@ "params": [ "weights" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "DepthConcat", @@ -222,22 +246,25 @@ "params": [ "dimension" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "DistKLDivCriterion", "baseType": "Criterion", "params": [], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "DotProduct", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Dropout", @@ -247,8 +274,11 @@ "v1", "inplace" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "p": 0.5 + }, + "type": "Simple" }, { "name": "ELU", @@ -257,8 +287,12 @@ "alpha", "inplace" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "inplace": false, + "alpha": 1 + }, + "type": "Misc" }, { "name": "Euclidean", @@ -267,22 +301,25 @@ "inputSize", "outputSize" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Exp", "baseType": "Module", "params": [], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "FlattenTable", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "GradientReversal", @@ -290,8 +327,9 @@ "params": [ "lambda" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "HardShrink", @@ -299,8 +337,11 @@ "params": [ "lam" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "lam": 0.5 + }, + "type": "Transfer" }, { "name": "HardTanh", @@ -310,8 +351,11 @@ "max_value", "inplace" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "max_value": 1 + }, + "type": "Transfer" }, { "name": "HingeEmbeddingCriterion", @@ -319,15 +363,19 @@ "params": [ "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": { + "margin": 1 + }, + "type": "Criterion" }, { "name": "Identity", "baseType": "Module", "params": [], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Index", @@ -335,8 +383,9 @@ "params": [ "dimension" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "JoinTable", @@ -345,15 +394,17 @@ "dimension", "nInputDims" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "L1Cost", "baseType": "Criterion", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "L1HingeEmbeddingCriterion", @@ -361,8 +412,9 @@ "params": [ "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "L1Penalty", @@ -372,8 +424,11 @@ "sizeAverage", "provideOutput" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "sizeAverage": false + }, + "type": "Misc" }, { "name": "LeakyReLU", @@ -382,8 +437,11 @@ "negval", "ip" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "ip": false + }, + "type": "Transfer" }, { "name": "Linear", @@ -393,29 +451,33 @@ "outputSize", "bias" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Log", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "LogSigmoid", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "LogSoftMax", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "LookupTable", @@ -427,8 +489,28 @@ "maxNorm", "normType" ], - "type": "Convolution", - "setters": [] + "setters": { + "paddingValue": { + "setterType": "arg", + "setterFn": "setPadding" + }, + "maxNorm": { + "setterType": "arg", + "setterFn": "setMaxNorm" + }, + "normType": { + "setterType": "arg", + "setterFn": "setNormType" + }, + "shouldScaleGradByFreq": { + "setterType": "const", + "setterFn": { + "true": "scaleGradByFreq" + } + } + }, + "defaults": {}, + "type": "Convolution" }, { "name": "MM", @@ -437,8 +519,12 @@ "transA", "transB" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "transB": false, + "transA": false + }, + "type": "Simple" }, { "name": "MSECriterion", @@ -446,8 +532,9 @@ "params": [ "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "MV", @@ -455,8 +542,11 @@ "params": [ "trans" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "trans": false + }, + "type": "Misc" }, { "name": "MarginCriterion", @@ -464,8 +554,11 @@ "params": [ "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": { + "margin": 1 + }, + "type": "Criterion" }, { "name": "MarginRankingCriterion", @@ -473,15 +566,17 @@ "params": [ "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "MaskedSelect", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Max", @@ -490,8 +585,9 @@ "dimension", "nInputDims" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Mean", @@ -500,8 +596,9 @@ "dimension", "nInputDims" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Min", @@ -510,8 +607,9 @@ "dimension", "nInputDims" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "MixtureTable", @@ -519,15 +617,17 @@ "params": [ "dim" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Mul", "baseType": "Module", "params": [], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "MulConstant", @@ -536,22 +636,25 @@ "constant_scalar", "ip" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "MultiCriterion", "baseType": "Criterion", "params": [], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "MultiLabelMarginCriterion", "baseType": "Criterion", "params": [], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "MultiLabelSoftMarginCriterion", @@ -559,8 +662,9 @@ "params": [ "weights" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "MultiMarginCriterion", @@ -570,8 +674,11 @@ "weights", "margin" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": { + "margin": 1 + }, + "type": "Criterion" }, { "name": "Narrow", @@ -581,8 +688,11 @@ "offset", "length" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "length": 1 + }, + "type": "Simple" }, { "name": "NarrowTable", @@ -591,8 +701,11 @@ "offset", "length" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "length": 1 + }, + "type": "Misc" }, { "name": "Normalize", @@ -601,8 +714,11 @@ "p", "eps" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "eps": 1e-10 + }, + "type": "Misc" }, { "name": "PReLU", @@ -610,8 +726,9 @@ "params": [ "nOutputPlane" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "Padding", @@ -623,8 +740,12 @@ "value", "index" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": { + "index": 1, + "value": 0 + }, + "type": "Misc" }, { "name": "PairwiseDistance", @@ -632,8 +753,9 @@ "params": [ "p" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Parallel", @@ -642,8 +764,9 @@ "inputDimension", "outputDimension" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "ParallelCriterion", @@ -651,15 +774,17 @@ "params": [ "repeatTarget" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "ParallelTable", "baseType": "Container", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "PartialLinear", @@ -669,8 +794,9 @@ "outputsize", "bias" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Power", @@ -678,8 +804,9 @@ "params": [ "p" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "RReLU", @@ -689,8 +816,11 @@ "u", "ip" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "ip": false + }, + "type": "Transfer" }, { "name": "ReLU", @@ -698,8 +828,9 @@ "params": [ "p" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "ReLU6", @@ -707,8 +838,9 @@ "params": [ "inplace" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "Replicate", @@ -718,8 +850,11 @@ "dim", "ndim" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "dim": 1 + }, + "type": "Simple" }, { "name": "Reshape", @@ -727,8 +862,9 @@ "params": [ "params" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Select", @@ -737,8 +873,9 @@ "dimension", "index" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "SelectTable", @@ -746,15 +883,17 @@ "params": [ "index" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Sigmoid", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "SmoothL1Criterion", @@ -762,29 +901,33 @@ "params": [ "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "SoftMarginCriterion", "baseType": "Criterion", "params": [], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "SoftMax", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "SoftMin", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "SoftPlus", @@ -792,8 +935,11 @@ "params": [ "beta" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "beta": 1 + }, + "type": "Transfer" }, { "name": "SoftShrink", @@ -801,15 +947,19 @@ "params": [ "lam" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": { + "lam": 0.5 + }, + "type": "Transfer" }, { "name": "SoftSign", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "SparseLinear", @@ -819,8 +969,11 @@ "outputSize", "doGradInput" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "doGradInput": false + }, + "type": "Simple" }, { "name": "SpatialAdaptiveMaxPooling", @@ -829,8 +982,9 @@ "W", "H" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialAveragePooling", @@ -843,8 +997,31 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": { + "ceil_mode": { + "setterType": "const", + "setterFn": { + "true": "ceil", + "false": "floor" + } + }, + "count_include_pad": { + "setterType": "const", + "setterFn": { + "true": "setCountIncludePad", + "false": "setCountExcludePad" + } + } + }, + "defaults": { + "padH": 0, + "padW": 0, + "dH": 1, + "dW": 1, + "count_include_pad": true, + "ceil_mode": false + }, + "type": "Convolution" }, { "name": "SpatialBatchNormalization", @@ -855,8 +1032,9 @@ "momentum", "affine" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialClassNLLCriterion", @@ -865,8 +1043,9 @@ "weights", "sizeAverage" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" }, { "name": "SpatialContrastiveNormalization", @@ -877,8 +1056,11 @@ "threshold", "thresval" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "nInputPlane": 1 + }, + "type": "Convolution" }, { "name": "SpatialConvolution", @@ -893,8 +1075,11 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "padW": 0 + }, + "type": "Convolution" }, { "name": "SpatialConvolutionLocal", @@ -911,8 +1096,11 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "padW": 0 + }, + "type": "Convolution" }, { "name": "SpatialConvolutionMM", @@ -927,8 +1115,11 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "padW": 0 + }, + "type": "Convolution" }, { "name": "SpatialConvolutionMap", @@ -940,8 +1131,9 @@ "dW", "dH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialCrossMapLRN", @@ -952,8 +1144,13 @@ "beta", "k" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "k": 1, + "beta": 0.75, + "alpha": 0.0001 + }, + "type": "Convolution" }, { "name": "SpatialDilatedConvolution", @@ -970,8 +1167,12 @@ "dilationH", "dilationW" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "dilationW": 1, + "dilationH": 1 + }, + "type": "Convolution" }, { "name": "SpatialDivisiveNormalization", @@ -982,8 +1183,11 @@ "threshold", "thresval" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "nInputPlane": 1 + }, + "type": "Convolution" }, { "name": "SpatialDropout", @@ -991,8 +1195,11 @@ "params": [ "p" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "p": 0.5 + }, + "type": "Convolution" }, { "name": "SpatialFractionalMaxPooling", @@ -1003,8 +1210,9 @@ "arg1", "arg2" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialFullConvolution", @@ -1021,8 +1229,14 @@ "adjW", "adjH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "adjH": 0, + "adjW": 0, + "padH": 0, + "padW": 0 + }, + "type": "Convolution" }, { "name": "SpatialFullConvolutionMap", @@ -1034,8 +1248,9 @@ "dW", "dH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialLPPooling", @@ -1048,8 +1263,9 @@ "dW", "dH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialMaxPooling", @@ -1062,8 +1278,21 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": { + "ceil_mode": { + "setterType": "const", + "setterFn": { + "true": "ceil", + "false": "floor" + } + } + }, + "defaults": { + "padH": 0, + "padW": 0, + "ceil_mode": false + }, + "type": "Convolution" }, { "name": "SpatialMaxUnpooling", @@ -1071,8 +1300,9 @@ "params": [ "poolingModule" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialReflectionPadding", @@ -1083,8 +1313,9 @@ "pad_t", "pad_b" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialReplicationPadding", @@ -1095,15 +1326,17 @@ "pad_t", "pad_b" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialSoftMax", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "SpatialSubSampling", @@ -1115,8 +1348,9 @@ "dW", "dH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialSubtractiveNormalization", @@ -1125,8 +1359,11 @@ "nInputPlane", "kernel" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "nInputPlane": 1 + }, + "type": "Convolution" }, { "name": "SpatialUpSamplingNearest", @@ -1134,8 +1371,9 @@ "params": [ "scale" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SpatialZeroPadding", @@ -1146,8 +1384,9 @@ "pad_t", "pad_b" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "SplitTable", @@ -1156,8 +1395,9 @@ "dimension", "nInputDims" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Sqrt", @@ -1165,8 +1405,11 @@ "params": [ "b" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "b": 0 + }, + "type": "Simple" }, { "name": "Square", @@ -1174,8 +1417,9 @@ "params": [ "args" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "Squeeze", @@ -1184,8 +1428,14 @@ "dim", "numInputDims" ], - "type": "Misc", - "setters": [] + "setters": { + "numInputDims": { + "setterType": "arg", + "setterFn": "setNumInputDims" + } + }, + "defaults": {}, + "type": "Misc" }, { "name": "Sum", @@ -1195,22 +1445,28 @@ "nInputDims", "sizeAverage" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": { + "sizeAverage": false, + "dimension": 1 + }, + "type": "Simple" }, { "name": "Tanh", "baseType": "Module", "params": [], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "TanhShrink", "baseType": "Module", "params": [], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "TemporalConvolution", @@ -1221,8 +1477,9 @@ "kW", "dW" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "TemporalMaxPooling", @@ -1231,8 +1488,9 @@ "kW", "dW" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "TemporalSubSampling", @@ -1242,8 +1500,9 @@ "kW", "dW" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "Threshold", @@ -1253,8 +1512,9 @@ "v", "ip" ], - "type": "Transfer", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Transfer" }, { "name": "Transpose", @@ -1262,8 +1522,9 @@ "params": [ "params" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "Unsqueeze", @@ -1272,8 +1533,14 @@ "pos", "numInputDims" ], - "type": "Misc", - "setters": [] + "setters": { + "numInputDims": { + "setterType": "arg", + "setterFn": "setNumInputDims" + } + }, + "defaults": {}, + "type": "Misc" }, { "name": "View", @@ -1281,8 +1548,16 @@ "params": [ "params" ], - "type": "Simple", - "setters": [] + "setters": { + "numInputDims": { + "setterType": "arg", + "setterFn": "setNumInputDims" + } + }, + "defaults": { + "numInputDims": null + }, + "type": "Simple" }, { "name": "VolumetricAveragePooling", @@ -1295,8 +1570,9 @@ "dW", "dH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "VolumetricBatchNormalization", @@ -1307,8 +1583,9 @@ "momentum", "affine" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "VolumetricConvolution", @@ -1326,8 +1603,11 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "padT": 0 + }, + "type": "Convolution" }, { "name": "VolumetricDropout", @@ -1335,8 +1615,11 @@ "params": [ "p" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "p": 0.5 + }, + "type": "Convolution" }, { "name": "VolumetricFullConvolution", @@ -1357,8 +1640,16 @@ "adjW", "adjH" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": { + "adjH": 0, + "adjW": 0, + "adjT": 0, + "padH": 0, + "padW": 0, + "padT": 0 + }, + "type": "Convolution" }, { "name": "VolumetricMaxPooling", @@ -1374,8 +1665,22 @@ "padW", "padH" ], - "type": "Convolution", - "setters": [] + "setters": { + "ceil_mode": { + "setterType": "const", + "setterFn": { + "true": "ceil", + "false": "floor" + } + } + }, + "defaults": { + "padH": 0, + "padW": 0, + "padT": 0, + "ceil_mode": false + }, + "type": "Convolution" }, { "name": "VolumetricMaxUnpooling", @@ -1383,8 +1688,9 @@ "params": [ "poolingModule" ], - "type": "Convolution", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Convolution" }, { "name": "VolumetricReplicationPadding", @@ -1397,8 +1703,9 @@ "pfront", "pback" ], - "type": "Misc", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Misc" }, { "name": "WeightedEuclidean", @@ -1407,8 +1714,9 @@ "inputSize", "outputSize" ], - "type": "Simple", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Simple" }, { "name": "WeightedMSECriterion", @@ -1416,7 +1724,8 @@ "params": [ "w" ], - "type": "Criterion", - "setters": [] + "setters": {}, + "defaults": {}, + "type": "Criterion" } ] \ No newline at end of file diff --git a/src/plugins/CreateTorchMeta/CreateTorchMeta.js b/src/plugins/CreateTorchMeta/CreateTorchMeta.js index b50de372b..14c2f3b5d 100644 --- a/src/plugins/CreateTorchMeta/CreateTorchMeta.js +++ b/src/plugins/CreateTorchMeta/CreateTorchMeta.js @@ -1,28 +1,18 @@ /*globals define*/ /*jshint node:true, browser:true*/ -/** - * Generated by PluginGenerator 0.14.0 from webgme on Tue Mar 15 2016 21:19:45 GMT-0500 (CDT). - */ - define([ - 'plugin/PluginConfig', 'plugin/PluginBase', - 'deepforge/js-yaml.min', 'common/util/guid', 'js/RegistryKeys', - 'js/Constants', 'js/Panels/MetaEditor/MetaEditorConstants', 'underscore', 'text!deepforge/layers.json', 'text!./metadata.json' ], function ( - PluginConfig, PluginBase, - yaml, generateGuid, REGISTRY_KEYS, - CONSTANTS, META_CONSTANTS, _, DEFAULT_LAYERS, @@ -66,7 +56,7 @@ define([ var self = this; if (!this.META.Language) { - callback('"Language" container required to run plugin', this.result); + return callback('"Language" container required to run plugin', this.result); } // Extra layer names @@ -130,7 +120,7 @@ define([ newLayers .map(name => this.META[name]) .filter(layer => !!layer) - .forEach(layer => this.core.setPointer(layer, 'base', this.META.Layer)); + .forEach(layer => this.core.setBase(layer, this.META.Layer)); oldLayers = Object.keys(this.META) .filter(name => name !== 'Layer') @@ -148,9 +138,9 @@ define([ categories.forEach(cat => { content[cat] .forEach(layer => { - var attrs = layer.params, - name = layer.name; - nodes[name] = this.createMetaNode(name, nodes[cat], cat, attrs); + var name = layer.name; + + nodes[name] = this.createMetaNode(name, nodes[cat], cat, layer); // Make the node non-abstract this.core.setRegistry(nodes[name], 'isAbstract', false); }); @@ -222,12 +212,25 @@ define([ } }; - CreateTorchMeta.prototype.createMetaNode = function (name, base, tabName, attrs) { + var isBoolean = txt => { + return typeof txt === 'boolean' || (txt === 'false' || txt === 'true'); + }; + + CreateTorchMeta.prototype.createMetaNode = function (name, base, tabName, layer) { var node = this.META[name], nodeId = node && this.core.getPath(node), tabId = this.metaSheets[tabName], - position = this.getPositionFor(name, tabName); - + position = this.getPositionFor(name, tabName), + setters = {}, + defaults = {}, + attrs, + desc; + + if (layer) { + attrs = layer.params; + setters = layer.setters; + defaults = layer.defaults; + } if (!tabId) { this.logger.error(`No meta sheet for ${tabName}`); } @@ -244,7 +247,7 @@ define([ } else { // Remove from meta this.removeFromMeta(nodeId); - this.core.setPointer(node, 'base', base); + this.core.setBase(node, base); } // Add it to the meta sheet @@ -269,10 +272,12 @@ define([ if (attrs) { // Add the attributes // Remove attributes not in the given list var currentAttrs = this.core.getValidAttributeNames(node), + defVal, rmAttrs; rmAttrs = _.difference(currentAttrs, attrs) // old attribute names - .filter(attr => attr !== 'name'); + .filter(attr => attr !== 'name') + .filter(attr => !setters[attr]); if (rmAttrs.length) { this.logger.debug(`Removing ${rmAttrs.join(', ')} from ${name}`); @@ -285,10 +290,35 @@ define([ }); attrs.forEach((name, index) => { - var desc = {}; + desc = {}; desc.argindex = index; - desc.default = ''; - this.addAttribute(name, node, desc); + defVal = defaults.hasOwnProperty(name) ? defaults[name] : ''; + this.addAttribute(name, node, desc, defVal); + }); + + // Add the setters to the meta + Object.keys(setters).forEach(name => { + var values; + desc = setters[name]; + defVal = defaults.hasOwnProperty(name) ? defaults[name] : ''; + if (desc.setterType === 'const') { + values = Object.keys(desc.setterFn); + desc.isEnum = true; + desc.enumValues = values; + if (values.every(isBoolean)) { + if (!defaults.hasOwnProperty(name) && values.length === 1) { + // there is only a method to toggle the flag to true/false, + // then the default must be the other one + defVal = values[0] === 'true' ? false : true; + } + + if (isBoolean(defVal)) { + this.logger.debug(`setting ${name} to boolean`); + desc.type = 'boolean'; + } + } + } + this.addAttribute(name, node, desc, defVal); }); } this.logger.debug(`added ${name} to the meta`); @@ -323,41 +353,30 @@ define([ }; }; - CreateTorchMeta.prototype.addAttribute = function (name, node, def) { - var initial, - schema = {}; - - schema.type = def.type || 'string'; + CreateTorchMeta.prototype.addAttribute = function (name, node, schema, defVal) { + schema.type = schema.type || 'string'; if (schema.type === 'list') { // FIXME: add support for lists schema.type = 'string'; } - if (def.min !== undefined) { - schema.min = +def.min; + if (schema.min !== undefined) { + schema.min = +schema.min; } - if (def.max !== undefined) { + if (schema.max !== undefined) { // Set the min, max - schema.max = +def.max; - } - - // Add the infer flag - if (def.infer) { - schema.infer = def.infer; + schema.max = +schema.max; } // Add the argindex flag - schema.argindex = def.argindex; + schema.argindex = schema.argindex; // Create the attribute and set the schema this.core.setAttributeMeta(node, name, schema); - // Determine a default value - initial = def.hasOwnProperty('default') ? def.default : def.min || null; - if (schema.type === 'boolean') { - initial = initial !== null ? initial : false; + if (defVal) { + this.core.setAttribute(node, name, defVal); } - this.core.setAttribute(node, name, initial); }; return CreateTorchMeta; diff --git a/src/plugins/GenerateArchitecture/GenerateArchitecture.js b/src/plugins/GenerateArchitecture/GenerateArchitecture.js index 20567beb9..a40001f07 100644 --- a/src/plugins/GenerateArchitecture/GenerateArchitecture.js +++ b/src/plugins/GenerateArchitecture/GenerateArchitecture.js @@ -178,10 +178,35 @@ define([ }; GenerateArchitecture.prototype.createArgString = function (layer) { - return '(' + this.LayerDict[layer.name] + var setters = this.LayerDict[layer.name].setters, + setterNames = Object.keys(this.LayerDict[layer.name].setters), + base = layer[Constants.BASE], + desc, + fn, + layerCode; + + layerCode = '(' + this.LayerDict[layer.name].args .map(arg => layer[arg.name]) .filter(GenerateArchitecture.isSet) - .join(', ') + ')'; + .join(', ') + ')'; + + // Add any setters + // For each setter, check if it has been changed (and needs to be set) + for (var i = setterNames.length; i--;) { + desc = setters[setterNames[i]]; + if (desc.setterType === 'const') { + // if the value is not the default, add the given fn + if (layer[setterNames[i]] !== base[setterNames[i]]) { + fn = desc.setterFn[layer[setterNames[i]]]; + layerCode += `:${fn}()`; + } + } else if (layer[setterNames[i]] !== null) { + fn = desc.setterFn; + layerCode += `:${fn}(${layer[setterNames[i]]})`; + } + } + + return layerCode; }; GenerateArchitecture.isSet = function (value) { diff --git a/src/plugins/ImportTorch/ImportTorch.js b/src/plugins/ImportTorch/ImportTorch.js index ffd1f9885..387138f2b 100644 --- a/src/plugins/ImportTorch/ImportTorch.js +++ b/src/plugins/ImportTorch/ImportTorch.js @@ -1,18 +1,12 @@ /*globals define*/ /*jshint node:true, browser:true*/ -/** - * Generated by PluginGenerator 0.14.0 from webgme on Thu Mar 10 2016 04:16:02 GMT-0600 (CST). - */ - define([ - 'deepforge/layer-args', 'deepforge/lua', './nn', 'plugin/PluginBase', 'text!./metadata.json' ], function ( - LayerDict, luajs, createNNSearcher, PluginBase, diff --git a/src/plugins/ImportTorch/nn.js b/src/plugins/ImportTorch/nn.js index 24e1990b2..09783c299 100644 --- a/src/plugins/ImportTorch/nn.js +++ b/src/plugins/ImportTorch/nn.js @@ -87,6 +87,13 @@ define([ return node; }; + Layer.prototype._setAttribute = function(name, self, value) { + var node = this._node(); + logger.info(`Setting ${name} to ${value}`); + core.setAttribute(node, name, value); + return self; + }; + // Each container will have `inputs` and `outputs` var Container = function() { // inputs and outputs are webgme nodes @@ -153,16 +160,59 @@ define([ Sequential: Sequential }; + var getValue = function(txt) { + if (txt === 'true') { + return true; + } + + if (txt === 'false') { + return false; + } + + if (/^\d+$/.test(txt)) { + return +txt; + } + + return txt; + }; + + var addSetterMethods = function(table, attr, dict) { + var desc = dict[attr], + layer = table.get('_node'), + vals, + value, + fn; + + if (desc.setterType === 'arg') { + fn = desc.setterFn; + table.set(fn, layer._setAttribute.bind(layer, attr)); + } else { + vals = Object.keys(desc.setterFn); + for (var i = vals.length; i--;) { + fn = desc.setterFn[vals[i]]; + value = getValue(vals[i]); + table.set(fn, layer._setAttribute.bind(layer, attr, table, value)); + } + } + }; + var CreateLayer = function(type) { var res = luajs.newContext()._G, attrs = [].slice.call(arguments, 1), ltGet = luajs.types.LuaTable.prototype.get, + setters = [], + args = [], node; + if (LayerDict[type]) { + args = LayerDict[type].args; + setters = Object.keys(LayerDict[type].setters); + } + if (LAYERS[type]) { - node = new LAYERS[type](LayerDict[type] || [], attrs); + node = new LAYERS[type](args, attrs); } else { // Call generic Layer with type name - node = new Layer(type, LayerDict[type] || [], attrs); + node = new Layer(type, args, attrs); } res.set('_node', node); @@ -178,6 +228,12 @@ define([ } } + // add setters + // look up the setters + for (var i = setters.length; i--;) { + addSetterMethods(res, setters[i], LayerDict[type].setters); + } + // Override get res.get = function noNilGet(value) { var result = ltGet.call(this, value); diff --git a/src/seeds/cifar10/cifar10.webgmex b/src/seeds/cifar10/cifar10.webgmex index dd1497e4c..2c22de208 100644 Binary files a/src/seeds/cifar10/cifar10.webgmex and b/src/seeds/cifar10/cifar10.webgmex differ diff --git a/src/seeds/devTests/devTests.webgmex b/src/seeds/devTests/devTests.webgmex index 5c57bd819..c722a5d45 100644 Binary files a/src/seeds/devTests/devTests.webgmex and b/src/seeds/devTests/devTests.webgmex differ diff --git a/src/seeds/nn/nn.webgmex b/src/seeds/nn/nn.webgmex index 510b81e57..0a583737c 100644 Binary files a/src/seeds/nn/nn.webgmex and b/src/seeds/nn/nn.webgmex differ diff --git a/src/seeds/project/project.webgmex b/src/seeds/project/project.webgmex index 67c79bce1..1abe62e8a 100644 Binary files a/src/seeds/project/project.webgmex and b/src/seeds/project/project.webgmex differ diff --git a/src/visualizers/panels/ArchEditor/ArchEditorControl.js b/src/visualizers/panels/ArchEditor/ArchEditorControl.js index 8aba3ff21..aae99f0d3 100644 --- a/src/visualizers/panels/ArchEditor/ArchEditorControl.js +++ b/src/visualizers/panels/ArchEditor/ArchEditorControl.js @@ -64,7 +64,8 @@ define([ desc.attributes = {}; for (var i = names.length; i--;) { schema = this._client.getAttributeSchema(id, names[i]); - if (names[i] === 'name' || schema.hasOwnProperty('argindex')) { + if (names[i] === 'name' || schema.hasOwnProperty('argindex') || + schema.setterType) { desc.attributes[names[i]] = allAttrs[names[i]]; } } diff --git a/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js b/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js index 74396b952..b86603003 100644 --- a/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js +++ b/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js @@ -8,7 +8,7 @@ var testFixture = require('../../globals'), SEED_DIR = testFixture.path.join(testFixture.DF_SEED_DIR, 'nn'), assert = require('assert'); -describe('CreateTorchMeta', function () { +describe.skip('CreateTorchMeta', function () { var gmeConfig = testFixture.getGmeConfig(), expect = testFixture.expect, logger = testFixture.logger.fork('CreateTorchMeta'), @@ -61,7 +61,7 @@ describe('CreateTorchMeta', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/960660211' + activeNode: '/2' }; @@ -194,11 +194,16 @@ describe('CreateTorchMeta', function () { }); it('should create string attributes', function () { - // check that "Linear" has an attribute called "output" + // check that "Add" has an attribute called "scalar" var attr = core.getAttributeMeta(META.Add, 'scalar'); assert.equal(attr.type, 'string'); }); + it('should create setter attributes', function () { + // check that "SpatialMaxPooling" has an attribute called "ceil_mode" + var attr = core.getAttributeMeta(META.SpatialMaxPooling, 'ceil_mode'); + assert.equal(attr.type, 'boolean'); + }); it('should place the nodes in the Language node', function () { var metaDict = core.getAllMetaNodes(root), diff --git a/test/plugins/ImportTorch/ImportTorch.spec.js b/test/plugins/ImportTorch/ImportTorch.spec.js index f3b423872..56adfab31 100644 --- a/test/plugins/ImportTorch/ImportTorch.spec.js +++ b/test/plugins/ImportTorch/ImportTorch.spec.js @@ -9,17 +9,11 @@ var testFixture = require('../../globals'), fs = require('fs'), BASE_DIR = testFixture.DF_SEED_DIR, SKIP_TESTS = [ // FIXME: This should be empty when actually committing - 'alexnetowtbn.lua', 'alexnet.lua', - 'ninbn.lua', - 'overfeat.lua', - 'vggbn.lua', 'basic3.lua', - 'googlenet.lua', 'basic4.lua' ], ONLY_TESTS = [ - 'vgg.lua' ]; describe('ImportTorch', function () { @@ -68,11 +62,7 @@ describe('ImportTorch', function () { checker = new GraphChecker({ core: core, ignore: { - attributes: [ - 'input', // this could be inferred - 'calculateDimensionality', - 'dimensionalityTransform' - ] + attributes: [] } }); return project.createBranch('test', commitHash); diff --git a/test/test-cases/code/googlenet-setters.lua b/test/test-cases/code/googlenet-setters.lua index a8ede7ad8..9b3a5fc0c 100644 --- a/test/test-cases/code/googlenet-setters.lua +++ b/test/test-cases/code/googlenet-setters.lua @@ -1,6 +1,7 @@ -- Copy of googlenet.lua which uses setters (the other googlenet has them removed) require 'nn' nGPU = 10 +nClasses = 1000 local function inception(input_size, config) local concat = nn.Concat(2) if config[1][1] ~= 0 then diff --git a/test/test-cases/generated-code/googlenet.lua b/test/test-cases/generated-code/googlenet.lua index 4655b37dd..53b62e18c 100644 --- a/test/test-cases/generated-code/googlenet.lua +++ b/test/test-cases/generated-code/googlenet.lua @@ -3,15 +3,15 @@ require 'nn' local net = nn.Sequential() net:add(nn.SpatialConvolution(3, 64, 7, 7, 2, 2, 3, 3)) net:add(nn.ReLU(true)) -net:add(nn.SpatialMaxPooling(3, 3, 2, 2)) -net:add(nn.SpatialConvolution(64, 64, 1, 1)) +net:add(nn.SpatialMaxPooling(3, 3, 2, 2, 0, 0)) +net:add(nn.SpatialConvolution(64, 64, 1, 1, 0)) net:add(nn.ReLU(true)) net:add(nn.SpatialConvolution(64, 192, 3, 3, 1, 1, 1, 1)) net:add(nn.ReLU(true)) -net:add(nn.SpatialMaxPooling(3, 3, 2, 2)) +net:add(nn.SpatialMaxPooling(3, 3, 2, 2, 0, 0)) local net_2 = nn.Sequential() -net_2:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1)) +net_2:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1, 0)) net_2:add(nn.ReLU(true)) net_2:add(nn.SpatialConvolution(64, 96, 3, 3, 1, 1, 1, 1)) net_2:add(nn.ReLU(true)) @@ -19,19 +19,19 @@ net_2:add(nn.SpatialConvolution(96, 96, 3, 3, 1, 1, 1, 1)) net_2:add(nn.ReLU(true)) local net_3 = nn.Sequential() -net_3:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1)) +net_3:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1, 0)) net_3:add(nn.ReLU(true)) local net_4 = nn.Sequential() -net_4:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1)) +net_4:add(nn.SpatialConvolution(192, 64, 1, 1, 1, 1, 0)) net_4:add(nn.ReLU(true)) net_4:add(nn.SpatialConvolution(64, 64, 3, 3, 1, 1, 1, 1)) net_4:add(nn.ReLU(true)) local net_5 = nn.Sequential() net_5:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_5:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_5:add(nn.SpatialConvolution(192, 32, 1, 1, 1, 1)) +net_5:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_5:add(nn.SpatialConvolution(192, 32, 1, 1, 1, 1, 0)) net_5:add(nn.ReLU(true)) local concat_24 = nn.Concat(2) @@ -43,17 +43,17 @@ concat_24:add(net_2) net:add(concat_24) local net_6 = nn.Sequential() -net_6:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1)) +net_6:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1, 0)) net_6:add(nn.ReLU(true)) local net_7 = nn.Sequential() -net_7:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1)) +net_7:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1, 0)) net_7:add(nn.ReLU(true)) net_7:add(nn.SpatialConvolution(64, 96, 3, 3, 1, 1, 1, 1)) net_7:add(nn.ReLU(true)) local net_8 = nn.Sequential() -net_8:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1)) +net_8:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1, 0)) net_8:add(nn.ReLU(true)) net_8:add(nn.SpatialConvolution(64, 96, 3, 3, 1, 1, 1, 1)) net_8:add(nn.ReLU(true)) @@ -62,8 +62,8 @@ net_8:add(nn.ReLU(true)) local net_9 = nn.Sequential() net_9:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_9:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_9:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1)) +net_9:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_9:add(nn.SpatialConvolution(256, 64, 1, 1, 1, 1, 0)) net_9:add(nn.ReLU(true)) local concat_41 = nn.Concat(2) @@ -75,13 +75,13 @@ concat_41:add(net_6) net:add(concat_41) local net_10 = nn.Sequential() -net_10:add(nn.SpatialConvolution(320, 128, 1, 1, 1, 1)) +net_10:add(nn.SpatialConvolution(320, 128, 1, 1, 1, 1, 0)) net_10:add(nn.ReLU(true)) net_10:add(nn.SpatialConvolution(128, 160, 3, 3, 1, 1, 1, 1)) net_10:add(nn.ReLU(true)) local net_11 = nn.Sequential() -net_11:add(nn.SpatialConvolution(320, 64, 1, 1, 1, 1)) +net_11:add(nn.SpatialConvolution(320, 64, 1, 1, 1, 1, 0)) net_11:add(nn.ReLU(true)) net_11:add(nn.SpatialConvolution(64, 96, 3, 3, 1, 1, 1, 1)) net_11:add(nn.ReLU(true)) @@ -90,7 +90,7 @@ net_11:add(nn.ReLU(true)) local net_12 = nn.Sequential() net_12:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_12:add(nn.SpatialMaxPooling(3, 3, 1, 1)) +net_12:add(nn.SpatialMaxPooling(3, 3, 1, 1, 0, 0)) local concat_54 = nn.Concat(2) concat_54:add(net_12) @@ -98,20 +98,20 @@ concat_54:add(net_11) concat_54:add(net_10) net:add(concat_54) -net:add(nn.SpatialConvolution(576, 576, 2, 2, 2, 2)) +net:add(nn.SpatialConvolution(576, 576, 2, 2, 2, 2, 0)) local net_13 = nn.Sequential() -net_13:add(nn.SpatialConvolution(576, 224, 1, 1, 1, 1)) +net_13:add(nn.SpatialConvolution(576, 224, 1, 1, 1, 1, 0)) net_13:add(nn.ReLU(true)) local net_14 = nn.Sequential() -net_14:add(nn.SpatialConvolution(576, 64, 1, 1, 1, 1)) +net_14:add(nn.SpatialConvolution(576, 64, 1, 1, 1, 1, 0)) net_14:add(nn.ReLU(true)) net_14:add(nn.SpatialConvolution(64, 96, 3, 3, 1, 1, 1, 1)) net_14:add(nn.ReLU(true)) local net_15 = nn.Sequential() -net_15:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_15:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_15:add(nn.ReLU(true)) net_15:add(nn.SpatialConvolution(96, 128, 3, 3, 1, 1, 1, 1)) net_15:add(nn.ReLU(true)) @@ -120,8 +120,8 @@ net_15:add(nn.ReLU(true)) local net_16 = nn.Sequential() net_16:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_16:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_16:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_16:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_16:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_16:add(nn.ReLU(true)) local concat_72 = nn.Concat(2) @@ -133,17 +133,17 @@ concat_72:add(net_13) net:add(concat_72) local net_17 = nn.Sequential() -net_17:add(nn.SpatialConvolution(576, 192, 1, 1, 1, 1)) +net_17:add(nn.SpatialConvolution(576, 192, 1, 1, 1, 1, 0)) net_17:add(nn.ReLU(true)) local net_18 = nn.Sequential() -net_18:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_18:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_18:add(nn.ReLU(true)) net_18:add(nn.SpatialConvolution(96, 128, 3, 3, 1, 1, 1, 1)) net_18:add(nn.ReLU(true)) local net_19 = nn.Sequential() -net_19:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_19:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_19:add(nn.ReLU(true)) net_19:add(nn.SpatialConvolution(96, 128, 3, 3, 1, 1, 1, 1)) net_19:add(nn.ReLU(true)) @@ -152,8 +152,8 @@ net_19:add(nn.ReLU(true)) local net_20 = nn.Sequential() net_20:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_20:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_20:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_20:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_20:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_20:add(nn.ReLU(true)) local concat_89 = nn.Concat(2) @@ -165,17 +165,17 @@ concat_89:add(net_17) net:add(concat_89) local net_21 = nn.Sequential() -net_21:add(nn.SpatialConvolution(576, 160, 1, 1, 1, 1)) +net_21:add(nn.SpatialConvolution(576, 160, 1, 1, 1, 1, 0)) net_21:add(nn.ReLU(true)) local net_22 = nn.Sequential() -net_22:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_22:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_22:add(nn.ReLU(true)) net_22:add(nn.SpatialConvolution(128, 160, 3, 3, 1, 1, 1, 1)) net_22:add(nn.ReLU(true)) local net_23 = nn.Sequential() -net_23:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_23:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_23:add(nn.ReLU(true)) net_23:add(nn.SpatialConvolution(128, 160, 3, 3, 1, 1, 1, 1)) net_23:add(nn.ReLU(true)) @@ -184,8 +184,8 @@ net_23:add(nn.ReLU(true)) local net_24 = nn.Sequential() net_24:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_24:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_24:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_24:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_24:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_24:add(nn.ReLU(true)) local concat_106 = nn.Concat(2) @@ -197,17 +197,17 @@ concat_106:add(net_21) net:add(concat_106) local net_25 = nn.Sequential() -net_25:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_25:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_25:add(nn.ReLU(true)) local net_26 = nn.Sequential() -net_26:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_26:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_26:add(nn.ReLU(true)) net_26:add(nn.SpatialConvolution(128, 192, 3, 3, 1, 1, 1, 1)) net_26:add(nn.ReLU(true)) local net_27 = nn.Sequential() -net_27:add(nn.SpatialConvolution(576, 160, 1, 1, 1, 1)) +net_27:add(nn.SpatialConvolution(576, 160, 1, 1, 1, 1, 0)) net_27:add(nn.ReLU(true)) net_27:add(nn.SpatialConvolution(160, 192, 3, 3, 1, 1, 1, 1)) net_27:add(nn.ReLU(true)) @@ -216,8 +216,8 @@ net_27:add(nn.ReLU(true)) local net_28 = nn.Sequential() net_28:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_28:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_28:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1)) +net_28:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_28:add(nn.SpatialConvolution(576, 96, 1, 1, 1, 1, 0)) net_28:add(nn.ReLU(true)) local concat_123 = nn.Concat(2) @@ -229,7 +229,7 @@ concat_123:add(net_25) net:add(concat_123) local net_29 = nn.Sequential() -net_29:add(nn.SpatialConvolution(576, 192, 1, 1, 1, 1)) +net_29:add(nn.SpatialConvolution(576, 192, 1, 1, 1, 1, 0)) net_29:add(nn.ReLU(true)) net_29:add(nn.SpatialConvolution(192, 256, 3, 3, 1, 1, 1, 1)) net_29:add(nn.ReLU(true)) @@ -238,11 +238,11 @@ net_29:add(nn.ReLU(true)) local net_30 = nn.Sequential() net_30:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_30:add(nn.SpatialMaxPooling(3, 3, 1, 1)) +net_30:add(nn.SpatialMaxPooling(3, 3, 1, 1, 0, 0)) local net_31 = nn.Sequential() -net_31:add(nn.SpatialAveragePooling(5, 5, 3, 3)) -net_31:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_31:add(nn.SpatialAveragePooling(5, 5, 3, 3, 0, 0)) +net_31:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_31:add(nn.View()) net_31:add(nn.Linear(2048, 768)) net_31:add(nn.ReLU()) @@ -250,7 +250,7 @@ net_31:add(nn.Linear(768, 4)) net_31:add(nn.LogSoftMax()) local net_32 = nn.Sequential() -net_32:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1)) +net_32:add(nn.SpatialConvolution(576, 128, 1, 1, 1, 1, 0)) net_32:add(nn.ReLU(true)) net_32:add(nn.SpatialConvolution(128, 192, 3, 3, 1, 1, 1, 1)) net_32:add(nn.ReLU(true)) @@ -262,20 +262,20 @@ concat_136:add(net_29) net:add(concat_136) local net_33 = nn.Sequential() -net_33:add(nn.SpatialConvolution(1024, 1024, 2, 2, 2, 2)) +net_33:add(nn.SpatialConvolution(1024, 1024, 2, 2, 2, 2, 0)) local net_34 = nn.Sequential() -net_34:add(nn.SpatialConvolution(1024, 352, 1, 1, 1, 1)) +net_34:add(nn.SpatialConvolution(1024, 352, 1, 1, 1, 1, 0)) net_34:add(nn.ReLU(true)) local net_35 = nn.Sequential() -net_35:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1)) +net_35:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1, 0)) net_35:add(nn.ReLU(true)) net_35:add(nn.SpatialConvolution(192, 320, 3, 3, 1, 1, 1, 1)) net_35:add(nn.ReLU(true)) local net_36 = nn.Sequential() -net_36:add(nn.SpatialConvolution(1024, 160, 1, 1, 1, 1)) +net_36:add(nn.SpatialConvolution(1024, 160, 1, 1, 1, 1, 0)) net_36:add(nn.ReLU(true)) net_36:add(nn.SpatialConvolution(160, 224, 3, 3, 1, 1, 1, 1)) net_36:add(nn.ReLU(true)) @@ -284,8 +284,8 @@ net_36:add(nn.ReLU(true)) local net_37 = nn.Sequential() net_37:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_37:add(nn.SpatialAveragePooling(3, 3, 1, 1)) -net_37:add(nn.SpatialConvolution(1024, 128, 1, 1, 1, 1)) +net_37:add(nn.SpatialAveragePooling(3, 3, 1, 1, 0, 0)) +net_37:add(nn.SpatialConvolution(1024, 128, 1, 1, 1, 1, 0)) net_37:add(nn.ReLU(true)) local concat_154 = nn.Concat(2) @@ -297,17 +297,17 @@ concat_154:add(net_34) net_33:add(concat_154) local net_38 = nn.Sequential() -net_38:add(nn.SpatialConvolution(1024, 352, 1, 1, 1, 1)) +net_38:add(nn.SpatialConvolution(1024, 352, 1, 1, 1, 1, 0)) net_38:add(nn.ReLU(true)) local net_39 = nn.Sequential() -net_39:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1)) +net_39:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1, 0)) net_39:add(nn.ReLU(true)) net_39:add(nn.SpatialConvolution(192, 320, 3, 3, 1, 1, 1, 1)) net_39:add(nn.ReLU(true)) local net_40 = nn.Sequential() -net_40:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1)) +net_40:add(nn.SpatialConvolution(1024, 192, 1, 1, 1, 1, 0)) net_40:add(nn.ReLU(true)) net_40:add(nn.SpatialConvolution(192, 224, 3, 3, 1, 1, 1, 1)) net_40:add(nn.ReLU(true)) @@ -316,8 +316,8 @@ net_40:add(nn.ReLU(true)) local net_41 = nn.Sequential() net_41:add(nn.SpatialZeroPadding(1, 1, 1, 1)) -net_41:add(nn.SpatialMaxPooling(3, 3, 1, 1)) -net_41:add(nn.SpatialConvolution(1024, 128, 1, 1, 1, 1)) +net_41:add(nn.SpatialMaxPooling(3, 3, 1, 1, 0, 0)) +net_41:add(nn.SpatialConvolution(1024, 128, 1, 1, 1, 1, 0)) net_41:add(nn.ReLU(true)) local concat_171 = nn.Concat(2) @@ -327,7 +327,7 @@ concat_171:add(net_39) concat_171:add(net_38) net_33:add(concat_171) -net_33:add(nn.SpatialAveragePooling(7, 7, 1, 1)) +net_33:add(nn.SpatialAveragePooling(7, 7, 1, 1, 0, 0)) net_33:add(nn.View()) net_33:add(nn.Linear(1024, 4)) net_33:add(nn.LogSoftMax()) diff --git a/test/test-cases/generated-code/overfeat.lua b/test/test-cases/generated-code/overfeat.lua index eee5515ea..405379a2c 100644 --- a/test/test-cases/generated-code/overfeat.lua +++ b/test/test-cases/generated-code/overfeat.lua @@ -1,19 +1,19 @@ require 'nn' local net = nn.Sequential() -net:add(nn.SpatialConvolution(3, 96, 11, 11, 4, 4)) +net:add(nn.SpatialConvolution(3, 96, 11, 11, 4, 4, 0)) net:add(nn.ReLU(true)) -net:add(nn.SpatialMaxPooling(2, 2, 2, 2)) -net:add(nn.SpatialConvolution(96, 256, 5, 5, 1, 1)) +net:add(nn.SpatialMaxPooling(2, 2, 2, 2, 0, 0)) +net:add(nn.SpatialConvolution(96, 256, 5, 5, 1, 1, 0)) net:add(nn.ReLU(true)) -net:add(nn.SpatialMaxPooling(2, 2, 2, 2)) +net:add(nn.SpatialMaxPooling(2, 2, 2, 2, 0, 0)) net:add(nn.SpatialConvolution(256, 512, 3, 3, 1, 1, 1, 1)) net:add(nn.ReLU(true)) net:add(nn.SpatialConvolution(512, 1024, 3, 3, 1, 1, 1, 1)) net:add(nn.ReLU(true)) net:add(nn.SpatialConvolution(1024, 1024, 3, 3, 1, 1, 1, 1)) net:add(nn.ReLU(true)) -net:add(nn.SpatialMaxPooling(2, 2, 2, 2)) +net:add(nn.SpatialMaxPooling(2, 2, 2, 2, 0, 0)) net:add(nn.View()) net:add(nn.Dropout(0.5)) net:add(nn.Linear(25600, 3072)) @@ -24,4 +24,4 @@ net:add(nn.Threshold(0, 0.000001)) net:add(nn.Linear(4096, 7)) net:add(nn.LogSoftMax()) -return net +return net \ No newline at end of file diff --git a/test/test-cases/models/alexnetowt.yml b/test/test-cases/models/alexnetowt.yml index 7e126f0e6..b7e9e5547 100644 --- a/test/test-cases/models/alexnetowt.yml +++ b/test/test-cases/models/alexnetowt.yml @@ -1,204 +1,194 @@ -- type: View - id: /a/0 +- type: SpatialConvolution + id: /P/0 next: - - /a/y + - /P/2 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - sizes: 9216 + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 384 + nInputPlane: 192 - type: ReLU - id: /a/3 + id: /P/2 + next: + - /P/fX + attributes: + p: true +- type: Dropout + id: /P/6 next: - - /a/u + - /P/C attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + v1: '' + inplace: '' + p: 0.5 - type: Linear - id: /a/4o + id: /P/8p next: - - /a/L + - /P/S8 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 4096 - input: 9216 + bias: '' + outputSize: 5 + inputSize: 4096 - type: SpatialConvolution - id: /a/9 + id: /P/A next: - - /a/z + - /P/j attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 1 - strideWidth: 1 - kernelHeight: 5 - kernelWidth: 5 + padH: 2 + padW: 2 + dH: 1 + dW: 1 + kH: 5 + kW: 5 nOutputPlane: 192 nInputPlane: 64 -- type: SpatialConvolution - id: /a/C +- type: Linear + id: /P/C next: - - /a/J + - /P/mQ attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 4 - strideWidth: 4 - kernelHeight: 11 - kernelWidth: 11 - nOutputPlane: 64 - nInputPlane: 3 -- type: LogSoftMax - id: /a/E0 - next: [] - attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + bias: '' + outputSize: 4096 + inputSize: 9216 - type: ReLU - id: /a/J + id: /P/F next: - - /a/j + - /P/R attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: ReLU - id: /a/L + p: true +- type: Linear + id: /P/H next: - - /a/l + - /P/e attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: SpatialConvolution - id: /a/U + bias: '' + outputSize: 4096 + inputSize: 4096 +- type: SpatialMaxPooling + id: /P/J next: - - /a/e + - /P/A attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 1 - strideWidth: 1 - kernelHeight: 3 - kernelWidth: 3 - nOutputPlane: 256 - nInputPlane: 384 -- type: ReLU - id: /a/X + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: Dropout + id: /P/L next: - - /a/U + - /P/H attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: ReLU - id: /a/e + v1: '' + inplace: '' + p: 0.5 +- type: View + id: /P/M next: - - /a/q + - /P/6 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: SpatialMaxPooling - id: /a/h + numInputDims: null + params: 9216 +- type: SpatialConvolution + id: /P/R next: - - /a/t + - /P/i attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 2 - strideWidth: 2 - kernelHeight: 3 - kernelWidth: 3 + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 256 +- type: LogSoftMax + id: /P/S8 + next: [] + attributes: {} - type: SpatialMaxPooling - id: /a/j - next: - - /a/9 - attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 2 - strideWidth: 2 - kernelHeight: 3 - kernelWidth: 3 -- type: Dropout - id: /a/l + id: /P/c next: - - /a/o + - /P/0 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - probability: 0.5 -- type: Linear - id: /a/o + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /P/d next: - - /a/r + - /P/q attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 4096 - input: 4096 -- type: Linear - id: /a/p + padH: 2 + padW: 2 + dH: 4 + dW: 4 + kH: 11 + kW: 11 + nOutputPlane: 64 + nInputPlane: 3 +- type: ReLU + id: /P/e next: - - /a/E0 + - /P/8p attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 5 - input: 4096 + p: '' - type: SpatialConvolution - id: /a/q + id: /P/fX next: - - /a/3 + - /P/F attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 1 - strideWidth: 1 - kernelHeight: 3 - kernelWidth: 3 + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 nOutputPlane: 256 - nInputPlane: 256 + nInputPlane: 384 - type: ReLU - id: /a/r + id: /P/i next: - - /a/p + - /P/n5 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: SpatialConvolution - id: /a/t + p: true +- type: ReLU + id: /P/j next: - - /a/X + - /P/c attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 1 - strideWidth: 1 - kernelHeight: 3 - kernelWidth: 3 - nOutputPlane: 384 - nInputPlane: 192 -- type: SpatialMaxPooling - id: /a/u + p: true +- type: ReLU + id: /P/mQ next: - - /a/0 + - /P/L attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 2 - strideWidth: 2 - kernelHeight: 3 - kernelWidth: 3 -- type: Dropout - id: /a/y + p: '' +- type: SpatialMaxPooling + id: /P/n5 next: - - /a/4o + - /P/M attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - probability: 0.5 + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 - type: ReLU - id: /a/z + id: /P/q next: - - /a/h + - /P/J attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + p: true diff --git a/test/test-cases/models/alexnetowtbn.yml b/test/test-cases/models/alexnetowtbn.yml new file mode 100644 index 000000000..8fcf82670 --- /dev/null +++ b/test/test-cases/models/alexnetowtbn.yml @@ -0,0 +1,257 @@ +- type: SpatialConvolution + id: /A/0 + next: + - /A/w + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 384 + nInputPlane: 192 +- type: LogSoftMax + id: /A/2 + next: [] + attributes: {} +- type: ReLU + id: /A/3 + next: + - /A/H + attributes: + p: '' +- type: ReLU + id: /A/6 + next: + - /A/NJ + attributes: + p: true +- type: SpatialMaxPooling + id: /A/7 + next: + - /A/G + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: BatchNormalization + id: /A/A + next: + - /A/r7 + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 4096 +- type: BatchNormalization + id: /A/B + next: + - /A/3 + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 4096 +- type: ReLU + id: /A/F + next: + - /A/q + attributes: + p: true +- type: View + id: /A/G + next: + - /A/a + attributes: + numInputDims: null + params: 9216 +- type: Dropout + id: /A/H + next: + - /A/i + attributes: + v1: '' + inplace: '' + p: 0.5 +- type: SpatialBatchNormalization + id: /A/I + next: + - /A/t + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 192 +- type: Linear + id: /A/M + next: + - /A/B + attributes: + bias: '' + outputSize: 4096 + inputSize: 9216 +- type: SpatialConvolution + id: /A/NJ + next: + - /A/PF + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 256 +- type: SpatialBatchNormalization + id: /A/PF + next: + - /A/X + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 256 +- type: ReLU + id: /A/X + next: + - /A/7 + attributes: + p: true +- type: Dropout + id: /A/a + next: + - /A/M + attributes: + v1: '' + inplace: '' + p: 0.5 +- type: ReLU + id: /A/d + next: + - /A/n + attributes: + p: true +- type: Linear + id: /A/h + next: + - /A/2 + attributes: + bias: '' + outputSize: 10 + inputSize: 4096 +- type: Linear + id: /A/i + next: + - /A/A + attributes: + bias: '' + outputSize: 4096 + inputSize: 4096 +- type: SpatialBatchNormalization + id: /A/k + next: + - /A/6 + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 256 +- type: SpatialBatchNormalization + id: /A/l + next: + - /A/F + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 64 +- type: SpatialConvolution + id: /A/n + next: + - /A/k + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 384 +- type: SpatialMaxPooling + id: /A/nm + next: + - /A/0 + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialMaxPooling + id: /A/q + next: + - /A/y + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /A/r + next: + - /A/l + attributes: + padH: 2 + padW: 2 + dH: 4 + dW: 4 + kH: 11 + kW: 11 + nOutputPlane: 64 + nInputPlane: 3 +- type: ReLU + id: /A/r7 + next: + - /A/h + attributes: + p: '' +- type: ReLU + id: /A/t + next: + - /A/nm + attributes: + p: true +- type: SpatialBatchNormalization + id: /A/w + next: + - /A/d + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 384 +- type: SpatialConvolution + id: /A/y + next: + - /A/I + attributes: + padH: 2 + padW: 2 + dH: 1 + dW: 1 + kH: 5 + kW: 5 + nOutputPlane: 192 + nInputPlane: 64 diff --git a/test/test-cases/models/basic-transfers.yml b/test/test-cases/models/basic-transfers.yml index 3ba18ef2f..76eb14b79 100644 --- a/test/test-cases/models/basic-transfers.yml +++ b/test/test-cases/models/basic-transfers.yml @@ -1,60 +1,76 @@ - type: Reshape - id: 0 + id: /J/1 next: - - 2 + - /J/5 attributes: - dimensions: 100 -- type: SoftMax - id: 1 - next: [] - attributes: {} + params: 100 - type: Linear - id: 2 + id: /J/5 next: - - 5 + - /J/x attributes: - output: 300 -- type: ReLU - id: 3 - next: - - 6 - attributes: {} + bias: '' + outputSize: 300 + inputSize: 100 - type: Sigmoid - id: 4 + id: /J/F next: - - 7 + - /J/z attributes: {} -- type: RReLU - id: 5 +- type: ReLU + id: /J/G next: - - 10 + - /J/q + attributes: + p: '' +- type: SoftMax + id: /J/Y + next: [] attributes: {} -- type: Linear - id: 6 +- type: LeakyReLU + id: /J/c next: - - 4 + - /J/m attributes: - output: 100 + negval: '' + ip: false - type: Linear - id: 7 + id: /J/d next: - - 8 + - /J/G attributes: - output: 120 -- type: LeakyReLU - id: 8 + bias: '' + outputSize: 100 + inputSize: 300 +- type: Linear + id: /J/m next: - - 9 - attributes: {} + - /J/Y + attributes: + bias: '' + outputSize: 5 + inputSize: 120 - type: Linear - id: 9 + id: /J/q + next: + - /J/F + attributes: + bias: '' + outputSize: 100 + inputSize: 100 +- type: RReLU + id: /J/x next: - - 1 + - /J/d attributes: - output: 5 + l: '' + u: '' + ip: false - type: Linear - id: 10 + id: /J/z next: - - 3 + - /J/c attributes: - output: 100 + bias: '' + outputSize: 120 + inputSize: 100 diff --git a/test/test-cases/models/basic.yml b/test/test-cases/models/basic.yml index 845d535c5..e0bb23216 100644 --- a/test/test-cases/models/basic.yml +++ b/test/test-cases/models/basic.yml @@ -1,22 +1,29 @@ -- type: Linear - id: 0 - next: [] +- type: Reshape + id: /x/3 + next: + - /x/K attributes: - output: 10 + params: 100 - type: Linear - id: 1 + id: /x/K next: - - 2 + - /x/e attributes: - output: 300 + bias: '' + outputSize: 300 + inputSize: 100 +- type: Linear + id: /x/N + next: [] + attributes: + bias: '' + outputSize: 10 + inputSize: 300 - type: HardTanh - id: 2 - next: - - 0 - attributes: {} -- type: Reshape - id: 3 + id: /x/e next: - - 1 + - /x/N attributes: - dimensions: 100 + min_value: '' + max_value: 1 + inplace: '' diff --git a/test/test-cases/models/basic2.yml b/test/test-cases/models/basic2.yml index b79685d96..6c8ff85cb 100644 --- a/test/test-cases/models/basic2.yml +++ b/test/test-cases/models/basic2.yml @@ -1,22 +1,26 @@ -- type: Linear - id: 4 - next: - - 7 - attributes: - output: 300 - type: Reshape - id: 5 + id: /Y/0 next: - - 4 + - /Y/y attributes: - dimensions: 100 + params: 100 - type: Linear - id: 6 + id: /Y/Z next: [] attributes: - output: 10 + bias: '' + outputSize: 10 + inputSize: 300 - type: Tanh - id: 7 + id: /Y/p next: - - 6 + - /Y/Z attributes: {} +- type: Linear + id: /Y/y + next: + - /Y/p + attributes: + bias: '' + outputSize: 300 + inputSize: 100 diff --git a/test/test-cases/models/concat-parallel-utils.yml b/test/test-cases/models/concat-parallel-utils.yml new file mode 100644 index 000000000..88fdd368a --- /dev/null +++ b/test/test-cases/models/concat-parallel-utils.yml @@ -0,0 +1,77 @@ +- type: Linear + id: /l/1 + next: + - /l/s + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 50 +- type: Reshape + id: /l/8 + next: + - /l/i + - /l/D + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same + dimensions: 100 +- type: Tanh + id: /l/9 + next: + - /l/k + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /l/D + next: + - /l/9 + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 150 +- type: Tanh + id: /l/X + next: + - /l/a + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /l/a + next: [] + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 7 +- type: Tanh + id: /l/f + next: + - /l/1 + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /l/i + next: + - /l/f + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 150 +- type: Linear + id: /l/k + next: + - /l/s + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 30 +- type: Concat + id: /l/s + next: + - /l/X + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same + dim: 1 diff --git a/test/test-cases/models/concat-parallel.yml b/test/test-cases/models/concat-parallel.yml index 8cb73ca8d..06b84fc77 100644 --- a/test/test-cases/models/concat-parallel.yml +++ b/test/test-cases/models/concat-parallel.yml @@ -1,65 +1,67 @@ -- type: Reshape - id: 1 +- type: Linear + id: /p/H + next: + - /p/V attributes: - dimensions: 100 + bias: '' + outputSize: 150 + inputSize: 100 +- type: Reshape + id: /p/L next: - - 2 - - 3 - -# Left side -- type: Linear - id: 2 + - /p/M + - /p/H attributes: - output: 150 + params: 100 +- type: Linear + id: /p/M next: - - 4 - + - /p/P + attributes: + bias: '' + outputSize: 150 + inputSize: 100 - type: Tanh - id: 4 + id: /p/P next: - - 6 - + - /p/W + attributes: {} - type: Linear - id: 6 - attributes: - output: 50 + id: /p/R next: - - 8 - -# Right side -- type: Linear - id: 3 + - /p/n attributes: - output: 150 - next: - - 5 - + bias: '' + outputSize: 30 + inputSize: 150 - type: Tanh - id: 5 + id: /p/V next: - - 7 - + - /p/R + attributes: {} - type: Linear - id: 7 - attributes: - output: 30 + id: /p/W next: - - 8 - -# Center -- type: Concat - id: 8 + - /p/n + attributes: + bias: '' + outputSize: 50 + inputSize: 150 +- type: Linear + id: /p/Zj + next: [] attributes: - dim: 1 + bias: '' + outputSize: 7 + inputSize: 80 +- type: Concat + id: /p/n next: - - 9 - + - /p/w + attributes: + dimension: 1 - type: Tanh - id: 9 + id: /p/w next: - - 10 - -- type: Linear - id: 10 - attributes: - output: 7 + - /p/Zj + attributes: {} diff --git a/test/test-cases/models/concat-seq.yml b/test/test-cases/models/concat-seq.yml index ab7c732aa..706202fa2 100644 --- a/test/test-cases/models/concat-seq.yml +++ b/test/test-cases/models/concat-seq.yml @@ -1,39 +1,47 @@ +- type: Linear + id: /u/1 + next: + - /u/T + attributes: + bias: '' + outputSize: 30 + inputSize: 150 +- type: Linear + id: /u/2 + next: + - /u/M + attributes: + bias: '' + outputSize: 150 + inputSize: 100 - type: Tanh - id: 8 + id: /u/G next: - - 12 + - /u/1 attributes: {} - type: Tanh - id: 9 + id: /u/M next: - - 14 + - /u/k attributes: {} -- type: Linear - id: 10 - next: - - 8 - attributes: - output: 150 - type: Concat - id: 11 + id: /u/T next: [] attributes: - dim: 1 -- type: Linear - id: 12 - next: - - 11 - attributes: - output: 50 + dimension: 1 - type: Linear - id: 13 + id: /u/k next: - - 9 + - /u/T attributes: - output: 150 + bias: '' + outputSize: 50 + inputSize: 150 - type: Linear - id: 14 + id: /u/q next: - - 11 + - /u/G attributes: - output: 30 + bias: '' + outputSize: 150 + inputSize: 100 diff --git a/test/test-cases/models/concat-y-utils.yml b/test/test-cases/models/concat-y-utils.yml new file mode 100644 index 000000000..17f0daa5c --- /dev/null +++ b/test/test-cases/models/concat-y-utils.yml @@ -0,0 +1,68 @@ +- type: Linear + id: /Z/1 + next: + - /Z/E + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 30 +- type: Tanh + id: /Z/3 + next: + - /Z/a + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /Z/7 + next: + - /Z/o + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 150 +- type: Concat + id: /Z/E + next: + - /Z/M + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same + dim: 1 +- type: Tanh + id: /Z/M + next: + - /Z/n + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /Z/a + next: + - /Z/E + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 50 +- type: Linear + id: /Z/n + next: [] + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 7 +- type: Tanh + id: /Z/o + next: + - /Z/1 + attributes: + calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' + dimensionalityTransform: same +- type: Linear + id: /Z/t + next: + - /Z/3 + attributes: + calculateDimensionality: function calcDims(layer) return layer.output; end + dimensionalityTransform: custom + output: 150 diff --git a/test/test-cases/models/concat-y.yml b/test/test-cases/models/concat-y.yml index 4bfb48b55..1f21fe25e 100644 --- a/test/test-cases/models/concat-y.yml +++ b/test/test-cases/models/concat-y.yml @@ -1,57 +1,60 @@ -# Left side -- type: Linear - id: 2 - attributes: - output: 150 +- type: Tanh + id: /t/5 next: - - 4 - + - /t/H + attributes: {} - type: Tanh - id: 4 + id: /t/D next: - - 6 - + - /t/b + attributes: {} - type: Linear - id: 6 + id: /t/H + next: [] attributes: - output: 50 - next: - - 8 - -# Right side + bias: '' + outputSize: 7 + inputSize: 80 - type: Linear - id: 3 + id: /t/I + next: + - /t/O attributes: - output: 150 + bias: '' + outputSize: 30 + inputSize: 150 +- type: Linear + id: /t/M next: - - 5 - -- type: Tanh - id: 5 + - /t/j + attributes: + bias: '' + outputSize: 150 + inputSize: 100 +- type: Concat + id: /t/O next: - - 7 - -- type: Linear - id: 7 + - /t/5 attributes: - output: 30 + dimension: 1 +- type: Linear + id: /t/b next: - - 8 - -# Center -- type: Concat - id: 8 + - /t/O attributes: - dim: 1 + bias: '' + outputSize: 50 + inputSize: 150 +- type: Linear + id: /t/e next: - - 9 - + - /t/D + attributes: + bias: '' + outputSize: 150 + inputSize: 100 - type: Tanh - id: 9 + id: /t/j next: - - 10 - -- type: Linear - id: 10 - attributes: - output: 7 + - /t/I + attributes: {} diff --git a/test/test-cases/models/concat.yml b/test/test-cases/models/concat.yml index fbaad5d72..8bcc3bd4a 100644 --- a/test/test-cases/models/concat.yml +++ b/test/test-cases/models/concat.yml @@ -1,24 +1,28 @@ -- type: Linear - id: 0 - next: - - 1 - attributes: - output: 3 - type: Concat - id: 1 + id: /T/3 next: [] attributes: - dim: 1 + dimension: 1 +- type: Linear + id: /T/G + next: + - /T/3 + attributes: + bias: '' + outputSize: 7 + inputSize: 5 - type: Linear - id: 2 + id: /T/J next: - - 1 + - /T/3 attributes: - output: 7 + bias: '' + outputSize: 3 + inputSize: 5 - type: Reshape - id: 3 + id: /T/o next: - - 2 - - 0 + - /T/G + - /T/J attributes: - dimensions: 5 + params: 5 diff --git a/test/test-cases/models/googlenet-setters.yml b/test/test-cases/models/googlenet-setters.yml new file mode 100644 index 000000000..b703e572e --- /dev/null +++ b/test/test-cases/models/googlenet-setters.yml @@ -0,0 +1,1765 @@ +- type: SpatialConvolution + id: /D/00 + next: + - /D/Wf + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 576 +- type: View + id: /D/0U + next: + - /D/TU + attributes: + params: 2048 + numInputDims: 3 +- type: ReLU + id: /D/1 + next: + - /D/d + attributes: + p: true +- type: SpatialAveragePooling + id: /D/1L + next: + - /D/UO + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialConvolution + id: /D/1X + next: + - /D/2v + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: ReLU + id: /D/1e + next: + - /D/4Q + attributes: + p: true +- type: SpatialConvolution + id: /D/1u + next: + - /D/v2 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: SpatialConvolution + id: /D/1v + next: + - /D/Ln + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/1y + next: + - /D/H + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: SpatialConvolution + id: /D/2 + next: + - /D/o + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 64 + nInputPlane: 64 +- type: Concat + id: /D/2D + next: + - /D/HF + attributes: + dimension: 2 +- type: SpatialZeroPadding + id: /D/2f + next: + - /D/W5 + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/2v + next: + - /D/Pp + attributes: + p: true +- type: SpatialConvolution + id: /D/32 + next: + - /D/jP + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 352 + nInputPlane: 1024 +- type: SpatialConvolution + id: /D/42 + next: + - /D/nn + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/4N + next: + - /D/42 + - /D/U7 + - /D/s + - /D/ht + attributes: + padW: 0 + padH: '' + dH: 2 + dW: 2 + kH: 2 + kW: 2 + nOutputPlane: 576 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/4Q + next: + - /D/CU + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: SpatialConvolution + id: /D/4l + next: + - /D/ru + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 320 +- type: ReLU + id: /D/4v + next: + - /D/Pu + attributes: + p: true +- type: SpatialZeroPadding + id: /D/50 + next: + - /D/1L + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/5v + next: + - /D/a5 + attributes: + p: true +- type: SpatialZeroPadding + id: /D/6Q + next: + - /D/Sx + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/7 + next: + - /D/u + attributes: + p: true +- type: ReLU + id: /D/7O + next: + - /D/Pp + attributes: + p: true +- type: ReLU + id: /D/8 + next: + - /D/dr + attributes: + p: true +- type: ReLU + id: /D/9 + next: + - /D/C + attributes: + p: true +- type: ReLU + id: /D/9O + next: + - /D/Cn + attributes: + p: true +- type: SpatialZeroPadding + id: /D/9c + next: + - /D/CK + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialConvolution + id: /D/9q + next: + - /D/P3 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 320 + nInputPlane: 192 +- type: SpatialConvolution + id: /D/A + next: + - /D/zo + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: SpatialAveragePooling + id: /D/A3 + next: + - /D/Cf + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialConvolution + id: /D/AW + next: + - /D/DN + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: SpatialConvolution + id: /D/B + next: + - /D/U + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 32 + nInputPlane: 192 +- type: SpatialConvolution + id: /D/C + next: + - /D/1 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialZeroPadding + id: /D/C9 + next: + - /D/W + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialMaxPooling + id: /D/CK + next: + - /D/l9 + attributes: + padW: 0 + padH: 0 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: ReLU + id: /D/CU + next: + - /D/f9 + attributes: + p: true +- type: SpatialConvolution + id: /D/Cf + next: + - /D/uh + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: Concat + id: /D/Cn + next: + - /D/gd + - /D/HO + - /D/2f + - /D/xI + attributes: + dimension: 2 +- type: Concat + id: /D/Co + next: [] + attributes: + dimension: 2 +- type: SpatialConvolution + id: /D/Ct + next: + - /D/bb + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 128 +- type: SpatialConvolution + id: /D/D + next: + - /D/S8 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: SpatialConvolution + id: /D/D2 + next: + - /D/RH + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 320 + nInputPlane: 192 +- type: LogSoftMax + id: /D/DH + next: + - /D/Co + attributes: {} +- type: ReLU + id: /D/DN + next: + - /D/Cn + attributes: + p: true +- type: SpatialConvolution + id: /D/Dx + next: + - /D/Wo + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 128 +- type: SpatialConvolution + id: /D/Ee + next: + - /D/pz + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 320 +- type: SpatialConvolution + id: /D/Eg + next: + - /D/gW + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialMaxPooling + id: /D/F3 + next: + - /D/Q0 + attributes: + padW: 0 + padH: 0 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: ReLU + id: /D/Fa + next: + - /D/my + attributes: + p: true +- type: SpatialConvolution + id: /D/Ff + next: + - /D/4v + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 192 +- type: ReLU + id: /D/GR + next: + - /D/Gg + attributes: + p: true +- type: SpatialConvolution + id: /D/Gb + next: + - /D/Lj + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: ReLU + id: /D/Gc + next: + - /D/M + attributes: + p: true +- type: SpatialConvolution + id: /D/Gg + next: + - /D/a0 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 192 +- type: SpatialConvolution + id: /D/Gs + next: + - /D/0U + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: ReLU + id: /D/H + next: + - /D/A + attributes: + p: true +- type: SpatialAveragePooling + id: /D/HF + next: + - /D/Ky + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 7 + kW: 7 +- type: SpatialConvolution + id: /D/HO + next: + - /D/Lu + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/Hg + next: + - /D/L8 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: SpatialAveragePooling + id: /D/Hz + next: + - /D/Gs + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 3 + dW: 3 + kH: 5 + kW: 5 + ceil_mode: true +- type: SpatialConvolution + id: /D/I + next: + - /D/7 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 64 +- type: ReLU + id: /D/I5 + next: + - /D/AW + attributes: + p: true +- type: SpatialMaxPooling + id: /D/IN + next: + - /D/dt + attributes: + padW: 0 + padH: 0 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: ReLU + id: /D/Ir + next: + - /D/tE + attributes: + p: true +- type: SpatialConvolution + id: /D/JD + next: + - /D/hC + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 192 +- type: ReLU + id: /D/K + next: + - /D/dr + attributes: + p: true +- type: SpatialConvolution + id: /D/K9 + next: + - /D/vO + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 160 +- type: SpatialConvolution + id: /D/KQ + next: + - /D/vt + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialAveragePooling + id: /D/Kr + next: + - /D/so + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: View + id: /D/Ky + next: + - /D/qf + attributes: + params: 1024 + numInputDims: 3 +- type: SpatialConvolution + id: /D/L + next: + - /D/n + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: ReLU + id: /D/L8 + next: + - /D/Eg + attributes: + p: true +- type: ReLU + id: /D/Lj + next: + - /D/1X + attributes: + p: true +- type: ReLU + id: /D/Ln + next: + - /D/Wk + attributes: + p: true +- type: ReLU + id: /D/Lu + next: + - /D/Wk + attributes: + p: true +- type: SpatialConvolution + id: /D/M + next: + - /D/p + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: ReLU + id: /D/M2 + next: + - /D/Ct + attributes: + p: true +- type: SpatialMaxPooling + id: /D/P + next: + - /D/S + attributes: + padW: 0 + padH: 0 + dH: 2 + dW: 2 + kH: 3 + kW: 3 + ceil_mode: true +- type: ReLU + id: /D/P3 + next: + - /D/aT + attributes: + p: true +- type: ReLU + id: /D/Pf + next: + - /D/2D + attributes: + p: true +- type: Concat + id: /D/Pp + next: + - /D/X1 + - /D/oR + - /D/iz + - /D/KQ + attributes: + dimension: 2 +- type: SpatialConvolution + id: /D/Pu + next: + - /D/Pf + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 224 +- type: Concat + id: /D/Q0 + next: + - /D/4N + attributes: + dimension: 2 +- type: SpatialConvolution + id: /D/Qh + next: + - /D/1e + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: ReLU + id: /D/RH + next: + - /D/2D + attributes: + p: true +- type: SpatialConvolution + id: /D/S + next: + - /D/g + attributes: + dW: '' + dH: '' + padW: 0 + padH: '' + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 64 +- type: ReLU + id: /D/S8 + next: + - /D/d + attributes: + p: true +- type: ReLU + id: /D/SY + next: + - /D/Ff + attributes: + p: true +- type: ReLU + id: /D/Sa + next: + - /D/aT + attributes: + p: true +- type: SpatialConvolution + id: /D/Se + next: + - /D/w0 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: SpatialAveragePooling + id: /D/Sx + next: + - /D/z + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialConvolution + id: /D/TE + next: + - /D/GR + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 576 +- type: Linear + id: /D/TU + next: + - /D/ur + attributes: + bias: '' + outputSize: 768 + inputSize: 2048 +- type: ReLU + id: /D/U + next: + - /D/d + attributes: + p: true +- type: SpatialConvolution + id: /D/U7 + next: + - /D/em + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/UO + next: + - /D/Sa + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 1024 +- type: SpatialAveragePooling + id: /D/W + next: + - /D/B + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialAveragePooling + id: /D/W5 + next: + - /D/1v + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: ReLU + id: /D/WL + next: + - /D/Dx + attributes: + p: true +- type: ReLU + id: /D/Wf + next: + - /D/Pp + attributes: + p: true +- type: Concat + id: /D/Wk + next: + - /D/Hz + - /D/cu + - /D/TE + - /D/9c + attributes: + dimension: 2 +- type: ReLU + id: /D/Wo + next: + - /D/cR + attributes: + p: true +- type: SpatialConvolution + id: /D/X + next: + - /D/8 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialConvolution + id: /D/X1 + next: + - /D/I5 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/Y5 + next: + - /D/Gc + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: ReLU + id: /D/Y7 + next: + - /D/cR + attributes: + p: true +- type: SpatialConvolution + id: /D/Z0 + next: + - /D/wf + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: ReLU + id: /D/Z2 + next: + - /D/dr + attributes: + p: true +- type: ReLU + id: /D/a0 + next: + - /D/wd + attributes: + p: true +- type: SpatialConvolution + id: /D/a5 + next: + - /D/9O + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 160 +- type: Concat + id: /D/aT + next: + - /D/32 + - /D/Se + - /D/cM + - /D/tD + attributes: + dimension: 2 +- type: ReLU + id: /D/bb + next: + - /D/l9 + attributes: + p: true +- type: SpatialZeroPadding + id: /D/be + next: + - /D/F3 + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialConvolution + id: /D/bz + next: + - /D/iU + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 128 +- type: ReLU + id: /D/cJ + next: + - /D/aT + attributes: + p: true +- type: SpatialConvolution + id: /D/cM + next: + - /D/SY + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: Concat + id: /D/cR + next: + - /D/Gb + - /D/00 + - /D/uL + - /D/Qh + attributes: + dimension: 2 +- type: SpatialConvolution + id: /D/ct + next: + - /D/WL + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: SpatialConvolution + id: /D/cu + next: + - /D/M2 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: Concat + id: /D/d + next: + - /D/6Q + - /D/1y + - /D/Y5 + - /D/wo + attributes: + dimension: 2 +- type: Concat + id: /D/dr + next: + - /D/be + - /D/Ee + - /D/4l + attributes: + dimension: 2 +- type: SpatialConvolution + id: /D/dt + next: + - /D/lN + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 1024 +- type: SpatialConvolution + id: /D/e + next: + - /D/v + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: ReLU + id: /D/em + next: + - /D/1u + attributes: + p: true +- type: SpatialConvolution + id: /D/f9 + next: + - /D/7O + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 128 +- type: ReLU + id: /D/fn + next: + - /D/bz + attributes: + p: true +- type: ReLU + id: /D/g + next: + - /D/I + attributes: + p: true +- type: ReLU + id: /D/gW + next: + - /D/Q0 + attributes: + p: true +- type: SpatialConvolution + id: /D/gd + next: + - /D/h7 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/gp + next: + - /D/oi + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: ReLU + id: /D/h7 + next: + - /D/K9 + attributes: + p: true +- type: ReLU + id: /D/hC + next: + - /D/Wk + attributes: + p: true +- type: SpatialZeroPadding + id: /D/ht + next: + - /D/sg + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/iU + next: + - /D/Wk + attributes: + p: true +- type: SpatialZeroPadding + id: /D/iz + next: + - /D/Kr + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/jP + next: + - /D/2D + attributes: + p: true +- type: ReLU + id: /D/jq + next: + - /D/aT + attributes: + p: true +- type: SpatialConvolution + id: /D/k + next: + - /D/9 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: Concat + id: /D/l9 + next: + - /D/wC + attributes: + dimension: 2 +- type: ReLU + id: /D/lN + next: + - /D/2D + attributes: + p: true +- type: SpatialConvolution + id: /D/my + next: + - /D/jq + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 224 +- type: ReLU + id: /D/n + next: + - /D/2 + attributes: + p: true +- type: ReLU + id: /D/nn + next: + - /D/ct + attributes: + p: true +- type: ReLU + id: /D/o + next: + - /D/d + attributes: + p: true +- type: SpatialConvolution + id: /D/oR + next: + - /D/yS + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 576 +- type: ReLU + id: /D/oi + next: + - /D/Q0 + attributes: + p: true +- type: ReLU + id: /D/p + next: + - /D/X + attributes: + p: true +- type: ReLU + id: /D/pz + next: + - /D/Hg + attributes: + p: true +- type: Linear + id: /D/qf + next: + - /D/DH + attributes: + bias: '' + outputSize: 1000 + inputSize: 1024 +- type: ReLU + id: /D/qp + next: + - /D/l9 + attributes: + p: true +- type: ReLU + id: /D/ru + next: + - /D/gp + attributes: + p: true +- type: SpatialConvolution + id: /D/s + next: + - /D/Y7 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 224 + nInputPlane: 576 +- type: SpatialAveragePooling + id: /D/sg + next: + - /D/z1 + attributes: + padW: 0 + padH: 0 + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialConvolution + id: /D/so + next: + - /D/y3 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialZeroPadding + id: /D/tD + next: + - /D/IN + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialConvolution + id: /D/tE + next: + - /D/Fa + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 160 +- type: SpatialMaxPooling + id: /D/u + next: + - /D/L + - /D/D + - /D/C9 + - /D/e + attributes: + padW: 0 + padH: 0 + dH: 2 + dW: 2 + kH: 3 + kW: 3 + ceil_mode: true +- type: SpatialZeroPadding + id: /D/uL + next: + - /D/A3 + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /D/uh + next: + - /D/Pp + attributes: + p: true +- type: ReLU + id: /D/ur + next: + - /D/zh + attributes: + p: '' +- type: LogSoftMax + id: /D/ut + next: + - /D/Co + attributes: {} +- type: ReLU + id: /D/v + next: + - /D/k + attributes: + p: true +- type: ReLU + id: /D/v2 + next: + - /D/cR + attributes: + p: true +- type: ReLU + id: /D/vO + next: + - /D/JD + attributes: + p: true +- type: ReLU + id: /D/vt + next: + - /D/wh + attributes: + p: true +- type: SpatialConvolution + id: /D/w + next: + - /D/y + attributes: + padH: 3 + padW: 3 + dH: 2 + dW: 2 + kH: 7 + kW: 7 + nOutputPlane: 64 + nInputPlane: 3 +- type: ReLU + id: /D/w0 + next: + - /D/D2 + attributes: + p: true +- type: SpatialConvolution + id: /D/wC + next: + - /D/xE + - /D/Z0 + - /D/50 + - /D/zb + attributes: + padW: 0 + padH: '' + dH: 2 + dW: 2 + kH: 2 + kW: 2 + nOutputPlane: 1024 + nInputPlane: 1024 +- type: SpatialConvolution + id: /D/wd + next: + - /D/qp + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 256 +- type: ReLU + id: /D/wf + next: + - /D/9q + attributes: + p: true +- type: SpatialConvolution + id: /D/wh + next: + - /D/5v + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: SpatialConvolution + id: /D/wo + next: + - /D/K + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: SpatialConvolution + id: /D/xE + next: + - /D/Ir + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 1024 +- type: SpatialConvolution + id: /D/xI + next: + - /D/fn + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: ReLU + id: /D/y + next: + - /D/P + attributes: + p: true +- type: ReLU + id: /D/y3 + next: + - /D/Cn + attributes: + p: true +- type: ReLU + id: /D/yO + next: + - /D/cR + attributes: + p: true +- type: ReLU + id: /D/yS + next: + - /D/Cn + attributes: + p: true +- type: SpatialConvolution + id: /D/z + next: + - /D/Z2 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: SpatialConvolution + id: /D/z1 + next: + - /D/yO + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialConvolution + id: /D/zb + next: + - /D/cJ + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 352 + nInputPlane: 1024 +- type: Linear + id: /D/zh + next: + - /D/ut + attributes: + bias: '' + outputSize: 1000 + inputSize: 768 +- type: ReLU + id: /D/zo + next: + - /D/dr + attributes: + p: true diff --git a/test/test-cases/models/googlenet.yml b/test/test-cases/models/googlenet.yml new file mode 100644 index 000000000..9a048f7ac --- /dev/null +++ b/test/test-cases/models/googlenet.yml @@ -0,0 +1,1765 @@ +- type: SpatialConvolution + id: /y/0A + next: + - /y/o0 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: SpatialConvolution + id: /y/0J + next: + - /y/4I + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: ReLU + id: /y/14 + next: + - /y/6l + attributes: + p: true +- type: ReLU + id: /y/1C + next: + - /y/s8 + attributes: + p: true +- type: Concat + id: /y/1I + next: + - /y/Rf + - /y/CN + - /y/Uf + - /y/tV + attributes: + dimension: 2 +- type: SpatialMaxPooling + id: /y/1b + next: + - /y/1u + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /y/1u + next: + - /y/Oz + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 1024 +- type: SpatialMaxPooling + id: /y/2 + next: + - /y/d + - /y/g + - /y/U + - /y/H + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /y/2b + next: + - /y/Bf + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/2z + next: + - /y/Uh + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 576 +- type: SpatialZeroPadding + id: /y/3I + next: + - /y/kr + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialAveragePooling + id: /y/3M + next: + - /y/qL + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 3 + dW: 3 + kH: 5 + kW: 5 +- type: SpatialConvolution + id: /y/3h + next: + - /y/lw + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 128 +- type: SpatialConvolution + id: /y/3o + next: + - /y/FM + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 320 + nInputPlane: 192 +- type: SpatialConvolution + id: /y/3s + next: + - /y/14 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/4 + next: + - /y/ST + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: ReLU + id: /y/4I + next: + - /y/6l + attributes: + p: true +- type: Concat + id: /y/4L + next: + - /y/M5 + - /y/jz + - /y/vB + - /y/NN + attributes: + dimension: 2 +- type: SpatialAveragePooling + id: /y/4k + next: + - /y/yH + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 7 + kW: 7 +- type: SpatialConvolution + id: /y/4p + next: + - /y/oL + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 224 + nInputPlane: 576 +- type: ReLU + id: /y/4u + next: + - /y/Tg + attributes: + p: true +- type: ReLU + id: /y/4v + next: + - /y/sp + attributes: + p: true +- type: SpatialConvolution + id: /y/5W + next: + - /y/nj + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 160 +- type: ReLU + id: /y/5e + next: + - /y/ZM + attributes: + p: true +- type: SpatialConvolution + id: /y/5h + next: + - /y/ZD + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: ReLU + id: /y/5i + next: + - /y/ZM + attributes: + p: true +- type: ReLU + id: /y/6 + next: + - /y/b + attributes: + p: true +- type: ReLU + id: /y/60 + next: + - /y/0A + attributes: + p: true +- type: Concat + id: /y/6l + next: + - /y/2z + - /y/x6 + - /y/3M + - /y/2b + attributes: + dimension: 2 +- type: SpatialConvolution + id: /y/7 + next: + - /y/J + attributes: + padH: 3 + padW: 3 + dH: 2 + dW: 2 + kH: 7 + kW: 7 + nOutputPlane: 64 + nInputPlane: 3 +- type: SpatialConvolution + id: /y/78 + next: + - /y/4v + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/7G + next: + - /y/qE + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/7w + next: + - /y/ZE + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 256 +- type: ReLU + id: /y/8 + next: + - /y/4 + attributes: + p: true +- type: SpatialConvolution + id: /y/8y + next: + - /y/Ts + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: ReLU + id: /y/A1 + next: + - /y/Ga + attributes: + p: true +- type: ReLU + id: /y/A7 + next: + - /y/F1 + attributes: + p: true +- type: ReLU + id: /y/AX + next: + - /y/3o + attributes: + p: true +- type: SpatialConvolution + id: /y/Ag + next: + - /y/Tu + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 128 +- type: SpatialConvolution + id: /y/Ar + next: + - /y/qo + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 160 +- type: SpatialConvolution + id: /y/B + next: + - /y/6 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 32 + nInputPlane: 192 +- type: ReLU + id: /y/BS + next: + - /y/s8 + attributes: + p: true +- type: SpatialConvolution + id: /y/BY + next: + - /y/5e + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: ReLU + id: /y/Bf + next: + - /y/3h + attributes: + p: true +- type: ReLU + id: /y/C2 + next: + - /y/Tg + attributes: + p: true +- type: ReLU + id: /y/C9 + next: + - /y/4L + attributes: + p: true +- type: ReLU + id: /y/CA + next: + - /y/Tg + attributes: + p: true +- type: SpatialConvolution + id: /y/CL + next: + - /y/wp + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialZeroPadding + id: /y/CN + next: + - /y/1b + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /y/DZ + next: + - /y/4L + attributes: + p: true +- type: SpatialAveragePooling + id: /y/Db + next: + - /y/3s + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialMaxPooling + id: /y/Dg + next: + - /y/s8 + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /y/Dj + next: + - /y/Ni + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 128 +- type: ReLU + id: /y/E + next: + - /y/ZM + attributes: + p: true +- type: SpatialConvolution + id: /y/F1 + next: + - /y/Fl + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: ReLU + id: /y/FM + next: + - /y/1I + attributes: + p: true +- type: ReLU + id: /y/Fl + next: + - /y/BY + attributes: + p: true +- type: Concat + id: /y/Ga + next: + - /y/0J + - /y/Iu + - /y/7G + - /y/RZ + attributes: + dimension: 2 +- type: ReLU + id: /y/Gh + next: + - /y/OI + attributes: + p: true +- type: SpatialConvolution + id: /y/H + next: + - /y/u + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: ReLU + id: /y/Hi + next: + - /y/7w + attributes: + p: true +- type: View + id: /y/Hr + next: + - /y/q7U + attributes: + numInputDims: null + params: 2048 +- type: ReLU + id: /y/IS + next: + - /y/Ag + attributes: + p: true +- type: ReLU + id: /y/Id + next: + - /y/vj + attributes: + p: true +- type: SpatialZeroPadding + id: /y/Iu + next: + - /y/Db + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /y/J + next: + - /y/x + attributes: + p: true +- type: ReLU + id: /y/Jo + next: + - /y/Rd + attributes: + p: true +- type: ReLU + id: /y/LV + next: + - /y/Ga + attributes: + p: true +- type: SpatialConvolution + id: /y/Lb + next: + - /y/LV + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 160 +- type: ReLU + id: /y/M + next: + - /y/Z + attributes: + p: true +- type: SpatialZeroPadding + id: /y/M5 + next: + - /y/Qj + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: Linear + id: /y/MD + next: + - /y/ZB + attributes: + bias: '' + outputSize: 1000 + inputSize: 768 +- type: Concat + id: /y/N1 + next: + - /y/f + - /y/zT + - /y/3I + - /y/ic + attributes: + dimension: 2 +- type: ReLU + id: /y/NC + next: + - /y/Ga + attributes: + p: true +- type: SpatialConvolution + id: /y/NN + next: + - /y/Id + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: ReLU + id: /y/Ni + next: + - /y/6l + attributes: + p: true +- type: ReLU + id: /y/O + next: + - /y/W + attributes: + p: true +- type: SpatialConvolution + id: /y/OI + next: + - /y/DZ + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 128 +- type: ReLU + id: /y/OV + next: + - /y/Q5 + attributes: + p: true +- type: ReLU + id: /y/Oz + next: + - /y/Tg + attributes: + p: true +- type: ReLU + id: /y/Q + next: + - /y/2 + attributes: + p: true +- type: SpatialConvolution + id: /y/Q5 + next: + - /y/C2 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 320 + nInputPlane: 192 +- type: SpatialAveragePooling + id: /y/Qj + next: + - /y/jN + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: ReLU + id: /y/Ql + next: + - /y/v9 + attributes: + p: true +- type: SpatialConvolution + id: /y/Qq + next: + - /y/gN + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 320 +- type: SpatialConvolution + id: /y/RZ + next: + - /y/oq + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/Rd + next: + - /y/BS + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: SpatialConvolution + id: /y/Rf + next: + - /y/pF + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: SpatialConvolution + id: /y/SD + next: + - /y/y5 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: ReLU + id: /y/ST + next: + - /y/N1 + attributes: + p: true +- type: ReLU + id: /y/T + next: + - /y/b + attributes: + p: true +- type: SpatialAveragePooling + id: /y/T4 + next: + - /y/tA + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: Concat + id: /y/Tg + next: + - /y/4k + attributes: + dimension: 2 +- type: ReLU + id: /y/Ts + next: + - /y/N1 + attributes: + p: true +- type: ReLU + id: /y/Tu + next: + - /y/N1 + attributes: + p: true +- type: SpatialConvolution + id: /y/U + next: + - /y/i + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: SpatialConvolution + id: /y/UZ + next: + - /y/AX + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: SpatialConvolution + id: /y/Uf + next: + - /y/OV + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 1024 +- type: ReLU + id: /y/Uh + next: + - /y/nH + attributes: + p: true +- type: SpatialConvolution + id: /y/VJ + next: + - /y/5i + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: SpatialConvolution + id: /y/W + next: + - /y/n + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: SpatialZeroPadding + id: /y/WD + next: + - /y/Dg + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: LogSoftMax + id: /y/WK + next: + - /y/aS + attributes: {} +- type: ReLU + id: /y/WT + next: + - /y/6l + attributes: + p: true +- type: SpatialConvolution + id: /y/Wb + next: + - /y/WT + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 192 +- type: SpatialMaxPooling + id: /y/Wo + next: + - /y/Ym + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /y/YA + next: + - /y/Ql + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 192 +- type: SpatialConvolution + id: /y/Ya + next: + - /y/rT + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 1024 +- type: Concat + id: /y/Ym + next: + - /y/oH + attributes: + dimension: 2 +- type: SpatialConvolution + id: /y/Z + next: + - /y/u7 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 64 +- type: LogSoftMax + id: /y/ZB + next: + - /y/aS + attributes: {} +- type: ReLU + id: /y/ZD + next: + - /y/Lb + attributes: + p: true +- type: ReLU + id: /y/ZE + next: + - /y/Ym + attributes: + p: true +- type: Concat + id: /y/ZM + next: + - /y/Qq + - /y/WD + - /y/tU + attributes: + dimension: 2 +- type: ReLU + id: /y/a7 + next: + - /y/b + attributes: + p: true +- type: Concat + id: /y/aS + next: [] + attributes: + dimension: 2 +- type: Concat + id: /y/b + next: + - /y/o + - /y/p1 + - /y/ro + - /y/wJ + attributes: + dimension: 2 +- type: SpatialConvolution + id: /y/bN + next: + - /y/1C + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialZeroPadding + id: /y/d + next: + - /y/l + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialZeroPadding + id: /y/d3 + next: + - /y/vN + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialConvolution + id: /y/e + next: + - /y/r + attributes: + dW: '' + dH: '' + padW: 0 + padH: '' + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 64 +- type: SpatialConvolution + id: /y/f + next: + - /y/g1 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/fY + next: + - /y/ty + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 224 +- type: SpatialConvolution + id: /y/fm + next: + - /y/pZ + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 352 + nInputPlane: 1024 +- type: SpatialConvolution + id: /y/g + next: + - /y/O + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 192 +- type: ReLU + id: /y/g1 + next: + - /y/vC + attributes: + p: true +- type: SpatialConvolution + id: /y/gA + next: + - /y/8 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 576 +- type: ReLU + id: /y/gN + next: + - /y/SD + attributes: + p: true +- type: SpatialConvolution + id: /y/h + next: + - /y/Q + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 192 + nInputPlane: 64 +- type: ReLU + id: /y/i + next: + - /y/t + attributes: + p: true +- type: ReLU + id: /y/iV + next: + - /y/MD + attributes: + p: '' +- type: SpatialConvolution + id: /y/ic + next: + - /y/60 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: Linear + id: /y/jC + next: + - /y/WK + attributes: + bias: '' + outputSize: 1000 + inputSize: 1024 +- type: SpatialConvolution + id: /y/jN + next: + - /y/rb + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 576 +- type: ReLU + id: /y/jV + next: + - /y/5h + attributes: + p: true +- type: SpatialConvolution + id: /y/jz + next: + - /y/jV + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: SpatialAveragePooling + id: /y/kr + next: + - /y/CL + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialAveragePooling + id: /y/l + next: + - /y/B + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: ReLU + id: /y/lw + next: + - /y/Ym + attributes: + p: true +- type: ReLU + id: /y/n + next: + - /y/ui + attributes: + p: true +- type: SpatialConvolution + id: /y/nH + next: + - /y/Hi + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 192 +- type: ReLU + id: /y/nj + next: + - /y/fY + attributes: + p: true +- type: SpatialZeroPadding + id: /y/o + next: + - /y/rl + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /y/o0 + next: + - /y/4L + attributes: + p: true +- type: SpatialConvolution + id: /y/oH + next: + - /y/vP + - /y/fm + - /y/UZ + - /y/Ya + attributes: + padW: 0 + padH: '' + dH: 2 + dW: 2 + kH: 2 + kW: 2 + nOutputPlane: 1024 + nInputPlane: 1024 +- type: ReLU + id: /y/oL + next: + - /y/N1 + attributes: + p: true +- type: ReLU + id: /y/oq + next: + - /y/Dj + attributes: + p: true +- type: SpatialConvolution + id: /y/p1 + next: + - /y/A7 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: ReLU + id: /y/pF + next: + - /y/YA + attributes: + p: true +- type: ReLU + id: /y/pZ + next: + - /y/1I + attributes: + p: true +- type: Linear + id: /y/q7U + next: + - /y/iV + attributes: + bias: '' + outputSize: 768 + inputSize: 2048 +- type: ReLU + id: /y/qE + next: + - /y/Ar + attributes: + p: true +- type: SpatialConvolution + id: /y/qL + next: + - /y/Hr + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 576 +- type: ReLU + id: /y/qo + next: + - /y/Wb + attributes: + p: true +- type: ReLU + id: /y/qz + next: + - /y/1I + attributes: + p: true +- type: ReLU + id: /y/r + next: + - /y/h + attributes: + p: true +- type: ReLU + id: /y/rT + next: + - /y/5W + attributes: + p: true +- type: ReLU + id: /y/rb + next: + - /y/Ga + attributes: + p: true +- type: SpatialAveragePooling + id: /y/rl + next: + - /y/VJ + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /y/ro + next: + - /y/E + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: Concat + id: /y/s8 + next: + - /y/wP + attributes: + dimension: 2 +- type: SpatialConvolution + id: /y/sp + next: + - /y/IS + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: SpatialConvolution + id: /y/t + next: + - /y/T + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 64 + nInputPlane: 64 +- type: SpatialConvolution + id: /y/tA + next: + - /y/qz + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 1024 +- type: SpatialConvolution + id: /y/tU + next: + - /y/Jo + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 128 + nInputPlane: 320 +- type: SpatialConvolution + id: /y/tV + next: + - /y/4u + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 352 + nInputPlane: 1024 +- type: ReLU + id: /y/ty + next: + - /y/1I + attributes: + p: true +- type: ReLU + id: /y/u + next: + - /y/b + attributes: + p: true +- type: ReLU + id: /y/u7 + next: + - /y/ZM + attributes: + p: true +- type: SpatialConvolution + id: /y/ui + next: + - /y/a7 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialConvolution + id: /y/v9 + next: + - /y/CA + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 224 + nInputPlane: 224 +- type: SpatialConvolution + id: /y/vB + next: + - /y/NC + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 160 + nInputPlane: 576 +- type: SpatialConvolution + id: /y/vC + next: + - /y/Gh + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 96 +- type: SpatialAveragePooling + id: /y/vN + next: + - /y/8y + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 3 + kW: 3 +- type: SpatialZeroPadding + id: /y/vP + next: + - /y/T4 + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: SpatialConvolution + id: /y/vj + next: + - /y/A1 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 160 + nInputPlane: 128 +- type: SpatialConvolution + id: /y/wJ + next: + - /y/M + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 64 + nInputPlane: 256 +- type: SpatialConvolution + id: /y/wP + next: + - /y/d3 + - /y/78 + - /y/gA + - /y/4p + attributes: + padW: 0 + padH: '' + dH: 2 + dW: 2 + kH: 2 + kW: 2 + nOutputPlane: 576 + nInputPlane: 576 +- type: ReLU + id: /y/wp + next: + - /y/4L + attributes: + p: true +- type: SpatialMaxPooling + id: /y/x + next: + - /y/e + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialZeroPadding + id: /y/x6 + next: + - /y/Wo + attributes: + pad_b: 1 + pad_t: 1 + pad_r: 1 + pad_l: 1 +- type: ReLU + id: /y/y5 + next: + - /y/bN + attributes: + p: true +- type: View + id: /y/yH + next: + - /y/jC + attributes: + numInputDims: null + params: 1024 +- type: SpatialConvolution + id: /y/zT + next: + - /y/C9 + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 192 + nInputPlane: 576 diff --git a/test/test-cases/models/lenet.yml b/test/test-cases/models/lenet.yml index 374374178..5f713a5bf 100644 --- a/test/test-cases/models/lenet.yml +++ b/test/test-cases/models/lenet.yml @@ -1,117 +1,109 @@ -- type: SpatialConvolution - id: /b/1 - next: - - /b/S - attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideWidth: 1 - strideHeight: 1 - kernelHeight: 5 - kernelWidth: 5 - nOutputPlane: 16 - nInputPlane: 6 +- type: LogSoftMax + id: /g/2 + next: [] + attributes: {} - type: View - id: /b/BJ + id: /g/5 next: - - /b/jr + - /g/U attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - sizes: 400 -- type: SpatialMaxPooling - id: /b/E + numInputDims: null + params: 400 +- type: ReLU + id: /g/7 next: - - /b/BJ + - /g/O attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 2 - strideWidth: 2 - kernelHeight: 2 - kernelWidth: 2 + p: '' - type: SpatialMaxPooling - id: /b/G + id: /g/9 next: - - /b/1 + - /g/X attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideHeight: 2 - strideWidth: 2 - kernelHeight: 2 - kernelWidth: 2 -- type: ReLU - id: /b/O + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: Linear + id: /g/E next: - - /b/G + - /g/2 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + bias: '' + outputSize: 10 + inputSize: 84 - type: ReLU - id: /b/S + id: /g/H next: - - /b/E + - /g/9 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + p: '' - type: Linear - id: /b/U + id: /g/O next: - - /b/y + - /g/g attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 10 - input: 84 + bias: '' + outputSize: 84 + inputSize: 120 - type: Linear - id: /b/W + id: /g/U next: - - /b/x + - /g/7 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 84 - input: 120 -- type: ReLU - id: /b/b + bias: '' + outputSize: 120 + inputSize: 400 +- type: SpatialMaxPooling + id: /g/W next: - - /b/W + - /g/5 attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: Linear - id: /b/jr + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialConvolution + id: /g/X next: - - /b/b + - /g/m attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - output: 120 - input: 400 -- type: SpatialConvolution - id: /b/r + dW: '' + dH: '' + padW: 0 + padH: '' + kH: 5 + kW: 5 + nOutputPlane: 16 + nInputPlane: 6 +- type: ReLU + id: /g/g next: - - /b/O + - /g/E attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same - strideWidth: 1 - strideHeight: 1 - kernelHeight: 5 - kernelWidth: 5 - nOutputPlane: 6 - nInputPlane: 3 + p: '' - type: ReLU - id: /b/x + id: /g/m next: - - /b/U + - /g/W attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same -- type: LogSoftMax - id: /b/y - next: [] + p: '' +- type: SpatialConvolution + id: /g/w + next: + - /g/H attributes: - calculateDimensionality: 'function calcDims(layer) return 1; --[[ return output dimensions --]] end' - dimensionalityTransform: same + dW: '' + dH: '' + padW: 0 + padH: '' + kH: 5 + kW: 5 + nOutputPlane: 6 + nInputPlane: 3 diff --git a/test/test-cases/models/ninbn.yml b/test/test-cases/models/ninbn.yml new file mode 100644 index 000000000..edd9c0d14 --- /dev/null +++ b/test/test-cases/models/ninbn.yml @@ -0,0 +1,404 @@ +- type: SpatialBatchNormalization + id: /k/0 + next: + - /k/a + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 96 +- type: ReLU + id: /k/1M + next: + - /k/W + attributes: + p: true +- type: SpatialConvolution + id: /k/3 + next: + - /k/E + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 384 + nInputPlane: 384 +- type: SpatialMaxPooling + id: /k/4 + next: + - /k/x2 + attributes: + ceil_mode: false + padH: 1 + padW: 1 + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialBatchNormalization + id: /k/5 + next: + - /k/q + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 256 +- type: SpatialBatchNormalization + id: /k/7 + next: + - /k/K + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 256 +- type: ReLU + id: /k/7R + next: + - /k/3 + attributes: + p: true +- type: SpatialConvolution + id: /k/8h + next: + - /k/g + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 1024 + nInputPlane: 1024 +- type: ReLU + id: /k/A + next: + - /k/J + attributes: + p: true +- type: SpatialConvolution + id: /k/D + next: + - /k/0 + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialBatchNormalization + id: /k/E + next: + - /k/j + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 384 +- type: LogSoftMax + id: /k/Em + next: [] + attributes: {} +- type: SpatialConvolution + id: /k/G3 + next: + - /k/t + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 384 + nInputPlane: 384 +- type: SpatialConvolution + id: /k/HU + next: + - /k/5 + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 256 + nInputPlane: 256 +- type: SpatialBatchNormalization + id: /k/I + next: + - /k/7R + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 384 +- type: SpatialMaxPooling + id: /k/J + next: + - /k/n + attributes: + ceil_mode: false + padH: 1 + padW: 1 + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialConvolution + id: /k/JG + next: + - /k/7 + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 256 + nInputPlane: 256 +- type: ReLU + id: /k/K + next: + - /k/HU + attributes: + p: true +- type: SpatialBatchNormalization + id: /k/MR + next: + - /k/1M + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 1024 +- type: SpatialBatchNormalization + id: /k/P1 + next: + - /k/k + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 256 +- type: Linear + id: /k/S + next: + - /k/Em + attributes: + bias: '' + outputSize: 1000 + inputSize: 1024 +- type: ReLU + id: /k/TN + next: + - /k/8h + attributes: + p: true +- type: ReLU + id: /k/U + next: + - /k/qr + attributes: + p: true +- type: SpatialMaxPooling + id: /k/V + next: + - /k/b + attributes: + ceil_mode: false + padH: 1 + padW: 1 + dH: 2 + dW: 2 + kH: 3 + kW: 3 +- type: SpatialAveragePooling + id: /k/W + next: + - /k/yv + attributes: + padW: 0 + padH: 0 + ceil_mode: false + count_include_pad: true + dH: 1 + dW: 1 + kH: 7 + kW: 7 +- type: ReLU + id: /k/a + next: + - /k/m + attributes: + p: true +- type: SpatialConvolution + id: /k/b + next: + - /k/I + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 384 + nInputPlane: 256 +- type: SpatialBatchNormalization + id: /k/g + next: + - /k/U + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 1024 +- type: SpatialBatchNormalization + id: /k/h + next: + - /k/o + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 96 +- type: ReLU + id: /k/iT + next: + - /k/4 + attributes: + p: true +- type: ReLU + id: /k/j + next: + - /k/G3 + attributes: + p: true +- type: ReLU + id: /k/k + next: + - /k/JG + attributes: + p: true +- type: SpatialConvolution + id: /k/m + next: + - /k/z + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 96 + nInputPlane: 96 +- type: SpatialConvolution + id: /k/n + next: + - /k/P1 + attributes: + padH: 2 + padW: 2 + dH: 1 + dW: 1 + kH: 5 + kW: 5 + nOutputPlane: 256 + nInputPlane: 96 +- type: ReLU + id: /k/o + next: + - /k/D + attributes: + p: true +- type: SpatialBatchNormalization + id: /k/p + next: + - /k/TN + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 1024 +- type: ReLU + id: /k/q + next: + - /k/V + attributes: + p: true +- type: SpatialConvolution + id: /k/qr + next: + - /k/MR + attributes: + padH: 0 + padW: 0 + dH: 1 + dW: 1 + kH: 1 + kW: 1 + nOutputPlane: 1024 + nInputPlane: 1024 +- type: SpatialBatchNormalization + id: /k/t + next: + - /k/iT + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 384 +- type: SpatialConvolution + id: /k/v + next: + - /k/h + attributes: + padH: 5 + padW: 5 + dH: 4 + dW: 4 + kH: 11 + kW: 11 + nOutputPlane: 96 + nInputPlane: 3 +- type: SpatialConvolution + id: /k/x2 + next: + - /k/p + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 1024 + nInputPlane: 384 +- type: View + id: /k/yv + next: + - /k/S + attributes: + params: -1 + numInputDims: 3 +- type: SpatialBatchNormalization + id: /k/z + next: + - /k/A + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 96 diff --git a/test/test-cases/models/overfeat.yml b/test/test-cases/models/overfeat.yml new file mode 100644 index 000000000..0c7a8aae0 --- /dev/null +++ b/test/test-cases/models/overfeat.yml @@ -0,0 +1,198 @@ +- type: Linear + id: /9/2 + next: + - /9/U + attributes: + bias: '' + outputSize: 4096 + inputSize: 3072 +- type: SpatialMaxPooling + id: /9/3 + next: + - /9/Ae + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialConvolution + id: /9/6 + next: + - /9/p + attributes: + padW: 0 + padH: '' + dH: 4 + dW: 4 + kH: 11 + kW: 11 + nOutputPlane: 96 + nInputPlane: 3 +- type: SpatialConvolution + id: /9/A + next: + - /9/P + attributes: + padW: 0 + padH: '' + dH: 1 + dW: 1 + kH: 5 + kW: 5 + nOutputPlane: 256 + nInputPlane: 96 +- type: Linear + id: /9/AQ + next: + - /9/m + attributes: + bias: '' + outputSize: 7 + inputSize: 4096 +- type: View + id: /9/Ae + next: + - /9/V + attributes: + numInputDims: null + params: 25600 +- type: ReLU + id: /9/F + next: + - /9/3 + attributes: + p: true +- type: SpatialMaxPooling + id: /9/I + next: + - /9/A + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialMaxPooling + id: /9/J + next: + - /9/a + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialConvolution + id: /9/L + next: + - /9/z + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 1024 + nInputPlane: 512 +- type: ReLU + id: /9/P + next: + - /9/J + attributes: + p: true +- type: ReLU + id: /9/Q + next: + - /9/L + attributes: + p: true +- type: Linear + id: /9/T + next: + - /9/UZ + attributes: + bias: '' + outputSize: 3072 + inputSize: 25600 +- type: Threshold + id: /9/U + next: + - /9/AQ + attributes: + ip: '' + v: 0.000001 + th: 0 +- type: Threshold + id: /9/UZ + next: + - /9/zp + attributes: + ip: '' + v: 0.000001 + th: 0 +- type: Dropout + id: /9/V + next: + - /9/T + attributes: + v1: '' + inplace: '' + p: 0.5 +- type: SpatialConvolution + id: /9/a + next: + - /9/Q + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 512 + nInputPlane: 256 +- type: SpatialConvolution + id: /9/l + next: + - /9/F + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 1024 + nInputPlane: 1024 +- type: LogSoftMax + id: /9/m + next: [] + attributes: {} +- type: ReLU + id: /9/p + next: + - /9/I + attributes: + p: true +- type: ReLU + id: /9/z + next: + - /9/l + attributes: + p: true +- type: Dropout + id: /9/zp + next: + - /9/2 + attributes: + v1: '' + inplace: '' + p: 0.5 diff --git a/test/test-cases/models/simple.yml b/test/test-cases/models/simple.yml index bbd877f9b..3c46b3f7d 100644 --- a/test/test-cases/models/simple.yml +++ b/test/test-cases/models/simple.yml @@ -1,11 +1,13 @@ - type: Linear - id: 11 + id: /3/O next: [] attributes: - output: 10 + bias: '' + outputSize: 10 + inputSize: 100 - type: Reshape - id: 12 + id: /3/g next: - - 11 + - /3/O attributes: - dimensions: 100 + params: 100 diff --git a/test/test-cases/models/vgg.yml b/test/test-cases/models/vgg.yml index 69dbe0f4b..45cc1f84b 100644 --- a/test/test-cases/models/vgg.yml +++ b/test/test-cases/models/vgg.yml @@ -1,11 +1,43 @@ -- type: LogSoftMax - id: /Y/19 - next: [] - attributes: {} +- type: ReLU + id: /2/4 + next: + - /2/i + attributes: + p: true +- type: Linear + id: /2/6 + next: + - /2/X + attributes: + bias: '' + outputSize: 10 + inputSize: 4096 +- type: Linear + id: /2/7 + next: + - /2/74 + attributes: + bias: '' + outputSize: 4096 + inputSize: 25088 +- type: Threshold + id: /2/74 + next: + - /2/Yu + attributes: + ip: '' + v: 0.000001 + th: 0 +- type: ReLU + id: /2/9 + next: + - /2/m + attributes: + p: true - type: SpatialConvolution - id: /Y/3 + id: /2/C next: - - /Y/hb + - /2/mo attributes: padH: 1 padW: 1 @@ -14,52 +46,43 @@ kH: 3 kW: 3 nOutputPlane: 512 - nInputPlane: 256 -- type: SpatialConvolution - id: /Y/4 + nInputPlane: 512 +- type: ReLU + id: /2/D next: - - /Y/8 + - /2/k attributes: - padH: 1 - padW: 1 - dH: 1 - dW: 1 - kH: 3 - kW: 3 - nOutputPlane: 64 - nInputPlane: 3 -- type: SpatialMaxPooling - id: /Y/6 + p: true +- type: Linear + id: /2/L next: - - /Y/IL + - /2/j attributes: - padW: '' - padH: '' - dH: 2 - dW: 2 - kH: 2 - kW: 2 + bias: '' + outputSize: 4096 + inputSize: 4096 - type: ReLU - id: /Y/8 + id: /2/M next: - - /Y/l + - /2/C attributes: p: true - type: SpatialMaxPooling - id: /Y/9 + id: /2/O next: - - /Y/K + - /2/u attributes: - padW: '' - padH: '' + padW: 0 + padH: 0 + ceil_mode: false dH: 2 dW: 2 kH: 2 kW: 2 - type: SpatialConvolution - id: /Y/A + id: /2/P next: - - /Y/y + - /2/Z attributes: padH: 1 padW: 1 @@ -67,34 +90,63 @@ dW: 1 kH: 3 kW: 3 - nOutputPlane: 128 - nInputPlane: 64 -- type: Threshold - id: /Y/Cg + nOutputPlane: 512 + nInputPlane: 512 +- type: Dropout + id: /2/U next: - - /Y/z + - /2/6 attributes: - ip: '' - v: 0.000001 - th: 0 -- type: Linear - id: /Y/D + v1: '' + inplace: '' + p: 0.5 +- type: LogSoftMax + id: /2/X + next: [] + attributes: {} +- type: Dropout + id: /2/Yu next: - - /Y/f4 + - /2/L attributes: - bias: '' - outputSize: 4096 - inputSize: 25088 + v1: '' + inplace: '' + p: 0.5 +- type: ReLU + id: /2/Z + next: + - /2/ti + attributes: + p: true +- type: View + id: /2/aW + next: + - /2/7 + attributes: + numInputDims: null + params: 25088 +- type: SpatialMaxPooling + id: /2/d + next: + - /2/q + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 - type: ReLU - id: /Y/EE + id: /2/e next: - - /Y/v + - /2/d attributes: p: true - type: SpatialConvolution - id: /Y/IL + id: /2/g next: - - /Y/EE + - /2/4 attributes: padH: 1 padW: 1 @@ -102,12 +154,12 @@ dW: 1 kH: 3 kW: 3 - nOutputPlane: 512 - nInputPlane: 512 + nOutputPlane: 256 + nInputPlane: 128 - type: SpatialConvolution - id: /Y/K + id: /2/i next: - - /Y/m + - /2/e attributes: padH: 1 padW: 1 @@ -116,105 +168,49 @@ kH: 3 kW: 3 nOutputPlane: 256 - nInputPlane: 128 -- type: SpatialMaxPooling - id: /Y/M - next: - - /Y/a5 - attributes: - padW: '' - padH: '' - dH: 2 - dW: 2 - kH: 2 - kW: 2 -- type: Linear - id: /Y/Q - next: - - /Y/19 - attributes: - bias: '' - outputSize: 10 - inputSize: 4096 -- type: ReLU - id: /Y/R - next: - - /Y/M - attributes: - p: true -- type: ReLU - id: /Y/T - next: - - /Y/6 - attributes: - p: true -- type: Dropout - id: /Y/U7 - next: - - /Y/k - attributes: - v1: '' - inplace: '' - p: 0.5 -- type: View - id: /Y/a5 - next: - - /Y/D - attributes: {} + nInputPlane: 256 - type: Threshold - id: /Y/f4 + id: /2/j next: - - /Y/U7 + - /2/U attributes: ip: '' v: 0.000001 th: 0 -- type: ReLU - id: /Y/h - next: - - /Y/j - attributes: - p: true -- type: ReLU - id: /Y/hb - next: - - /Y/l4 - attributes: - p: true - type: SpatialMaxPooling - id: /Y/j + id: /2/k next: - - /Y/3 + - /2/z attributes: - padW: '' - padH: '' + padW: 0 + padH: 0 + ceil_mode: false dH: 2 dW: 2 kH: 2 kW: 2 -- type: Linear - id: /Y/k - next: - - /Y/Cg - attributes: - bias: '' - outputSize: 4096 - inputSize: 4096 - type: SpatialMaxPooling - id: /Y/l + id: /2/m next: - - /Y/A + - /2/g attributes: - padW: '' - padH: '' + padW: 0 + padH: 0 + ceil_mode: false dH: 2 dW: 2 kH: 2 kW: 2 +- type: ReLU + id: /2/mo + next: + - /2/O + attributes: + p: true - type: SpatialConvolution - id: /Y/l4 + id: /2/q next: - - /Y/T + - /2/M attributes: padH: 1 padW: 1 @@ -223,17 +219,29 @@ kH: 3 kW: 3 nOutputPlane: 512 - nInputPlane: 512 + nInputPlane: 256 - type: ReLU - id: /Y/m + id: /2/s next: - - /Y/x + - /2/P attributes: p: true +- type: SpatialMaxPooling + id: /2/ti + next: + - /2/aW + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 - type: SpatialConvolution - id: /Y/v + id: /2/u next: - - /Y/R + - /2/s attributes: padH: 1 padW: 1 @@ -244,9 +252,9 @@ nOutputPlane: 512 nInputPlane: 512 - type: SpatialConvolution - id: /Y/x + id: /2/w next: - - /Y/h + - /2/D attributes: padH: 1 padW: 1 @@ -254,19 +262,18 @@ dW: 1 kH: 3 kW: 3 - nOutputPlane: 256 - nInputPlane: 256 -- type: ReLU - id: /Y/y - next: - - /Y/9 - attributes: - p: true -- type: Dropout - id: /Y/z + nOutputPlane: 64 + nInputPlane: 3 +- type: SpatialConvolution + id: /2/z next: - - /Y/Q + - /2/9 attributes: - v1: '' - inplace: '' - p: 0.5 + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 64 diff --git a/test/test-cases/models/vggbn.yml b/test/test-cases/models/vggbn.yml new file mode 100644 index 000000000..60b6589f6 --- /dev/null +++ b/test/test-cases/models/vggbn.yml @@ -0,0 +1,297 @@ +- type: Linear + id: /S/1 + next: + - /S/s + attributes: + bias: '' + outputSize: 4096 + inputSize: 4096 +- type: SpatialMaxPooling + id: /S/4 + next: + - /S/fu + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: ReLU + id: /S/7 + next: + - /S/f + attributes: + p: true +- type: Dropout + id: /S/A + next: + - /S/Pt + attributes: + v1: '' + inplace: '' + p: 0.5 +- type: View + id: /S/B + next: + - /S/WQ + attributes: + numInputDims: null + params: 25088 +- type: ReLU + id: /S/C + next: + - /S/w + attributes: + p: true +- type: Threshold + id: /S/Ee + next: + - /S/i + attributes: + ip: '' + v: 0.000001 + th: 0 +- type: SpatialMaxPooling + id: /S/H + next: + - /S/b + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: LogSoftMax + id: /S/Iz + next: [] + attributes: {} +- type: SpatialMaxPooling + id: /S/M + next: + - /S/X + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: BatchNormalization + id: /S/MT + next: + - /S/A + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 4096 +- type: ReLU + id: /S/P + next: + - /S/cJ + attributes: + p: true +- type: ReLU + id: /S/PX + next: + - /S/Z + attributes: + p: true +- type: Linear + id: /S/Pt + next: + - /S/Iz + attributes: + bias: '' + outputSize: 1000 + inputSize: 4096 +- type: SpatialConvolution + id: /S/R + next: + - /S/T + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 128 + nInputPlane: 64 +- type: ReLU + id: /S/T + next: + - /S/M + attributes: + p: true +- type: Linear + id: /S/WQ + next: + - /S/Ee + attributes: + bias: '' + outputSize: 4096 + inputSize: 25088 +- type: SpatialConvolution + id: /S/X + next: + - /S/7 + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 128 +- type: ReLU + id: /S/Y + next: + - /S/t + attributes: + p: true +- type: SpatialConvolution + id: /S/Z + next: + - /S/Y + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 512 + nInputPlane: 512 +- type: SpatialConvolution + id: /S/b + next: + - /S/P + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 512 + nInputPlane: 256 +- type: SpatialConvolution + id: /S/cJ + next: + - /S/e + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 512 + nInputPlane: 512 +- type: ReLU + id: /S/e + next: + - /S/4 + attributes: + p: true +- type: SpatialConvolution + id: /S/f + next: + - /S/y + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 256 + nInputPlane: 256 +- type: SpatialConvolution + id: /S/fu + next: + - /S/PX + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 512 + nInputPlane: 512 +- type: Dropout + id: /S/hr + next: + - /S/1 + attributes: + v1: '' + inplace: '' + p: 0.5 +- type: BatchNormalization + id: /S/i + next: + - /S/hr + attributes: + momentum: '' + affine: '' + eps: 0.001 + nOutput: 4096 +- type: Threshold + id: /S/s + next: + - /S/MT + attributes: + ip: '' + v: 0.000001 + th: 0 +- type: SpatialMaxPooling + id: /S/t + next: + - /S/B + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialMaxPooling + id: /S/w + next: + - /S/R + attributes: + padW: 0 + padH: 0 + ceil_mode: false + dH: 2 + dW: 2 + kH: 2 + kW: 2 +- type: SpatialConvolution + id: /S/x + next: + - /S/C + attributes: + padH: 1 + padW: 1 + dH: 1 + dW: 1 + kH: 3 + kW: 3 + nOutputPlane: 64 + nInputPlane: 3 +- type: ReLU + id: /S/y + next: + - /S/H + attributes: + p: true diff --git a/test/utils/utils.spec.js b/test/utils/utils.spec.js index b74196db8..52b32d9f0 100644 --- a/test/utils/utils.spec.js +++ b/test/utils/utils.spec.js @@ -106,8 +106,8 @@ describe('utils', function () { describe('matching architectures', function() { var cases = [ - ['/l', 'concat-parallel'], - ['/Z', 'concat-y'], + ['/l', 'concat-parallel-utils'], + ['/Z', 'concat-y-utils'], ['/y', 'concat-y-bad-conn'] // disconnected graph ]; @@ -117,9 +117,9 @@ describe('utils', function () { describe('mismatching architectures', function() { var cases = [ - ['/l', 'concat-y'], - ['/y', 'concat-parallel'], - ['/s', 'concat-y'] + ['/l', 'concat-y-utils'], + ['/y', 'concat-parallel-utils'], + ['/s', 'concat-y-utils'] ]; cases.forEach(pair => it('should NOT validate ' + pair[1], diff --git a/utils/nn-parser.js b/utils/nn-parser.js index a0297afc1..5ec800d19 100644 --- a/utils/nn-parser.js +++ b/utils/nn-parser.js @@ -1,60 +1,28 @@ -var fs = require('fs'); -var path = require('path'); -var parser = require('../src/common/lua').parser; -var torchPath = process.env.HOME + '/torch/extra/nn/'; -var SKIP_LAYERS = {}; -var skipLayerList = require('./skipLayers.json'); -skipLayerList.forEach(name => SKIP_LAYERS[name] = true); - -var findInitParams = function(ast){ - // Find '__init' function - var params; - ast.block.stats.forEach(function(block){ - if(block.key && block.key.val == '__init' && block.func){ - params = block.func.args; - if(params.length === 0 && block.func.varargs){ - params[0] = 'params'; - } - } - }); - return params; -}; +var fs = require('fs'), + path = require('path'), + torchPath, -var findTorchClass = function(ast){ - var torchClassArgs, // args for `torch.class(...)` - name = '', - baseType, - params = []; + LayerParser = require(__dirname + '/../src/common/LayerParser'), + SKIP_LAYERS = {}, + skipLayerList = require('./skipLayers.json'), - if(ast.type == 'function'){ - ast.block.stats.forEach(function(func){ - if(func.type == 'stat.local' && func.right && func.right[0] && - func.right[0].func && func.right[0].func.self && - func.right[0].func.self.val == 'torch' && - func.right[0].func.key.val == 'class'){ + categories = require('./categories.json'), + catNames = Object.keys(categories), + exists = require('exists-file'), + configDir = process.env.HOME + '/.deepforge/', + configPath = configDir + 'config.json', + layerToCategory = {}, + config; - torchClassArgs = func.right[0].args.map(arg => arg.val); - name = torchClassArgs[0]; - if(name !== ''){ - name = name.replace('nn.', ''); - params = findInitParams(ast); - if (torchClassArgs.length > 1) { - baseType = torchClassArgs[1].replace('nn.', ''); - } - } - } - }); - } - return { - name, - baseType, - params - }; -}; +// Check the deepforge config +torchPath = process.env.HOME + '/torch'; +if (exists.sync(configPath)) { + config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + torchPath = (config.torch && config.torch.dir) || (configDir + 'torch'); +} +torchPath += '/extra/nn/'; -var categories = require('./categories.json'); -var catNames = Object.keys(categories); -var layerToCategory = {}; +skipLayerList.forEach(name => SKIP_LAYERS[name] = true); catNames.forEach(cat => // create layer -> category dictionary categories[cat].forEach(lname => layerToCategory[lname] = cat) ); @@ -72,15 +40,14 @@ fs.readdir(torchPath, function(err,files){ layerByName = {}; layers = files.filter(filename => path.extname(filename) === '.lua') + //.filter(filename => filename === 'SpatialAveragePooling.lua') .map(filename => fs.readFileSync(torchPath + filename, 'utf8')) - .map(code => parser.parse(code)) - .map(ast => findTorchClass(ast)) // create initial layers + .map(code => LayerParser.parse(code)) .filter(layer => !!layer && layer.name); layers.forEach(layer => { layer.type = lookupType(layer.name); layerByName[layer.name] = layer; - layer.setters = []; }); // handle inheritance