Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
i-evi committed Nov 11, 2020
1 parent 7578887 commit 40dba4e
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 51 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions demo/deprecated/lua2vgg16.lua
Original file line number Diff line number Diff line change
@@ -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"})
100 changes: 50 additions & 50 deletions demo/lua2vgg16.lua
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.

0 comments on commit 40dba4e

Please sign in to comment.