Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

added symbolTableCreator

parent 40f76601
......@@ -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,13 +21,13 @@ grammar CNNArch extends de.monticore.common.Common {
interface ArgumentAssignment;
ast ArgumentAssignment = method public Enum getLhs(){}
method public ASTRhs getRhs(){};
method public ASTArgumentRhs getRhs(){};
Rhs = stringVal:String
| intVal:Num_Int
| doubleVal:Num_Double
| intTuple:IntTuple
| refOrBool:Name;
ArgumentRhs = stringVal:String
| intVal:Num_Int
| doubleVal:Num_Double
| intTuple:IntTuple
| refOrBool:Name;
IntTuple = "(" values:Num_Int "," values:(Num_Int || ",")+ ")";
......@@ -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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
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:ArgumentRhs;
enum SVMOutputArgument = MARGIN:"margin"
| REGULARIZATIONCOEFFICIENT:"regularization_coefficient"
| USELINEAR:"use_linear";
......
......@@ -22,14 +22,14 @@ package de.monticore.lang.monticar.cnnarch._ast;
import java.util.Optional;
public class ASTRhs extends ASTRhsTOP{
public class ASTArgumentRhs extends ASTArgumentRhsTOP{
private boolean containsBoolean;
public ASTRhs() {
public ASTArgumentRhs() {
}
public ASTRhs(String stringVal, String intVal, String doubleVal, ASTIntTuple intTuple, String refOrBool) {
public ASTArgumentRhs(String stringVal, String intVal, String doubleVal, ASTIntTuple intTuple, String refOrBool) {
super(stringVal, intVal, doubleVal, intTuple, refOrBool);
}
......
......@@ -32,8 +32,8 @@ public interface ASTMethod extends ASTMethodTOP {
return new LinkedList<>();
}
default ASTRhs get(String lhsName) {
ASTRhs rhs = null;
default ASTArgumentRhs get(String lhsName) {
ASTArgumentRhs rhs = null;
lhsName = lhsName.replace("_", "");
for (ASTArgumentAssignment assignment : getAssignments()) {
String assignmentLhs = assignment.getLhs().name();
......
/**
*
* ******************************************************************************
* 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();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment