Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Caffe2
Commits
104949c3
Commit
104949c3
authored
Dec 06, 2019
by
Evgeny Kusmenko
Browse files
Merge branch 'develop' into 'master'
Adjustments for BLEU eval_metric. Updated dependencies See merge request
!42
parents
93d0199d
5af5df86
Pipeline
#215570
passed with stages
in 6 minutes and 8 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
104949c3
...
@@ -9,16 +9,16 @@
...
@@ -9,16 +9,16 @@
<groupId>
de.monticore.lang.monticar
</groupId>
<groupId>
de.monticore.lang.monticar
</groupId>
<artifactId>
cnnarch-caffe2-generator
</artifactId>
<artifactId>
cnnarch-caffe2-generator
</artifactId>
<version>
0.2.1
3
-SNAPSHOT
</version>
<version>
0.2.1
4
-SNAPSHOT
</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<properties>
<!-- .. SE-Libraries .................................................. -->
<!-- .. SE-Libraries .................................................. -->
<CNNArch.version>
0.3.
2
-SNAPSHOT
</CNNArch.version>
<CNNArch.version>
0.3.
4
-SNAPSHOT
</CNNArch.version>
<CNNTrain.version>
0.3.
6
-SNAPSHOT
</CNNTrain.version>
<CNNTrain.version>
0.3.
9
-SNAPSHOT
</CNNTrain.version>
<CNNArch2X.version>
0.0.
3
-SNAPSHOT
</CNNArch2X.version>
<CNNArch2X.version>
0.0.
5
-SNAPSHOT
</CNNArch2X.version>
<embedded-montiarc-math-opt-generator>
0.1.4
</embedded-montiarc-math-opt-generator>
<embedded-montiarc-math-opt-generator>
0.1.4
</embedded-montiarc-math-opt-generator>
<!-- .. Libraries .................................................. -->
<!-- .. Libraries .................................................. -->
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java
View file @
104949c3
...
@@ -141,7 +141,7 @@ public class CNNArchTemplateController {
...
@@ -141,7 +141,7 @@ public class CNNArchTemplateController {
include
(
TEMPLATE_ELEMENTS_DIR_PATH
,
"Output"
,
writer
);
include
(
TEMPLATE_ELEMENTS_DIR_PATH
,
"Output"
,
writer
);
}
}
}
else
{
}
else
{
include
(
element
.
getResolvedThis
().
get
(),
writer
);
include
(
(
ArchitectureElementSymbol
)
element
.
getResolvedThis
().
get
(),
writer
);
}
}
setCurrentElement
(
previousElement
);
setCurrentElement
(
previousElement
);
...
@@ -158,7 +158,7 @@ public class CNNArchTemplateController {
...
@@ -158,7 +158,7 @@ public class CNNArchTemplateController {
include
(
TEMPLATE_ELEMENTS_DIR_PATH
,
templateName
,
writer
);
include
(
TEMPLATE_ELEMENTS_DIR_PATH
,
templateName
,
writer
);
}
}
}
else
{
}
else
{
include
(
layer
.
getResolvedThis
().
get
(),
writer
);
include
(
(
ArchitectureElementSymbol
)
layer
.
getResolvedThis
().
get
(),
writer
);
}
}
setCurrentElement
(
previousElement
);
setCurrentElement
(
previousElement
);
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/ConfigurationData.java
View file @
104949c3
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
package
de.monticore.lang.monticar.cnnarch.caffe2generator
;
package
de.monticore.lang.monticar.cnnarch.caffe2generator
;
import
de.monticore.lang.monticar.cnntrain._symboltable.*
;
import
de.monticore.lang.monticar.cnntrain._symboltable.*
;
import
static
de
.
monticore
.
lang
.
monticar
.
cnntrain
.
helper
.
ConfigEntryNameConstants
.*;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -61,11 +62,8 @@ public class ConfigurationData {
...
@@ -61,11 +62,8 @@ public class ConfigurationData {
return
getConfiguration
().
getEntry
(
"context"
).
getValue
().
toString
();
return
getConfiguration
().
getEntry
(
"context"
).
getValue
().
toString
();
}
}
public
String
getEvalMetric
()
{
public
Map
<
String
,
Object
>
getEvalMetric
()
{
if
(!
getConfiguration
().
getEntryMap
().
containsKey
(
"eval_metric"
))
{
return
getMultiParamEntry
(
EVAL_METRIC
,
"name"
);
return
null
;
}
return
getConfiguration
().
getEntry
(
"eval_metric"
).
getValue
().
toString
();
}
}
public
String
getLoss
()
{
public
String
getLoss
()
{
...
@@ -104,4 +102,29 @@ public class ConfigurationData {
...
@@ -104,4 +102,29 @@ public class ConfigurationData {
}
}
return
mapToStrings
;
return
mapToStrings
;
}
}
protected
Map
<
String
,
Object
>
getMultiParamEntry
(
final
String
key
,
final
String
valueName
)
{
if
(!
configurationContainsKey
(
key
))
{
return
null
;
}
Map
<
String
,
Object
>
resultView
=
new
HashMap
<>();
ValueSymbol
value
=
this
.
getConfiguration
().
getEntryMap
().
get
(
key
).
getValue
();
if
(
value
instanceof
MultiParamValueSymbol
)
{
MultiParamValueSymbol
multiParamValue
=
(
MultiParamValueSymbol
)
value
;
resultView
.
put
(
valueName
,
multiParamValue
.
getValue
());
resultView
.
putAll
(
multiParamValue
.
getParameters
());
}
else
{
resultView
.
put
(
valueName
,
value
.
getValue
());
}
return
resultView
;
}
protected
Boolean
configurationContainsKey
(
final
String
key
)
{
return
this
.
getConfiguration
().
getEntryMap
().
containsKey
(
key
);
}
}
}
src/main/resources/templates/caffe2/CNNTrainer.ftl
View file @
104949c3
...
@@ -28,7 +28,7 @@ if __name__ == "__main__":
...
@@ -28,7 +28,7 @@ if __name__ == "__main__":
context='${config.context}',
context='${config.context}',
</#if>
</#if>
<#if (config.evalMetric)??>
<#if (config.evalMetric)??>
eval_metric='${config.evalMetric}',
eval_metric='${config.evalMetric
.name
}',
</#if>
</#if>
<#if (config.loss)??>
<#if (config.loss)??>
loss='${config.loss}',
loss='${config.loss}',
...
...
src/test/resources/target_code/CMakeLists.txt
View file @
104949c3
#(c) https://github.com/MontiCore/monticore
cmake_minimum_required
(
VERSION 3.5
)
cmake_minimum_required
(
VERSION 3.5
)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
CMAKE_CXX_STANDARD 14
)
...
...
src/test/resources/target_code/CNNCreator_LeNet.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
@@ -92,6 +91,7 @@ class CNNCreator_LeNet:
...
@@ -92,6 +91,7 @@ class CNNCreator_LeNet:
return
predictions_
return
predictions_
# this adds the loss and optimizer
# this adds the loss and optimizer
def
add_training_operators
(
self
,
model
,
output
,
label
,
device_opts
,
loss
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
:
def
add_training_operators
(
self
,
model
,
output
,
label
,
device_opts
,
loss
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
:
with
core
.
DeviceScope
(
device_opts
):
with
core
.
DeviceScope
(
device_opts
):
...
...
src/test/resources/target_code/CNNCreator_VGG16.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
@@ -138,6 +137,7 @@ class CNNCreator_VGG16:
...
@@ -138,6 +137,7 @@ class CNNCreator_VGG16:
return
predictions_
return
predictions_
# this adds the loss and optimizer
# this adds the loss and optimizer
def
add_training_operators
(
self
,
model
,
output
,
label
,
device_opts
,
loss
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
:
def
add_training_operators
(
self
,
model
,
output
,
label
,
device_opts
,
loss
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
:
with
core
.
DeviceScope
(
device_opts
):
with
core
.
DeviceScope
(
device_opts
):
...
...
src/test/resources/target_code/CNNPredictor_LeNet.h
View file @
104949c3
/* (c) https://github.com/MontiCore/monticore */
#ifndef CNNPREDICTOR_LENET
#ifndef CNNPREDICTOR_LENET
#define CNNPREDICTOR_LENET
#define CNNPREDICTOR_LENET
...
...
src/test/resources/target_code/CNNPredictor_VGG16.h
View file @
104949c3
/* (c) https://github.com/MontiCore/monticore */
#ifndef CNNPREDICTOR_VGG16
#ifndef CNNPREDICTOR_VGG16
#define CNNPREDICTOR_VGG16
#define CNNPREDICTOR_VGG16
...
...
src/test/resources/target_code/CNNTrainer_emptyConfig.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
...
src/test/resources/target_code/CNNTrainer_fullConfig.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
...
src/test/resources/target_code/CNNTrainer_simpleConfig.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
...
src/test/resources/target_code/CNNTrainer_unsupportedConfig.py
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python
import
workspace
,
core
,
model_helper
,
brew
,
optimizer
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.python.predictor
import
mobile_exporter
from
caffe2.proto
import
caffe2_pb2
from
caffe2.proto
import
caffe2_pb2
...
...
src/test/resources/target_code/cmake/FindArmadillo.cmake
View file @
104949c3
# (c) https://github.com/MontiCore/monticore
# Automatically generated file
# Automatically generated file
#
#
# - Try to find Armadillo
# - Try to find Armadillo
...
@@ -36,4 +35,4 @@ mark_as_advanced(
...
@@ -36,4 +35,4 @@ mark_as_advanced(
)
)
set
(
Armadillo_INCLUDE_DIRS
${
Armadillo_INCLUDE_DIR
}
)
set
(
Armadillo_INCLUDE_DIRS
${
Armadillo_INCLUDE_DIR
}
)
set
(
Armadillo_LIBRARIES
${
Armadillo_LIBRARY
}
)
set
(
Armadillo_LIBRARIES
${
Armadillo_LIBRARY
}
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment