Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArchLang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
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
languages
CNNArchLang
Commits
fc91b63b
Commit
fc91b63b
authored
Oct 16, 2020
by
Julian Johannes Steinsberger-Dührßen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
23865315
Pipeline
#344500
passed with stage
in 7 minutes and 57 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
105 additions
and
43 deletions
+105
-43
pom.xml
pom.xml
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckLargeMemoryLayer.java
...e/lang/monticar/cnnarch/_cocos/CheckLargeMemoryLayer.java
+2
-2
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchExpressionSymbol.java
...g/monticar/cnnarch/_symboltable/ArchExpressionSymbol.java
+24
-0
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchitectureSymbol.java
...ang/monticar/cnnarch/_symboltable/ArchitectureSymbol.java
+25
-8
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/Constraints.java
...icore/lang/monticar/cnnarch/_symboltable/Constraints.java
+0
-20
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
...icore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
+4
-0
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/SerialCompositeElementSymbol.java
...ar/cnnarch/_symboltable/SerialCompositeElementSymbol.java
+5
-0
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/AllPredefinedLayers.java
...lang/monticar/cnnarch/predefined/AllPredefinedLayers.java
+2
-3
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/DotProductSelfAttention.java
.../monticar/cnnarch/predefined/DotProductSelfAttention.java
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/EpisodicMemory.java
...core/lang/monticar/cnnarch/predefined/EpisodicMemory.java
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LargeMemory.java
...nticore/lang/monticar/cnnarch/predefined/LargeMemory.java
+0
-5
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LayerNorm.java
...monticore/lang/monticar/cnnarch/predefined/LayerNorm.java
+38
-0
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LoadNetwork.java
...nticore/lang/monticar/cnnarch/predefined/LoadNetwork.java
+2
-2
No files found.
pom.xml
View file @
fc91b63b
...
...
@@ -33,7 +33,7 @@
<mc.grammars.assembly.version>
0.0.6
</mc.grammars.assembly.version>
<SIUnit.version>
0.0.11
</SIUnit.version>
<Common-MontiCar.version>
0.0.19-SNAPSHOT
</Common-MontiCar.version>
<Math.version>
0.
0.20
-SNAPSHOT
</Math.version>
<Math.version>
0.
2.12
-SNAPSHOT
</Math.version>
<!-- .. Libraries .................................................. -->
<guava.version>
18.0
</guava.version>
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckLargeMemoryLayer.java
View file @
fc91b63b
...
...
@@ -32,9 +32,9 @@ public class CheckLargeMemoryLayer extends CNNArchSymbolCoCo {
Integer
k
=
new
Integer
(
0
);
for
(
ArgumentSymbol
arg
:
arguments
)
{
if
(
arg
.
getName
().
equals
(
"subKeySize"
))
{
if
(
arg
.
getName
().
equals
(
"subKeySize"
)
&&
arg
.
getRhs
().
getIntValue
().
isPresent
()
)
{
subKeySize
=
arg
.
getRhs
().
getIntValue
().
get
();
}
else
if
(
arg
.
getName
().
equals
(
"k"
))
{
}
else
if
(
arg
.
getName
().
equals
(
"k"
)
&&
arg
.
getRhs
().
getIntValue
().
isPresent
()
)
{
k
=
arg
.
getRhs
().
getIntValue
().
get
();
}
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchExpressionSymbol.java
View file @
fc91b63b
...
...
@@ -229,6 +229,30 @@ abstract public class ArchExpressionSymbol extends CommonSymbol {
return
Optional
.
empty
();
}
public
Optional
<
List
<
Integer
>>
getIntOrIntTupleValues
(){
Optional
<
List
<
Object
>>
optValue
=
getTupleValues
();
if
(
optValue
.
isPresent
()){
List
<
Integer
>
list
=
new
ArrayList
<>();
for
(
Object
value
:
optValue
.
get
())
{
if
(
value
instanceof
Integer
){
list
.
add
((
Integer
)
value
);
}
else
{
return
Optional
.
empty
();
}
}
return
Optional
.
of
(
list
);
}
else
{
List
<
Integer
>
list
=
new
ArrayList
<>();
Optional
<
Integer
>
optValueInt
=
getIntValue
();
if
(
optValueInt
.
isPresent
()){
list
.
add
(
optValueInt
.
get
());
return
Optional
.
of
(
list
);
}
}
return
Optional
.
empty
();
}
public
Optional
<
List
<
Double
>>
getDoubleTupleValues
()
{
Optional
<
List
<
Object
>>
optValue
=
getTupleValues
();
if
(
optValue
.
isPresent
()){
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchitectureSymbol.java
View file @
fc91b63b
...
...
@@ -260,31 +260,47 @@ public class ArchitectureSymbol extends CommonScopeSpanningSymbol {
List
<
ArchitectureElementSymbol
>
elementsNew
=
new
ArrayList
<>();
List
<
List
<
ArchitectureElementSymbol
>>
episodicSubNetworks
=
new
ArrayList
<>(
new
ArrayList
<>());
List
<
ArchitectureElementSymbol
>
currentEpisodicSubNetworkElements
=
new
ArrayList
<>();
boolean
anyEpisodicLocalAdaption
=
false
;
for
(
ArchitectureElementSymbol
element
:
elements
){
if
(
AllPredefinedLayers
.
EPISODIC_REPLAY_LAYER_NAMES
.
contains
(
element
.
getName
()))
{
boolean
use_replay
=
false
;
boolean
use_local_adaption
=
false
;
boolean
use_replay_specified
=
false
;
boolean
use_local_adaption_specified
=
false
;
for
(
ArgumentSymbol
arg
:
((
LayerSymbol
)
element
).
getArguments
()){
if
(
arg
.
getName
().
equals
(
AllPredefinedLayers
.
USE_REPLAY_NAME
)
&&
(
boolean
)
arg
.
getRhs
().
getValue
().
get
()){
use_replay
=
true
;
break
;
}
else
if
(
arg
.
getName
().
equals
(
AllPredefinedLayers
.
USE_LOCAL_ADAPTION_NAME
)
&&
(
boolean
)
arg
.
getRhs
().
getValue
().
get
()){
use_local_adaption
=
true
;
break
;
if
(
arg
.
getName
().
equals
(
AllPredefinedLayers
.
USE_REPLAY_NAME
)){
use_replay_specified
=
true
;
if
((
boolean
)
arg
.
getRhs
().
getValue
().
get
())
{
use_replay
=
true
;
break
;
}
}
else
if
(
arg
.
getName
().
equals
(
AllPredefinedLayers
.
USE_LOCAL_ADAPTION_NAME
)){
use_local_adaption_specified
=
true
;
if
((
boolean
)
arg
.
getRhs
().
getValue
().
get
())
{
use_local_adaption
=
true
;
anyEpisodicLocalAdaption
=
true
;
break
;
}
}
}
if
(!
use_replay
&&
!
use_local_adaption
)
{
if
(!
use_replay
_specified
)
{
for
(
ParameterSymbol
param
:
((
LayerSymbol
)
element
).
getDeclaration
().
getParameters
())
{
if
(
param
.
getName
().
equals
(
AllPredefinedLayers
.
USE_REPLAY_NAME
)
&&
(
boolean
)
param
.
getDefaultExpression
().
get
().
getValue
().
get
())
{
use_replay
=
true
;
break
;
}
else
if
(
param
.
getName
().
equals
(
AllPredefinedLayers
.
USE_LOCAL_ADAPTION_NAME
)
&&
}
}
}
if
(!
use_local_adaption_specified
)
{
for
(
ParameterSymbol
param
:
((
LayerSymbol
)
element
).
getDeclaration
().
getParameters
())
{
if
(
param
.
getName
().
equals
(
AllPredefinedLayers
.
USE_LOCAL_ADAPTION_NAME
)
&&
(
boolean
)
param
.
getDefaultExpression
().
get
().
getValue
().
get
())
{
use_local_adaption
=
true
;
anyEpisodicLocalAdaption
=
true
;
break
;
}
}
...
...
@@ -303,6 +319,7 @@ public class ArchitectureSymbol extends CommonScopeSpanningSymbol {
episodicSubNetworks
.
add
(
currentEpisodicSubNetworkElements
);
}
networkInstruction
.
getBody
().
setEpisodicSubNetworks
(
episodicSubNetworks
);
networkInstruction
.
getBody
().
setAnyEpisodicLocalAdaption
(
anyEpisodicLocalAdaption
);
}
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/Constraints.java
View file @
fc91b63b
...
...
@@ -269,26 +269,6 @@ public enum Constraints {
+
AllPredefinedLayers
.
MEMORY_ACTIVATION_SOFTSIGN
;
}
},
DIST_MEASURE_TYPE
{
@Override
public
boolean
isValid
(
ArchSimpleExpressionSymbol
exp
)
{
Optional
<
String
>
optString
=
exp
.
getStringValue
();
if
(
optString
.
isPresent
()){
if
(
optString
.
get
().
equals
(
AllPredefinedLayers
.
L2
)
||
optString
.
get
().
equals
(
AllPredefinedLayers
.
INNER_PROD
)){
return
true
;
}
}
return
false
;
}
@Override
protected
String
msgString
()
{
return
AllPredefinedLayers
.
L2
+
" or "
+
AllPredefinedLayers
.
INNER_PROD
+
"or"
+
AllPredefinedLayers
.
RANDOM
;
}
},
MEMORY_REPLACEMENT_STRATEGY_TYPE
{
@Override
public
boolean
isValid
(
ArchSimpleExpressionSymbol
exp
)
{
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
View file @
fc91b63b
...
...
@@ -283,6 +283,10 @@ public class LayerSymbol extends ArchitectureElementSymbol {
return
getTValue
(
parameterName
,
ArchExpressionSymbol:
:
getIntTupleValues
);
}
public
Optional
<
List
<
Integer
>>
getIntOrIntTupleValues
(
String
parameterName
){
return
getTValue
(
parameterName
,
ArchExpressionSymbol:
:
getIntOrIntTupleValues
);
}
public
Optional
<
Boolean
>
getBooleanValue
(
String
parameterName
){
return
getTValue
(
parameterName
,
ArchExpressionSymbol:
:
getBooleanValue
);
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/SerialCompositeElementSymbol.java
View file @
fc91b63b
...
...
@@ -13,6 +13,7 @@ import java.util.*;
public
class
SerialCompositeElementSymbol
extends
CompositeElementSymbol
{
protected
List
<
List
<
ArchitectureElementSymbol
>>
episodicSubNetworks
=
new
ArrayList
<>(
new
ArrayList
<>());
protected
boolean
anyEpisodicLocalAdaption
=
false
;
protected
void
setElements
(
List
<
ArchitectureElementSymbol
>
elements
)
{
ArchitectureElementSymbol
previous
=
null
;
...
...
@@ -60,6 +61,10 @@ public class SerialCompositeElementSymbol extends CompositeElementSymbol {
return
episodicSubNetworks
;
}
protected
void
setAnyEpisodicLocalAdaption
(
boolean
isUsed
){
anyEpisodicLocalAdaption
=
isUsed
;
}
public
boolean
getAnyEpisodicLocalAdaption
(){
return
anyEpisodicLocalAdaption
;
}
@Override
public
void
setInputElement
(
ArchitectureElementSymbol
inputElement
)
{
super
.
setInputElement
(
inputElement
);
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/AllPredefinedLayers.java
View file @
fc91b63b
...
...
@@ -31,6 +31,7 @@ public class AllPredefinedLayers {
public
static
final
String
GLOBAL_POOLING_NAME
=
"GlobalPooling"
;
public
static
final
String
LRN_NAME
=
"Lrn"
;
public
static
final
String
BATCHNORM_NAME
=
"BatchNorm"
;
public
static
final
String
LAYERNORM_NAME
=
"LayerNorm"
;
public
static
final
String
SPLIT_NAME
=
"Split"
;
public
static
final
String
GET_NAME
=
"Get"
;
public
static
final
String
ADD_NAME
=
"Add"
;
...
...
@@ -126,7 +127,6 @@ public class AllPredefinedLayers {
public
static
final
String
QUERY_ACT_NAME
=
"queryAct"
;
public
static
final
String
K_NAME
=
"k"
;
public
static
final
String
NUM_HEADS_NAME
=
"numHeads"
;
public
static
final
String
STORE_DIST_MEASURE_NAME
=
"storeDistMeasure"
;
public
static
final
String
VALUES_DIM_NAME
=
"valuesDim"
;
public
static
final
String
MEMORY_REPLACEMENT_STRATEGY_NAME
=
"memoryReplacementStrategy"
;
...
...
@@ -143,8 +143,6 @@ public class AllPredefinedLayers {
public
static
final
String
PADDING_NO_LOSS
=
"no_loss"
;
public
static
final
String
POOL_MAX
=
"max"
;
public
static
final
String
POOL_AVG
=
"avg"
;
public
static
final
String
L2
=
"l2"
;
public
static
final
String
INNER_PROD
=
"inner_prod"
;
public
static
final
String
RANDOM
=
"random"
;
public
static
final
String
REPLACE_OLDEST
=
"replace_oldest"
;
public
static
final
String
NO_REPLACEMENT
=
"no_replacement"
;
...
...
@@ -174,6 +172,7 @@ public class AllPredefinedLayers {
GlobalPooling
.
create
(),
Lrn
.
create
(),
BatchNorm
.
create
(),
LayerNorm
.
create
(),
Split
.
create
(),
Get
.
create
(),
Add
.
create
(),
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/DotProductSelfAttention.java
View file @
fc91b63b
...
...
@@ -50,7 +50,7 @@ public class DotProductSelfAttention extends PredefinedLayerDeclaration {
List
<
ParameterSymbol
>
parameters
=
new
ArrayList
<>(
Arrays
.
asList
(
new
ParameterSymbol
.
Builder
()
.
name
(
AllPredefinedLayers
.
SCALE_FACTOR_NAME
)
.
constraints
(
Constraints
.
INTEGER
,
Constraints
.
POSITIVE
)
.
constraints
(
Constraints
.
POSITIVE
)
.
defaultValue
(-
1
)
.
build
(),
new
ParameterSymbol
.
Builder
()
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/EpisodicMemory.java
View file @
fc91b63b
...
...
@@ -80,7 +80,7 @@ public class EpisodicMemory extends PredefinedLayerDeclaration {
.
build
(),
new
ParameterSymbol
.
Builder
()
.
name
(
AllPredefinedLayers
.
USE_LOCAL_ADAPTION_NAME
)
.
constraints
(
Constraints
.
BOOLEAN
,
Constraints
.
POSITIVE
)
.
constraints
(
Constraints
.
BOOLEAN
)
.
defaultValue
(
true
)
.
build
(),
new
ParameterSymbol
.
Builder
()
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LargeMemory.java
View file @
fc91b63b
...
...
@@ -60,11 +60,6 @@ public class LargeMemory extends PredefinedLayerDeclaration {
public
static
LargeMemory
create
(){
LargeMemory
declaration
=
new
LargeMemory
();
List
<
ParameterSymbol
>
parameters
=
new
ArrayList
<>(
Arrays
.
asList
(
new
ParameterSymbol
.
Builder
()
.
name
(
AllPredefinedLayers
.
STORE_DIST_MEASURE_NAME
)
.
constraints
(
Constraints
.
DIST_MEASURE_TYPE
)
.
defaultValue
(
AllPredefinedLayers
.
INNER_PROD
)
.
build
(),
new
ParameterSymbol
.
Builder
()
.
name
(
AllPredefinedLayers
.
SUB_KEY_SIZE_NAME
)
.
constraints
(
Constraints
.
INTEGER
,
Constraints
.
POSITIVE
)
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LayerNorm.java
0 → 100644
View file @
fc91b63b
/**
*
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package
de.monticore.lang.monticar.cnnarch.predefined
;
import
de.monticore.lang.monticar.cnnarch._symboltable.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
LayerNorm
extends
PredefinedLayerDeclaration
{
private
LayerNorm
()
{
super
(
AllPredefinedLayers
.
LAYERNORM_NAME
);
}
@Override
public
List
<
ArchTypeSymbol
>
computeOutputTypes
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
VariableSymbol
.
Member
member
)
{
return
layer
.
getInputTypes
();
}
@Override
public
void
checkInput
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
VariableSymbol
.
Member
member
)
{
errorIfInputSizeIsNotOne
(
inputTypes
,
layer
);
}
public
static
LayerNorm
create
(){
LayerNorm
declaration
=
new
LayerNorm
();
declaration
.
setParameters
(
new
ArrayList
<>());
return
declaration
;
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/LoadNetwork.java
View file @
fc91b63b
...
...
@@ -24,7 +24,7 @@ public class LoadNetwork extends PredefinedLayerDeclaration {
@Override
public
List
<
ArchTypeSymbol
>
computeOutputTypes
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
VariableSymbol
.
Member
member
)
{
Optional
<
List
<
Integer
>>
optValue
=
layer
.
getInt
TupleValue
(
AllPredefinedLayers
.
OUTPUT_SHAPE_NAME
);
Optional
<
List
<
Integer
>>
optValue
=
layer
.
getInt
OrIntTupleValues
(
AllPredefinedLayers
.
OUTPUT_SHAPE_NAME
);
List
<
Integer
>
shapeList
=
Arrays
.
asList
(
1
,
1
,
1
);
...
...
@@ -65,7 +65,7 @@ public class LoadNetwork extends PredefinedLayerDeclaration {
.
build
(),
new
ParameterSymbol
.
Builder
()
.
name
(
AllPredefinedLayers
.
OUTPUT_SHAPE_NAME
)
.
constraints
(
Constraints
.
INTEGER_TUPLE
)
.
constraints
(
Constraints
.
INTEGER_
OR_INTEGER_
TUPLE
)
.
build
()));
declaration
.
setParameters
(
parameters
);
return
declaration
;
...
...
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