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
CNNArch2X
Commits
5ea62176
Commit
5ea62176
authored
Oct 26, 2020
by
Evgeny Kusmenko
Browse files
Merge branch 'master' into 'develop'
Master See merge request
!13
parents
b2dda75a
340e16fd
Pipeline
#348594
passed with stage
in 2 minutes and 33 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
5ea62176
...
@@ -4,6 +4,28 @@ stages:
...
@@ -4,6 +4,28 @@ stages:
#- windows
#- windows
-
linux
-
linux
githubjob
:
image
:
maven:3-jdk-8
stage
:
linux
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y
)'
-
eval $(ssh-agent -s)
-
ssh-add <(echo "$GITHUB_SSH_PRIV_KEY")
-
echo "$GITHUB_SSH_PRIV_KEY" | tr -d '\r' | ssh-add -
-
git config --global user.email "kusmenko@se-rwth.de"
-
git config --global user.name "EMA CI Robot"
-
mkdir -p ~/.ssh
# - cat gitlab-known-hosts >> ~/.ssh/known_hosts
-
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
script
:
-
git clone git@github.com:MontiCore/EmbeddedMontiArc.git
-
cd EmbeddedMontiArc
-
git subtree pull --prefix $PRJ_NAME https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/${PRJ_NAME}.git master --squash
-
git push --force
only
:
-
master
masterJobLinux
:
masterJobLinux
:
stage
:
linux
stage
:
linux
image
:
maven:3-jdk-8
image
:
maven:3-jdk-8
...
@@ -13,6 +35,11 @@ masterJobLinux:
...
@@ -13,6 +35,11 @@ masterJobLinux:
-
mvn package sonar:sonar -s settings.xml
-
mvn package sonar:sonar -s settings.xml
only
:
only
:
-
master
-
master
except
:
changes
:
-
.gitlab-ci.yml
-
.gitignore
-
README.md
#masterJobWindows:
#masterJobWindows:
# stage: windows
# stage: windows
...
...
pom.xml
View file @
5ea62176
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<groupId>
de.monticore.lang.monticar
</groupId>
<groupId>
de.monticore.lang.monticar
</groupId>
<artifactId>
cnnarch-generator
</artifactId>
<artifactId>
cnnarch-generator
</artifactId>
<version>
0.
0.7
-SNAPSHOT
</version>
<version>
0.
4.0
-SNAPSHOT
</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<!-- == PROJECT DEPENDENCIES ============================================= -->
...
@@ -17,13 +17,13 @@
...
@@ -17,13 +17,13 @@
<!-- .. SE-Libraries .................................................. -->
<!-- .. SE-Libraries .................................................. -->
<CNNArch.version>
0.
3.7
-SNAPSHOT
</CNNArch.version>
<CNNArch.version>
0.
4.0
-SNAPSHOT
</CNNArch.version>
<CNNTrain.version>
0.
3.12
-SNAPSHOT
</CNNTrain.version>
<CNNTrain.version>
0.
4.0
-SNAPSHOT
</CNNTrain.version>
<embedded-montiarc-math-
opt-
generator>
0.
1.6
</embedded-montiarc-math-
opt-
generator>
<embedded-montiarc-math-generator>
0.
4.0-SNAPSHOT
</embedded-montiarc-math-generator>
<!-- .. Libraries .................................................. -->
<!-- .. Libraries .................................................. -->
<guava.version>
18.0
</guava.version>
<guava.version>
25.1-jre
</guava.version>
<junit.version>
4.1
2
</junit.version>
<junit.version>
4.1
3.1
</junit.version>
<logback.version>
1.1.2
</logback.version>
<logback.version>
1.1.2
</logback.version>
<jscience.version>
4.3.1
</jscience.version>
<jscience.version>
4.3.1
</jscience.version>
...
@@ -91,8 +91,8 @@
...
@@ -91,8 +91,8 @@
<dependency>
<dependency>
<groupId>
de.monticore.lang.monticar
</groupId>
<groupId>
de.monticore.lang.monticar
</groupId>
<artifactId>
embedded-montiarc-math-
opt-
generator
</artifactId>
<artifactId>
embedded-montiarc-math-generator
</artifactId>
<version>
${embedded-montiarc-math-
opt-
generator}
</version>
<version>
${embedded-montiarc-math-generator}
</version>
</dependency>
</dependency>
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/generator/CNNArchGenerator.java
View file @
5ea62176
...
@@ -4,21 +4,25 @@ package de.monticore.lang.monticar.cnnarch.generator;
...
@@ -4,21 +4,25 @@ package de.monticore.lang.monticar.cnnarch.generator;
import
de.monticore.io.paths.ModelPath
;
import
de.monticore.io.paths.ModelPath
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage
;
import
de.monticore.lang.monticar.generator.cmake.CMakeConfig
;
import
de.monticore.lang.monticar.generator.Generator
;
import
de.monticore.lang.monticar.generator.cmake.CMakeFindModule
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
de.monticore.lang.monticar.generator.cpp.GeneratorCPP
;
import
de.monticore.lang.monticar.generator.cpp.GeneratorCPP
;
import
de.monticore.lang.tagging._symboltable.TaggingResolver
;
import
de.monticore.symboltable.GlobalScope
;
import
de.monticore.symboltable.GlobalScope
;
import
de.monticore.symboltable.Scope
;
import
de.monticore.symboltable.Scope
;
import
de.se_rwth.commons.logging.Log
;
import
de.se_rwth.commons.logging.Log
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.HashMap
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.LinkedList
;
import
java.util.List
;
public
abstract
class
CNNArchGenerator
{
public
abstract
class
CNNArchGenerator
implements
Generator
<
ArchitectureSymbol
>
{
private
boolean
generateCMake
=
false
;
protected
ArchitectureSupportChecker
architectureSupportChecker
;
protected
ArchitectureSupportChecker
architectureSupportChecker
;
protected
LayerSupportChecker
layerSupportChecker
;
protected
LayerSupportChecker
layerSupportChecker
;
...
@@ -35,8 +39,14 @@ public abstract class CNNArchGenerator {
...
@@ -35,8 +39,14 @@ public abstract class CNNArchGenerator {
System
.
exit
(
1
);
System
.
exit
(
1
);
}
}
public
boolean
isCMakeRequired
()
{
@Override
return
true
;
public
boolean
isGenerateCMake
()
{
return
generateCMake
;
}
@Override
public
void
setGenerateCMake
(
boolean
generateCMake
)
{
this
.
generateCMake
=
generateCMake
;
}
}
public
String
getGenerationTargetPath
(){
public
String
getGenerationTargetPath
(){
...
@@ -58,7 +68,8 @@ public abstract class CNNArchGenerator {
...
@@ -58,7 +68,8 @@ public abstract class CNNArchGenerator {
this
.
modelsDirPath
=
modelsDirPath
.
toString
();
this
.
modelsDirPath
=
modelsDirPath
.
toString
();
final
ModelPath
mp
=
new
ModelPath
(
modelsDirPath
);
final
ModelPath
mp
=
new
ModelPath
(
modelsDirPath
);
GlobalScope
scope
=
new
GlobalScope
(
mp
,
new
CNNArchLanguage
());
GlobalScope
scope
=
new
GlobalScope
(
mp
,
new
CNNArchLanguage
());
generate
(
scope
,
rootModelName
);
TaggingResolver
tagging
=
new
TaggingResolver
(
scope
,
Arrays
.
asList
(
rootModelName
));
generate
(
tagging
,
rootModelName
);
}
}
// TODO: Rewrite so that CNNArchSymbolCompiler is used in EMADL2CPP instead of this method
// TODO: Rewrite so that CNNArchSymbolCompiler is used in EMADL2CPP instead of this method
...
@@ -66,9 +77,9 @@ public abstract class CNNArchGenerator {
...
@@ -66,9 +77,9 @@ public abstract class CNNArchGenerator {
return
architectureSupportChecker
.
check
(
architecture
)
&&
layerSupportChecker
.
check
(
architecture
);
return
architectureSupportChecker
.
check
(
architecture
)
&&
layerSupportChecker
.
check
(
architecture
);
}
}
public
void
generate
(
Scope
scope
,
String
rootModelName
){
public
void
generate
(
TaggingResolver
taggingResolver
,
String
rootModelName
){
CNNArchSymbolCompiler
symbolCompiler
=
new
CNNArchSymbolCompiler
(
architectureSupportChecker
,
layerSupportChecker
);
CNNArchSymbolCompiler
symbolCompiler
=
new
CNNArchSymbolCompiler
(
architectureSupportChecker
,
layerSupportChecker
);
ArchitectureSymbol
architectureSymbol
=
symbolCompiler
.
compileArchitectureSymbol
(
scope
,
rootModelName
);
ArchitectureSymbol
architectureSymbol
=
symbolCompiler
.
compileArchitectureSymbol
(
taggingResolver
,
rootModelName
);
try
{
try
{
String
dataConfPath
=
getModelsDirPath
()
+
"/data_paths.txt"
;
String
dataConfPath
=
getModelsDirPath
()
+
"/data_paths.txt"
;
...
@@ -86,37 +97,41 @@ public abstract class CNNArchGenerator {
...
@@ -86,37 +97,41 @@ public abstract class CNNArchGenerator {
}
}
architectureSymbol
.
setWeightsPath
(
weightsPath
);
architectureSymbol
.
setWeightsPath
(
weightsPath
);
architectureSymbol
.
setComponentName
(
rootModelName
);
architectureSymbol
.
setComponentName
(
rootModelName
);
generateFiles
(
architectureSymbol
);
generateFiles
(
taggingResolver
,
architectureSymbol
);
}
catch
(
IOException
e
){
}
catch
(
IOException
e
){
Log
.
error
(
e
.
toString
());
Log
.
error
(
e
.
toString
());
}
}
}
}
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public
abstract
Map
<
String
,
String
>
generateStrings
(
ArchitectureSymbol
architecture
);
public
abstract
List
<
FileContent
>
generateStrings
(
TaggingResolver
taggingResolver
,
ArchitectureSymbol
architecture
);
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public
void
generateFiles
(
ArchitectureSymbol
architecture
)
throws
IOException
{
public
List
<
File
>
generateFiles
(
TaggingResolver
taggingResolver
,
ArchitectureSymbol
architecture
)
throws
IOException
{
Map
<
String
,
String
>
fileContent
Map
=
generateStrings
(
architecture
);
List
<
FileContent
>
fileContent
s
=
generateStrings
(
taggingResolver
,
architecture
);
generateFromFilecontentsMap
(
fileContent
Map
);
return
generateFromFilecontentsMap
(
fileContent
s
);
}
}
public
void
generateFromFilecontentsMap
(
Map
<
String
,
String
>
fileContentMap
)
throws
IOException
{
public
List
<
File
>
generateFromFilecontentsMap
(
List
<
FileContent
>
fileContents
)
throws
IOException
{
List
<
File
>
res
=
new
LinkedList
<>();
GeneratorCPP
genCPP
=
new
GeneratorCPP
();
GeneratorCPP
genCPP
=
new
GeneratorCPP
();
genCPP
.
setGenerationTargetPath
(
getGenerationTargetPath
());
genCPP
.
setGenerationTargetPath
(
getGenerationTargetPath
());
for
(
String
fileName
:
fileContent
Map
.
keySet
())
{
for
(
FileContent
fileContent
:
fileContent
s
)
{
genCPP
.
generateFile
(
new
FileContent
(
fileContentMap
.
get
(
fileName
),
fileName
));
res
.
add
(
genCPP
.
generateFile
(
fileContent
));
}
}
return
res
;
}
}
public
void
generateCMake
(
String
rootModelName
){
public
void
generateCMake
(
String
rootModelName
){
Map
<
String
,
String
>
fileContent
Map
=
generateCMakeContent
(
rootModelName
);
List
<
FileContent
>
fileContent
s
=
generateCMakeContent
(
rootModelName
);
try
{
try
{
generateFromFilecontentsMap
(
fileContent
Map
);
generateFromFilecontentsMap
(
fileContent
s
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
Log
.
error
(
"CMake file could not be generated"
+
e
.
getMessage
());
Log
.
error
(
"CMake file could not be generated"
+
e
.
getMessage
());
}
}
}
}
public
abstract
Map
<
String
,
String
>
generateCMakeContent
(
String
rootModelName
);
public
abstract
List
<
FileContent
>
generateCMakeContent
(
String
rootModelName
);
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/generator/CNNArchTemplateController.java
View file @
5ea62176
...
@@ -4,6 +4,8 @@ package de.monticore.lang.monticar.cnnarch.generator;
...
@@ -4,6 +4,8 @@ package de.monticore.lang.monticar.cnnarch.generator;
import
de.monticore.lang.monticar.cnnarch._symboltable.*
;
import
de.monticore.lang.monticar.cnnarch._symboltable.*
;
import
de.monticore.lang.monticar.cnnarch.predefined.Sigmoid
;
import
de.monticore.lang.monticar.cnnarch.predefined.Sigmoid
;
import
de.monticore.lang.monticar.cnnarch.predefined.Softmax
;
import
de.monticore.lang.monticar.cnnarch.predefined.Softmax
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
org.apache.commons.io.monitor.FileEntry
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.io.Writer
;
...
@@ -198,7 +200,7 @@ public abstract class CNNArchTemplateController {
...
@@ -198,7 +200,7 @@ public abstract class CNNArchTemplateController {
templateConfiguration
.
processTemplate
(
ftlContext
,
templatePath
,
writer
);
templateConfiguration
.
processTemplate
(
ftlContext
,
templatePath
,
writer
);
}
}
public
Map
.
Entry
<
String
,
String
>
process
(
String
templateNameWithoutEnding
,
Target
targetLanguage
){
public
FileContent
process
(
String
templateNameWithoutEnding
,
Target
targetLanguage
){
StringWriter
newWriter
=
new
StringWriter
();
StringWriter
newWriter
=
new
StringWriter
();
this
.
mainTemplateNameWithoutEnding
=
templateNameWithoutEnding
;
this
.
mainTemplateNameWithoutEnding
=
templateNameWithoutEnding
;
this
.
targetLanguage
=
targetLanguage
;
this
.
targetLanguage
=
targetLanguage
;
...
@@ -207,7 +209,7 @@ public abstract class CNNArchTemplateController {
...
@@ -207,7 +209,7 @@ public abstract class CNNArchTemplateController {
include
(
""
,
templateNameWithoutEnding
,
newWriter
);
include
(
""
,
templateNameWithoutEnding
,
newWriter
);
String
fileEnding
=
targetLanguage
.
toString
();
String
fileEnding
=
targetLanguage
.
toString
();
String
fileName
=
getFileNameWithoutEnding
()
+
fileEnding
;
String
fileName
=
getFileNameWithoutEnding
()
+
fileEnding
;
Map
.
Entry
<
String
,
String
>
fileContent
=
new
AbstractMap
.
SimpleEntry
<>(
fileName
,
newWriter
.
toString
());
FileContent
fileContent
=
new
FileContent
(
newWriter
.
toString
()
,
fileName
);
this
.
mainTemplateNameWithoutEnding
=
null
;
this
.
mainTemplateNameWithoutEnding
=
null
;
this
.
targetLanguage
=
null
;
this
.
targetLanguage
=
null
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/generator/CNNTrainGenerator.java
View file @
5ea62176
...
@@ -113,5 +113,5 @@ public abstract class CNNTrainGenerator {
...
@@ -113,5 +113,5 @@ public abstract class CNNTrainGenerator {
public
abstract
void
generate
(
Path
modelsDirPath
,
String
rootModelNames
);
public
abstract
void
generate
(
Path
modelsDirPath
,
String
rootModelNames
);
//check cocos with CNNTrainCocos.checkAll(configuration) before calling this method.
//check cocos with CNNTrainCocos.checkAll(configuration) before calling this method.
public
abstract
Map
<
String
,
String
>
generateStrings
(
ConfigurationSymbol
configuration
);
public
abstract
List
<
FileContent
>
generateStrings
(
ConfigurationSymbol
configuration
);
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/generator/TemplateConfiguration.java
View file @
5ea62176
...
@@ -25,6 +25,10 @@ public abstract class TemplateConfiguration {
...
@@ -25,6 +25,10 @@ public abstract class TemplateConfiguration {
configuration
.
setClassForTemplateLoading
(
TemplateConfiguration
.
class
,
getBaseTemplatePackagePath
());
configuration
.
setClassForTemplateLoading
(
TemplateConfiguration
.
class
,
getBaseTemplatePackagePath
());
configuration
.
setDefaultEncoding
(
"UTF-8"
);
configuration
.
setDefaultEncoding
(
"UTF-8"
);
configuration
.
setTemplateExceptionHandler
(
TemplateExceptionHandler
.
RETHROW_HANDLER
);
configuration
.
setTemplateExceptionHandler
(
TemplateExceptionHandler
.
RETHROW_HANDLER
);
// numbers in windows germany are formatted as '0,2' instead of '0.2'
configuration
.
setNumberFormat
(
"computer"
);
return
configuration
;
return
configuration
;
}
}
...
...
Write
Preview
Supports
Markdown
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