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
languages
CNNArchLang
Commits
79cfdeba
Commit
79cfdeba
authored
Oct 24, 2019
by
Sebastian Nickels
Browse files
Fixed dot layer
parent
5636a8dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/PredefinedLayerDeclaration.java
View file @
79cfdeba
...
...
@@ -121,14 +121,6 @@ abstract public class PredefinedLayerDeclaration extends LayerDeclarationSymbol
}
}
protected
void
errorIfInputNotFeasibleForDotProduct
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
){
if
(!(
layer
.
getInputTypes
().
get
(
1
).
getHeight
()
==
layer
.
getInputTypes
().
get
(
0
).
getWidth
())){
Log
.
error
(
"0"
+
ErrorCodes
.
INVALID_ELEMENT_INPUT_SHAPE
+
" Invalid layer input. Dot Product cannot be applied to input 1 with height "
+
layer
.
getInputTypes
().
get
(
1
).
getHeight
()
+
" and input 0 with width "
+
layer
.
getInputTypes
().
get
(
0
).
getWidth
()
,
layer
.
getSourcePosition
());
}
}
protected
void
errorIfInputChannelSizeIsInvalid
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
int
channels
)
{
for
(
ArchTypeSymbol
inputType
:
inputTypes
)
{
if
(
inputType
.
getChannels
()
!=
channels
)
{
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/Dot.java
View file @
79cfdeba
...
...
@@ -21,6 +21,8 @@
package
de.monticore.lang.monticar.cnnarch.predefined
;
import
de.monticore.lang.monticar.cnnarch._symboltable.*
;
import
de.monticore.lang.monticar.cnnarch.helper.ErrorCodes
;
import
de.se_rwth.commons.logging.Log
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -35,29 +37,24 @@ public class Dot extends PredefinedLayerDeclaration {
@Override
public
List
<
ArchTypeSymbol
>
computeOutputTypes
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
VariableSymbol
.
Member
member
)
{
if
(
layer
.
getInputTypes
().
get
(
0
).
getWidth
()
==
1
||
layer
.
getInputTypes
().
get
(
0
).
getHeight
()
==
1
)
{
// if dot product between vectors
return
Collections
.
singletonList
(
new
ArchTypeSymbol
.
Builder
()
.
channels
(
layer
.
getInputTypes
().
get
(
0
).
getChannels
())
.
height
(
1
)
.
width
(
1
)
.
elementType
(
"-oo"
,
"oo"
)
.
build
());
}
else
{
// if dot product between matrices
return
Collections
.
singletonList
(
new
ArchTypeSymbol
.
Builder
()
.
channels
(
layer
.
getInputTypes
().
get
(
0
).
getChannels
())
.
height
(
layer
.
getInputTypes
().
get
(
0
).
getHeight
())
.
width
(
layer
.
getInputTypes
().
get
(
0
).
getWidth
())
.
elementType
(
"-oo"
,
"oo"
)
.
build
());
}
return
Collections
.
singletonList
(
new
ArchTypeSymbol
.
Builder
()
.
channels
(
layer
.
getInputTypes
().
get
(
0
).
getChannels
())
.
height
(
layer
.
getInputTypes
().
get
(
1
).
getHeight
())
.
width
(
1
)
.
elementType
(
"-oo"
,
"oo"
)
.
build
());
}
@Override
public
void
checkInput
(
List
<
ArchTypeSymbol
>
inputTypes
,
LayerSymbol
layer
,
VariableSymbol
.
Member
member
)
{
errorIfInputIsEmpty
(
inputTypes
,
layer
);
errorIfInputNotFeasibleForDotProduct
(
inputTypes
,
layer
);
errorIfInputWidthIsInvalid
(
inputTypes
,
layer
,
1
);
if
(
layer
.
getInputTypes
().
get
(
0
).
getHeight
().
intValue
()
!=
layer
.
getInputTypes
().
get
(
1
).
getChannels
().
intValue
())
{
Log
.
error
(
"0"
+
ErrorCodes
.
INVALID_ELEMENT_INPUT_SHAPE
+
" Invalid layer input. Dot cannot be applied to input 0 with height "
+
layer
.
getInputTypes
().
get
(
0
).
getHeight
()
+
" and input 1 with channel size "
+
layer
.
getInputTypes
().
get
(
1
).
getChannels
()
,
layer
.
getSourcePosition
());
}
}
public
static
Dot
create
(){
...
...
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