Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Gluon
Commits
0208cace
Commit
0208cace
authored
Feb 22, 2019
by
Carlos Alfredo Yeverino Rodriguez
Browse files
Merge branch 'unsupported_layer_check' into 'master'
added layer support checker See merge request
!2
parents
f9a53bef
391092bd
Pipeline
#107061
passed with stages
in 4 minutes and 31 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/cnnarch/gluongenerator/CNNArch2Gluon.java
View file @
0208cace
...
...
@@ -24,6 +24,9 @@ import de.monticore.io.paths.ModelPath;
import
de.monticore.lang.monticar.cnnarch.CNNArchGenerator
;
import
de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.IOSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage
;
import
de.monticore.lang.monticar.generator.FileContent
;
...
...
@@ -39,11 +42,39 @@ import java.nio.file.Path;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.List
;
public
class
CNNArch2Gluon
implements
CNNArchGenerator
{
private
String
generationTargetPath
;
private
boolean
isSupportedLayer
(
ArchitectureElementSymbol
element
,
LayerSupportChecker
layerChecker
){
List
<
ArchitectureElementSymbol
>
constructLayerElemList
;
if
(!(
element
instanceof
IOSymbol
)
&&
(
element
.
getResolvedThis
().
get
()
instanceof
CompositeElementSymbol
))
{
constructLayerElemList
=
((
CompositeElementSymbol
)
element
.
getResolvedThis
().
get
()).
getElements
();
for
(
ArchitectureElementSymbol
constructedLayerElement
:
constructLayerElemList
)
{
if
(!
isSupportedLayer
(
constructedLayerElement
,
layerChecker
))
return
false
;
}
}
if
(!
layerChecker
.
isSupported
(
element
.
toString
()))
{
Log
.
error
(
"Unsupported layer "
+
"'"
+
element
.
getName
()
+
"'"
+
" for the backend MXNET."
);
return
false
;
}
else
{
return
true
;
}
}
private
boolean
supportCheck
(
ArchitectureSymbol
architecture
){
LayerSupportChecker
layerChecker
=
new
LayerSupportChecker
();
for
(
ArchitectureElementSymbol
element
:
((
CompositeElementSymbol
)
architecture
.
getBody
()).
getElements
()){
if
(!
isSupportedLayer
(
element
,
layerChecker
))
return
false
;
}
return
true
;
}
public
CNNArch2Gluon
()
{
setGenerationTargetPath
(
"./target/generated-sources-cnnarch/"
);
}
...
...
@@ -78,6 +109,10 @@ public class CNNArch2Gluon implements CNNArchGenerator {
}
CNNArchCocos
.
checkAll
(
compilationUnit
.
get
());
if
(!
supportCheck
(
compilationUnit
.
get
().
getArchitecture
())){
Log
.
error
(
"Code generation aborted."
);
System
.
exit
(
1
);
}
try
{
generateFiles
(
compilationUnit
.
get
().
getArchitecture
());
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/gluongenerator/LayerSupportChecker.java
0 → 100644
View file @
0208cace
package
de.monticore.lang.monticar.cnnarch.gluongenerator
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
LayerSupportChecker
{
private
List
<
String
>
unsupportedLayerList
=
new
ArrayList
();
public
LayerSupportChecker
()
{
//Set the unsupported layers for the backend
//this.unsupportedLayerList.add(PREDEFINED_LAYER_NAME);
}
public
boolean
isSupported
(
String
element
)
{
return
!
this
.
unsupportedLayerList
.
contains
(
element
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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