Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2X
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2X
Commits
aac37a40
Commit
aac37a40
authored
Sep 28, 2020
by
Malte Heithoff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CNNArchGenerator now implements the Generator interface
parent
16a10f1e
Pipeline
#335891
canceled with stage
in 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
21 deletions
+36
-21
src/main/java/de/monticore/lang/monticar/cnnarch/generator/CNNArchGenerator.java
...ore/lang/monticar/cnnarch/generator/CNNArchGenerator.java
+36
-21
No files found.
src/main/java/de/monticore/lang/monticar/cnnarch/generator/CNNArchGenerator.java
View file @
aac37a40
...
...
@@ -4,21 +4,25 @@ package de.monticore.lang.monticar.cnnarch.generator;
import
de.monticore.io.paths.ModelPath
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage
;
import
de.monticore.lang.monticar.generator.cmake.CMakeConfig
;
import
de.monticore.lang.monticar.generator.cmake.CMakeFindModule
;
import
de.monticore.lang.monticar.generator.Generator
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
de.monticore.lang.monticar.generator.cpp.GeneratorCPP
;
import
de.monticore.lang.tagging._symboltable.TaggingResolver
;
import
de.monticore.symboltable.GlobalScope
;
import
de.monticore.symboltable.Scope
;
import
de.se_rwth.commons.logging.Log
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Arrays
;
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
LayerSupportChecker
layerSupportChecker
;
...
...
@@ -35,8 +39,14 @@ public abstract class CNNArchGenerator {
System
.
exit
(
1
);
}
public
boolean
isCMakeRequired
()
{
return
true
;
@Override
public
boolean
isGenerateCMake
()
{
return
generateCMake
;
}
@Override
public
void
setGenerateCMake
(
boolean
generateCMake
)
{
this
.
generateCMake
=
generateCMake
;
}
public
String
getGenerationTargetPath
(){
...
...
@@ -58,7 +68,8 @@ public abstract class CNNArchGenerator {
this
.
modelsDirPath
=
modelsDirPath
.
toString
();
final
ModelPath
mp
=
new
ModelPath
(
modelsDirPath
);
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
...
...
@@ -66,9 +77,9 @@ public abstract class CNNArchGenerator {
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
);
ArchitectureSymbol
architectureSymbol
=
symbolCompiler
.
compileArchitectureSymbol
(
scope
,
rootModelName
);
ArchitectureSymbol
architectureSymbol
=
symbolCompiler
.
compileArchitectureSymbol
(
taggingResolver
,
rootModelName
);
try
{
String
dataConfPath
=
getModelsDirPath
()
+
"/data_paths.txt"
;
...
...
@@ -86,37 +97,41 @@ public abstract class CNNArchGenerator {
}
architectureSymbol
.
setWeightsPath
(
weightsPath
);
architectureSymbol
.
setComponentName
(
rootModelName
);
generateFiles
(
architectureSymbol
);
generateFiles
(
taggingResolver
,
architectureSymbol
);
}
catch
(
IOException
e
){
Log
.
error
(
e
.
toString
());
}
}
//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.
public
void
generateFiles
(
ArchitectureSymbol
architecture
)
throws
IOException
{
Map
<
String
,
String
>
fileContentMap
=
generateStrings
(
architecture
);
generateFromFilecontentsMap
(
fileContentMap
);
public
List
<
File
>
generateFiles
(
TaggingResolver
taggingResolver
,
ArchitectureSymbol
architecture
)
throws
IOException
{
List
<
FileContent
>
fileContents
=
generateStrings
(
taggingResolver
,
architecture
);
return
generateFromFilecontentsMap
(
fileContents
);
}
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
();
genCPP
.
setGenerationTargetPath
(
getGenerationTargetPath
());
for
(
String
fileName
:
fileContentMap
.
keySet
())
{
genCPP
.
generateFile
(
new
FileContent
(
fileContentMap
.
get
(
fileName
),
fileName
));
for
(
FileContent
fileContent
:
fileContents
)
{
res
.
add
(
genCPP
.
generateFile
(
fileContent
));
}
return
res
;
}
public
void
generateCMake
(
String
rootModelName
){
Map
<
String
,
String
>
fileContentMap
=
generateCMakeContent
(
rootModelName
);
List
<
FileContent
>
fileContents
=
generateCMakeContent
(
rootModelName
);
try
{
generateFromFilecontentsMap
(
fileContent
Map
);
generateFromFilecontentsMap
(
fileContent
s
);
}
catch
(
IOException
e
)
{
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
);
}
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