diff --git a/demo/lenet_pack.c b/demo/deprecated/lenet_pack.c similarity index 100% rename from demo/lenet_pack.c rename to demo/deprecated/lenet_pack.c diff --git a/demo/lenet_unpack.c b/demo/deprecated/lenet_unpack.c similarity index 100% rename from demo/lenet_unpack.c rename to demo/deprecated/lenet_unpack.c diff --git a/demo/lua2lenet.lua b/demo/deprecated/lua2lenet.lua similarity index 100% rename from demo/lua2lenet.lua rename to demo/deprecated/lua2lenet.lua diff --git a/demo/lua2tinynet.lua b/demo/deprecated/lua2tinynet.lua similarity index 100% rename from demo/lua2tinynet.lua rename to demo/deprecated/lua2tinynet.lua diff --git a/demo/deprecated/lua2vgg16.lua b/demo/deprecated/lua2vgg16.lua new file mode 100644 index 0000000..4ed7e53 --- /dev/null +++ b/demo/deprecated/lua2vgg16.lua @@ -0,0 +1,50 @@ +loadfile("./util/lua2cc.lua")() + +network = { + networkName = "vgg16", + createScope = "vgg16", + parameterLv = 0, + inputLayers = {"in"}, + outputLayers = {"out"}, + l1 = conv2d ({input = "in", + stride = 1, padding = 1}), + l2 = relu ({}), + l3 = conv2d ({stride = 1, padding = 1}), + l4 = relu ({}), + l5 = maxPool2d ({stride = 2}), + l6 = conv2d ({stride = 1, padding = 1}), + l7 = relu ({}), + l8 = conv2d ({stride = 1, padding = 1}), + l9 = relu ({}), + l10 = maxPool2d ({stride = 2}), + l11 = conv2d ({stride = 1, padding = 1}), + l12 = relu ({}), + l13 = conv2d ({stride = 1, padding = 1}), + l14 = relu ({}), + l15 = conv2d ({stride = 1, padding = 1}), + l16 = relu ({}), + l17 = maxPool2d ({stride = 2}), + l18 = conv2d ({stride = 1, padding = 1}), + l19 = relu ({}), + l20 = conv2d ({stride = 1, padding = 1}), + l21 = relu ({}), + l22 = conv2d ({stride = 1, padding = 1}), + l23 = relu ({}), + l24 = maxPool2d ({stride = 2}), + l25 = conv2d ({stride = 1, padding = 1}), + l26 = relu ({}), + l27 = conv2d ({stride = 1, padding = 1}), + l28 = relu ({}), + l29 = conv2d ({stride = 1, padding = 1}), + l30 = relu ({}), + l31 = maxPool2d ({stride = 2}), + l32 = reshape ({shape = {-1, 1, 1}}), + l33 = fullyConnected ({}), + l34 = relu ({}), + l35 = fullyConnected ({}), + l36 = relu ({}), + l37 = fullyConnected ({}), + out = softmax ({input = "l37"}) +} + +ccCodeTranslator(network, {file = "vgg16.c"}) diff --git a/demo/lua2vgg16.lua b/demo/lua2vgg16.lua index 4ed7e53..51cac37 100644 --- a/demo/lua2vgg16.lua +++ b/demo/lua2vgg16.lua @@ -1,50 +1,50 @@ -loadfile("./util/lua2cc.lua")() - -network = { - networkName = "vgg16", - createScope = "vgg16", - parameterLv = 0, - inputLayers = {"in"}, - outputLayers = {"out"}, - l1 = conv2d ({input = "in", - stride = 1, padding = 1}), - l2 = relu ({}), - l3 = conv2d ({stride = 1, padding = 1}), - l4 = relu ({}), - l5 = maxPool2d ({stride = 2}), - l6 = conv2d ({stride = 1, padding = 1}), - l7 = relu ({}), - l8 = conv2d ({stride = 1, padding = 1}), - l9 = relu ({}), - l10 = maxPool2d ({stride = 2}), - l11 = conv2d ({stride = 1, padding = 1}), - l12 = relu ({}), - l13 = conv2d ({stride = 1, padding = 1}), - l14 = relu ({}), - l15 = conv2d ({stride = 1, padding = 1}), - l16 = relu ({}), - l17 = maxPool2d ({stride = 2}), - l18 = conv2d ({stride = 1, padding = 1}), - l19 = relu ({}), - l20 = conv2d ({stride = 1, padding = 1}), - l21 = relu ({}), - l22 = conv2d ({stride = 1, padding = 1}), - l23 = relu ({}), - l24 = maxPool2d ({stride = 2}), - l25 = conv2d ({stride = 1, padding = 1}), - l26 = relu ({}), - l27 = conv2d ({stride = 1, padding = 1}), - l28 = relu ({}), - l29 = conv2d ({stride = 1, padding = 1}), - l30 = relu ({}), - l31 = maxPool2d ({stride = 2}), - l32 = reshape ({shape = {-1, 1, 1}}), - l33 = fullyConnected ({}), - l34 = relu ({}), - l35 = fullyConnected ({}), - l36 = relu ({}), - l37 = fullyConnected ({}), - out = softmax ({input = "l37"}) -} - -ccCodeTranslator(network, {file = "vgg16.c"}) +loadfile("lua2cc.lua")() + +vgg16 = new_context({ + name = "vgg16", + inputs = { + "in" + }, + outputs = { + "out" + } +}) + +features = new_module() +classifier = new_module() + +for i = 1, 2 do + if i == 1 then inp = "#in" else inp = nil end + features:append(fn.conv2d , { input = inp, stride = 1, padding = 1 }) + features:append(fn.relu , { name = "#NULL"}) + features:append(fn.conv2d , { input = nil, stride = 1, padding = 1 }) + features:append(fn.relu , { name = "#NULL"}) + features:append(fn.max_pool2d, { stride = 2 }) +end + +for i = 1, 3 do + if i == 1 then inp = "in" else inp = nil end + features:append(fn.conv2d , { stride = 1, padding = 1 }) + features:append(fn.relu , { name = "#NULL"}) + features:append(fn.conv2d , { stride = 1, padding = 1 }) + features:append(fn.relu , { name = "#NULL"}) + features:append(fn.conv2d , { stride = 1, padding = 1 }) + features:append(fn.relu , { name = "#NULL"}) + features:append(fn.max_pool2d, { stride = 2 }) +end + +classifier:append(fn.reshape, { shape = { -1, 1, 1 } }) -- C * H * W +classifier:append(fn.fully_connected) +classifier:append(fn.relu, { name = "#NULL"}) +classifier:append(fn.fully_connected) +classifier:append(fn.relu, { name = "#NULL"}) +classifier:append(fn.fully_connected) +classifier:append(fn.softmax, { output = "#*out", name = "#NULL"}) + +vgg16.block = "f" -- features +features:impl_on(vgg16) + +vgg16.block = "c" -- classifier +classifier:impl_on(vgg16) + +vgg16:generate() diff --git a/makefile b/makefile index 719383d..7589a59 100644 --- a/makefile +++ b/makefile @@ -111,7 +111,7 @@ util_vec.o util_image.o global_fn_cfg.o CATCOON_A = libcatcoon.a -APPS_DEMO = simple lenet lenet_pack lenet_unpack +APPS_DEMO = simple lenet APPS_UTIL = lspkg mkpkg cclua APP_NAMES = $(APPS_DEMO) $(APPS_UTIL) diff --git a/util/lua2cc.lua b/util/deprecated/lua2cc.lua similarity index 100% rename from util/lua2cc.lua rename to util/deprecated/lua2cc.lua