Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Caffe2
Commits
c18c2cf5
Commit
c18c2cf5
authored
Feb 20, 2019
by
Evgeny Kusmenko
Browse files
Merge branch 'new_junit_tests' into 'master'
New JUnit tests See merge request
!27
parents
45b48793
821b76b8
Pipeline
#106586
passed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java
View file @
c18c2cf5
...
...
@@ -37,6 +37,7 @@ public class CNNArchTemplateController {
private
LayerNameCreator
nameManager
;
private
ArchitectureSymbol
architecture
;
private
String
loss
;
//temporary attributes. They are set after calling process()
private
Writer
writer
;
...
...
@@ -44,8 +45,6 @@ public class CNNArchTemplateController {
private
Target
targetLanguage
;
private
ArchitectureElementData
dataElement
;
public
String
loss
;
public
static
final
String
CROSS_ENTROPY
=
"cross_entropy"
;
public
static
final
String
EUCLIDEAN
=
"euclidean"
;
...
...
src/test/java/de/monticore/lang/monticar/cnnarch/caffe2generator/GenerationTest.java
View file @
c18c2cf5
...
...
@@ -22,6 +22,7 @@ package de.monticore.lang.monticar.cnnarch.caffe2generator;
import
de.se_rwth.commons.logging.Log
;
import
freemarker.template.TemplateException
;
import
org.apache.commons.cli.ParseException
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -31,6 +32,7 @@ import java.nio.file.Path;
import
java.nio.file.Paths
;
import
java.util.*
;
import
org.junit.contrib.java.lang.system.Assertion
;
import
org.junit.contrib.java.lang.system.ExpectedSystemExit
;
import
static
junit
.
framework
.
TestCase
.
assertTrue
;
...
...
@@ -62,26 +64,33 @@ public class GenerationTest extends AbstractSymtabTest{
}
@Test
public
void
testCifar10Classifier
()
throws
IOException
,
TemplateException
{
public
void
test
UnsupportedLayers
Cifar10Classifier
()
throws
IOException
,
TemplateException
{
Log
.
getFindings
().
clear
();
String
[]
args
=
{
"-m"
,
"src/test/resources/valid_tests"
,
"-r"
,
"CifarClassifierNetwork"
,
"-o"
,
"./target/generated-sources-cnnarch/"
};
exit
.
expectSystemExit
();
exit
.
checkAssertionAfterwards
(
new
Assertion
()
{
public
void
checkAssertion
()
{
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
});
CNNArch2Caffe2Cli
.
main
(
args
);
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
@Test
public
void
test
AlexnetGeneration
()
throws
IOException
,
TemplateException
{
public
void
test
UnsupportedLayersAlexnet
()
throws
IOException
,
TemplateException
{
Log
.
getFindings
().
clear
();
String
[]
args
=
{
"-m"
,
"src/test/resources/architectures"
,
"-r"
,
"Alexnet"
,
"-o"
,
"./target/generated-sources-cnnarch/"
};
exit
.
expectSystemExit
();
exit
.
checkAssertionAfterwards
(
new
Assertion
()
{
public
void
checkAssertion
()
{
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
});
CNNArch2Caffe2Cli
.
main
(
args
);
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
@Test
public
void
testGeneratorVGG16
()
throws
IOException
,
TemplateException
{
public
void
testGeneratorVGG16
Generation
()
throws
IOException
,
TemplateException
{
Log
.
getFindings
().
clear
();
String
[]
args
=
{
"-m"
,
"src/test/resources/architectures"
,
"-r"
,
"VGG16"
,
"-o"
,
"./target/generated-sources-cnnarch/"
};
CNNArch2Caffe2Cli
.
main
(
args
);
...
...
@@ -102,17 +111,25 @@ public class GenerationTest extends AbstractSymtabTest{
Log
.
getFindings
().
clear
();
String
[]
args
=
{
"-m"
,
"src/test/resources/architectures"
,
"-r"
,
"ThreeInputCNN_M14"
};
exit
.
expectSystemExit
();
exit
.
checkAssertionAfterwards
(
new
Assertion
()
{
public
void
checkAssertion
()
{
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
});
CNNArch2Caffe2Cli
.
main
(
args
);
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
@Test
public
void
test
ResNeXtGeneration
()
throws
IOException
,
TemplateException
{
public
void
test
UnsupportedLayersResNeXt
()
throws
IOException
,
TemplateException
{
Log
.
getFindings
().
clear
();;
String
[]
args
=
{
"-m"
,
"src/test/resources/architectures"
,
"-r"
,
"ResNeXt50"
};
exit
.
expectSystemExit
();
exit
.
checkAssertionAfterwards
(
new
Assertion
()
{
public
void
checkAssertion
()
{
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
});
CNNArch2Caffe2Cli
.
main
(
args
);
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
@Test
...
...
@@ -190,7 +207,9 @@ public class GenerationTest extends AbstractSymtabTest{
String
rootModelName
=
"alexnet"
;
CNNArch2Caffe2
generator
=
new
CNNArch2Caffe2
();
generator
.
setGenerationTargetPath
(
"./target/generated-sources-cnnarch"
);
generator
.
generateCMake
(
rootModelName
);
if
(
generator
.
isCMakeRequired
()){
generator
.
generateCMake
(
rootModelName
);
}
assertTrue
(
Log
.
getFindings
().
isEmpty
());
...
...
@@ -207,4 +226,17 @@ public class GenerationTest extends AbstractSymtabTest{
"FindArmadillo.cmake"
));
}
@Test
public
void
testWrongArgumentCNNArch2Caffe2Cli
()
throws
ParseException
{
Log
.
getFindings
().
clear
();
String
[]
args
=
{
"-x"
,
"src/test/resources/architectures"
,
"-y"
,
"LeNet"
,
"-z"
,
"./target/generated-sources-cnnarch/"
};
exit
.
expectSystemExit
();
exit
.
checkAssertionAfterwards
(
new
Assertion
()
{
public
void
checkAssertion
()
{
assertTrue
(
Log
.
getFindings
().
size
()
==
2
);
}
});
CNNArch2Caffe2Cli
.
main
(
args
);
}
}
Write
Preview
Supports
Markdown
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