Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
monticore
EmbeddedMontiArc
languages
CNNArchLang
Commits
e16a54a9
Commit
e16a54a9
authored
Nov 01, 2017
by
Thomas Michael Timmermanns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added symbolTableCreator
parent
40f76601
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
22 deletions
+102
-22
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
+20
-17
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTArgumentRhs.java
.../monticore/lang/monticar/cnnarch/_ast/ASTArgumentRhs.java
+3
-3
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTMethod.java
...va/de/monticore/lang/monticar/cnnarch/_ast/ASTMethod.java
+2
-2
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/CNNArchSymbolTableCreator.java
...ticar/cnnarch/_symboltable/CNNArchSymbolTableCreator.java
+77
-0
No files found.
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
View file @
e16a54a9
...
...
@@ -2,14 +2,17 @@ package de.monticore.lang.monticar;
grammar
CNNArch
extends
de
.
monticore
.
common
.
Common
{
CNNArchCompilationUnit
=
Architecture
;
symbol
scope
Architecture
=
"architecture"
name
:
Name
&
"("
inputPort
:
Name
&
")"
"{"
Name
&
"{"
(
MainLayer
)+
outputPort
:
Name
&
"="
OutputLayer
"}"
;
//
InputPort
=
Name
"-->"
;
//
OutputPort
=
"-->"
Name
;
interface
Layer
;
ast
Layer
=
method
ASTMethod
getMethod
(){};
interface
Method
;
...
...
@@ -18,9 +21,9 @@ grammar CNNArch extends de.monticore.common.Common {
interface
ArgumentAssignment
;
ast
ArgumentAssignment
=
method
public
Enum
getLhs
(){}
method
public
ASTRhs
getRhs
(){};
method
public
AST
Argument
Rhs
getRhs
(){};
Rhs
=
stringVal
:
String
Argument
Rhs
=
stringVal
:
String
|
intVal
:
Num_Int
|
doubleVal
:
Num_Double
|
intTuple
:
IntTuple
...
...
@@ -35,7 +38,7 @@ grammar CNNArch extends de.monticore.common.Common {
ConvolutionMethod
implements
MainLayerMethod
=
name
:
"Convolution"
"("
arguments
:(
ConvolutionArgumentAssignment
||
","
)*
")"
;
ConvolutionArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
ConvolutionArgument
"="
rhs
:
Rhs
;
ConvolutionArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
ConvolutionArgument
"="
rhs
:
Argument
Rhs
;
enum
ConvolutionArgument
=
KERNEL
:
"kernel"
//
required
|
NUMFILTER
:
"num_filter"
//
required
|
STRIDE
:
"stride"
...
...
@@ -43,16 +46,16 @@ grammar CNNArch extends de.monticore.common.Common {
|
NOBIAS
:
"no_bias"
;
FullyConnectedMethod
implements
MainLayerMethod
=
name
:
"FullyConnected"
"("
arguments
:(
FullyConnectedArgumentAssignment
||
","
)*
")"
;
FullyConnectedArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
FullyConnectedArgument
"="
rhs
:
Rhs
;
FullyConnectedArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
FullyConnectedArgument
"="
rhs
:
Argument
Rhs
;
enum
FullyConnectedArgument
=
NUMHIDDEN
:
"num_hidden"
//
required
|
NOBIAS
:
"no_bias"
;
ActivationMethod
implements
MainLayerMethod
=
name
:
"Activation"
"("
arguments
:(
ActivationArgumentAssignment
||
","
)*
")"
;
ActivationArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
ActivationArgument
"="
rhs
:
Rhs
;
ActivationArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
ActivationArgument
"="
rhs
:
Argument
Rhs
;
enum
ActivationArgument
=
ACTTYPE
:
"act_type"
;
//
required
PoolingMethod
implements
MainLayerMethod
=
name
:
"Pooling"
"("
arguments
:(
PoolingArgumentAssignment
||
","
)*
")"
;
PoolingArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
PoolingArgument
"="
rhs
:
Rhs
;
PoolingArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
PoolingArgument
"="
rhs
:
Argument
Rhs
;
enum
PoolingArgument
=
KERNEL
:
"kernel"
//
required
|
POOLTYPE
:
"pool_type"
//
required
|
POOLINGCONVENTION
:
"pooling_convention"
...
...
@@ -60,12 +63,12 @@ grammar CNNArch extends de.monticore.common.Common {
|
PAD
:
"pad"
;
DropoutMethod
implements
MainLayerMethod
=
name
:
"Dropout"
"("
arguments
:(
DropoutArgumentAssignment
||
","
)*
")"
;
DropoutArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
DropoutArgument
"="
rhs
:
Rhs
;
DropoutArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
DropoutArgument
"="
rhs
:
Argument
Rhs
;
enum
DropoutArgument
=
P
:
"p"
|
MODE
:
"mode"
;
LRNMethod
implements
MainLayerMethod
=
name
:
"LRN"
"("
arguments
:(
LRNArgumentAssignment
||
","
)*
")"
;
LRNArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
LRNArgument
"="
rhs
:
Rhs
;
LRNArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
LRNArgument
"="
rhs
:
Argument
Rhs
;
enum
LRNArgument
=
ALPHA
:
"alpha"
|
BETA
:
"beta"
|
KNORM
:
"knorm"
...
...
@@ -84,13 +87,13 @@ grammar CNNArch extends de.monticore.common.Common {
ast
StandardOutputLayerMethod
=
method
public
String
getName
(){
return
optName
.
get
();
};
StandardOutputArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
StandardOutputArgument
"="
rhs
:
Rhs
;
StandardOutputArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
StandardOutputArgument
"="
rhs
:
Argument
Rhs
;
enum
StandardOutputArgument
=
GRADSCALE
:
"grad_scale"
;
SVMOutputLayerMethod
implements
OutputLayerMethod
=
name
:
"SVMOutput"
"("
arguments
:(
SVMOutputArgumentAssignment
||
","
)*
")"
;
SVMOutputArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
SVMOutputArgument
"="
rhs
:
Rhs
;
SVMOutputArgumentAssignment
implements
ArgumentAssignment
=
lhs
:
SVMOutputArgument
"="
rhs
:
Argument
Rhs
;
enum
SVMOutputArgument
=
MARGIN
:
"margin"
|
REGULARIZATIONCOEFFICIENT
:
"regularization_coefficient"
|
USELINEAR
:
"use_linear"
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTRhs.java
→
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/AST
Argument
Rhs.java
View file @
e16a54a9
...
...
@@ -22,14 +22,14 @@ package de.monticore.lang.monticar.cnnarch._ast;
import
java.util.Optional
;
public
class
ASTRhs
extends
ASTRhsTOP
{
public
class
AST
Argument
Rhs
extends
AST
Argument
RhsTOP
{
private
boolean
containsBoolean
;
public
ASTRhs
()
{
public
AST
Argument
Rhs
()
{
}
public
ASTRhs
(
String
stringVal
,
String
intVal
,
String
doubleVal
,
ASTIntTuple
intTuple
,
String
refOrBool
)
{
public
AST
Argument
Rhs
(
String
stringVal
,
String
intVal
,
String
doubleVal
,
ASTIntTuple
intTuple
,
String
refOrBool
)
{
super
(
stringVal
,
intVal
,
doubleVal
,
intTuple
,
refOrBool
);
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTMethod.java
View file @
e16a54a9
...
...
@@ -32,8 +32,8 @@ public interface ASTMethod extends ASTMethodTOP {
return
new
LinkedList
<>();
}
default
ASTRhs
get
(
String
lhsName
)
{
ASTRhs
rhs
=
null
;
default
AST
Argument
Rhs
get
(
String
lhsName
)
{
AST
Argument
Rhs
rhs
=
null
;
lhsName
=
lhsName
.
replace
(
"_"
,
""
);
for
(
ASTArgumentAssignment
assignment
:
getAssignments
())
{
String
assignmentLhs
=
assignment
.
getLhs
().
name
();
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/CNNArchSymbolTableCreator.java
0 → 100644
View file @
e16a54a9
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package
de.monticore.lang.monticar.cnnarch._symboltable
;
import
de.monticore.lang.monticar.cnnarch._ast.ASTArchitecture
;
import
de.monticore.lang.monticar.cnnarch._ast.ASTCNNArchCompilationUnit
;
import
de.monticore.symboltable.ArtifactScope
;
import
de.monticore.symboltable.ImportStatement
;
import
de.monticore.symboltable.MutableScope
;
import
de.monticore.symboltable.ResolvingConfiguration
;
import
de.se_rwth.commons.logging.Log
;
import
java.util.*
;
public
class
CNNArchSymbolTableCreator
extends
CNNArchSymbolTableCreatorTOP
{
private
String
compilationUnitPackage
=
""
;
public
CNNArchSymbolTableCreator
(
final
ResolvingConfiguration
resolvingConfig
,
final
MutableScope
enclosingScope
)
{
super
(
resolvingConfig
,
enclosingScope
);
}
public
CNNArchSymbolTableCreator
(
final
ResolvingConfiguration
resolvingConfig
,
final
Deque
<
MutableScope
>
scopeStack
)
{
super
(
resolvingConfig
,
scopeStack
);
}
@Override
public
void
visit
(
final
ASTCNNArchCompilationUnit
compilationUnit
)
{
Log
.
debug
(
"Building Symboltable for Script: "
+
compilationUnit
.
getArchitecture
().
getName
(),
CNNArchSymbolTableCreator
.
class
.
getSimpleName
());
List
<
ImportStatement
>
imports
=
new
ArrayList
<>();
ArtifactScope
artifactScope
=
new
ArtifactScope
(
Optional
.
empty
(),
compilationUnitPackage
,
imports
);
putOnStack
(
artifactScope
);
}
public
void
visit
(
final
ASTArchitecture
architecture
)
{
ArchitectureSymbol
architectureSymbol
=
new
ArchitectureSymbol
(
architecture
.
getName
()
);
addToScopeAndLinkWithNode
(
architectureSymbol
,
architecture
);
}
public
void
endVisit
(
final
ASTArchitecture
architecture
)
{
removeCurrentScope
();
}
}
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