Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2MXNet
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
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
CNNArch2MXNet
Commits
2ac3a1c5
Commit
2ac3a1c5
authored
Feb 22, 2019
by
Carlos Alfredo Yeverino Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change CNNArchGenerator to an abstract class
parent
20bacfb6
Pipeline
#107037
passed with stages
in 3 minutes and 25 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
70 deletions
+3
-70
pom.xml
pom.xml
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/mxnetgenerator/CNNArch2MxNet.java
...e/lang/monticar/cnnarch/mxnetgenerator/CNNArch2MxNet.java
+2
-69
No files found.
pom.xml
View file @
2ac3a1c5
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<properties>
<properties>
<!-- .. SE-Libraries .................................................. -->
<!-- .. SE-Libraries .................................................. -->
<CNNArch.version>
0.2.
8
</CNNArch.version>
<CNNArch.version>
0.2.
9
</CNNArch.version>
<CNNTrain.version>
0.2.6
</CNNTrain.version>
<CNNTrain.version>
0.2.6
</CNNTrain.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>
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/mxnetgenerator/CNNArch2MxNet.java
View file @
2ac3a1c5
...
@@ -20,32 +20,26 @@
...
@@ -20,32 +20,26 @@
*/
*/
package
de.monticore.lang.monticar.cnnarch.mxnetgenerator
;
package
de.monticore.lang.monticar.cnnarch.mxnetgenerator
;
import
de.monticore.io.paths.ModelPath
;
import
de.monticore.lang.monticar.cnnarch.CNNArchGenerator
;
import
de.monticore.lang.monticar.cnnarch.CNNArchGenerator
;
import
de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos
;
import
de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
de.monticore.lang.monticar.generator.FileContent
;
import
de.monticore.lang.monticar.generator.cmake.CMakeConfig
;
import
de.monticore.lang.monticar.generator.cmake.CMakeConfig
;
import
de.monticore.lang.monticar.generator.cmake.CMakeFindModule
;
import
de.monticore.lang.monticar.generator.cmake.CMakeFindModule
;
import
de.monticore.lang.monticar.generator.cpp.GeneratorCPP
;
import
de.monticore.lang.monticar.generator.cpp.GeneratorCPP
;
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.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.List
;
import
java.util.List
;
public
class
CNNArch2MxNet
implements
CNNArchGenerator
{
public
class
CNNArch2MxNet
extends
CNNArchGenerator
{
private
String
generationTargetPath
;
private
boolean
isSupportedLayer
(
ArchitectureElementSymbol
element
,
LayerSupportChecker
layerChecker
){
private
boolean
isSupportedLayer
(
ArchitectureElementSymbol
element
,
LayerSupportChecker
layerChecker
){
List
<
ArchitectureElementSymbol
>
constructLayerElemList
;
List
<
ArchitectureElementSymbol
>
constructLayerElemList
;
...
@@ -76,37 +70,10 @@ public class CNNArch2MxNet implements CNNArchGenerator {
...
@@ -76,37 +70,10 @@ public class CNNArch2MxNet implements CNNArchGenerator {
return
true
;
return
true
;
}
}
private
static
void
quitGeneration
(){
Log
.
error
(
"Code generation is aborted"
);
System
.
exit
(
1
);
}
public
CNNArch2MxNet
()
{
public
CNNArch2MxNet
()
{
setGenerationTargetPath
(
"./target/generated-sources-cnnarch/"
);
setGenerationTargetPath
(
"./target/generated-sources-cnnarch/"
);
}
}
@Override
public
boolean
isCMakeRequired
()
{
return
true
;
}
public
String
getGenerationTargetPath
()
{
if
(
generationTargetPath
.
charAt
(
generationTargetPath
.
length
()
-
1
)
!=
'/'
)
{
this
.
generationTargetPath
=
generationTargetPath
+
"/"
;
}
return
generationTargetPath
;
}
public
void
setGenerationTargetPath
(
String
generationTargetPath
)
{
this
.
generationTargetPath
=
generationTargetPath
;
}
public
void
generate
(
Path
modelsDirPath
,
String
rootModelName
){
final
ModelPath
mp
=
new
ModelPath
(
modelsDirPath
);
GlobalScope
scope
=
new
GlobalScope
(
mp
,
new
CNNArchLanguage
());
generate
(
scope
,
rootModelName
);
}
public
void
generate
(
Scope
scope
,
String
rootModelName
){
public
void
generate
(
Scope
scope
,
String
rootModelName
){
Optional
<
CNNArchCompilationUnitSymbol
>
compilationUnit
=
scope
.
resolve
(
rootModelName
,
CNNArchCompilationUnitSymbol
.
KIND
);
Optional
<
CNNArchCompilationUnitSymbol
>
compilationUnit
=
scope
.
resolve
(
rootModelName
,
CNNArchCompilationUnitSymbol
.
KIND
);
if
(!
compilationUnit
.
isPresent
()){
if
(!
compilationUnit
.
isPresent
()){
...
@@ -149,41 +116,7 @@ public class CNNArch2MxNet implements CNNArchGenerator {
...
@@ -149,41 +116,7 @@ public class CNNArch2MxNet implements CNNArchGenerator {
return
fileContentMap
;
return
fileContentMap
;
}
}
private
void
checkValidGeneration
(
ArchitectureSymbol
architecture
){
public
void
generateFromFilecontentsMap
(
Map
<
String
,
String
>
fileContentMap
)
throws
IOException
{
if
(
architecture
.
getInputs
().
size
()
>
1
){
Log
.
error
(
"This cnn architecture has multiple inputs, "
+
"which is currently not supported by the mxnetgenerator. "
,
architecture
.
getSourcePosition
());
}
if
(
architecture
.
getOutputs
().
size
()
>
1
){
Log
.
error
(
"This cnn architecture has multiple outputs, "
+
"which is currently not supported by the mxnetgenerator. "
,
architecture
.
getSourcePosition
());
}
if
(
architecture
.
getOutputs
().
get
(
0
).
getDefinition
().
getType
().
getWidth
()
!=
1
||
architecture
.
getOutputs
().
get
(
0
).
getDefinition
().
getType
().
getHeight
()
!=
1
){
Log
.
error
(
"This cnn architecture has a multi-dimensional output, "
+
"which is currently not supported by the mxnetgenerator."
,
architecture
.
getSourcePosition
());
}
}
//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
void
generateCMake
(
String
rootModelName
)
{
Map
<
String
,
String
>
fileContentMap
=
generateCMakeContent
(
rootModelName
);
try
{
generateFromFilecontentsMap
(
fileContentMap
);
}
catch
(
IOException
e
)
{
Log
.
error
(
"CMake file could not be generated"
+
e
.
getMessage
());
}
}
private
void
generateFromFilecontentsMap
(
Map
<
String
,
String
>
fileContentMap
)
throws
IOException
{
GeneratorCPP
genCPP
=
new
GeneratorCPP
();
GeneratorCPP
genCPP
=
new
GeneratorCPP
();
genCPP
.
setGenerationTargetPath
(
getGenerationTargetPath
());
genCPP
.
setGenerationTargetPath
(
getGenerationTargetPath
());
for
(
String
fileName
:
fileContentMap
.
keySet
()){
for
(
String
fileName
:
fileContentMap
.
keySet
()){
...
...
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