Commit b227b149 authored by Nicola Gatto's avatar Nicola Gatto

Merge branch 'update-emadl-version' into ng-dev

parents 84271562 6aacf769
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.24-SNAPSHOT</version>
<version>0.0.23-SNAPSHOT-NG</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -22,8 +22,8 @@
<embedded-montiarc.version>0.1.9-SNAPSHOT</embedded-montiarc.version>
<Embedded-montiarc-math-generator.version>0.1.8-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.4-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL2CPP.version>0.2.8</EMADL2CPP.version>
<EMADL.version>0.2.7-SNAPSHOT</EMADL.version>
<EMADL2CPP.version>0.3.2-SNAPSHOT-NG</EMADL2CPP.version>
<EMADL.version>0.2.8-SNAPSHOT</EMADL.version>
<embedded-montiarc-component-clustering.version>0.0.2-SNAPSHOT</embedded-montiarc-component-clustering.version>
<!-- .. Libraries .................................................. -->
......
......@@ -25,6 +25,7 @@ public class DistributedTargetGenerator{
private ClusteringResultList clusteringResults = new ClusteringResultList();
private CMakeGenerator generatorBlueprint = new CMakeGenerator();
private String generationTargetPath;
private Integer updateRate;
public boolean isGenerateMiddlewareTags() {
return generateMiddlewareTags;
......@@ -157,6 +158,7 @@ public class DistributedTargetGenerator{
private GeneratorImpl createFullGenerator(String subdir) {
MiddlewareGenerator res = new MiddlewareGenerator();
res.setGenerationTargetPath(generationTargetPath + "src/" + (subdir.endsWith("/") ? subdir : subdir + "/"));
res.setUpdateRate(updateRate);
generatorBlueprint.getGeneratorImpls().forEach(gen -> res.add(gen, generatorBlueprint.getImplSubdir(gen)));
......@@ -205,4 +207,8 @@ public class DistributedTargetGenerator{
public void add(GeneratorImpl generator, String subdir) {
generatorBlueprint.add(generator, subdir);
}
public void setUpdateRate(int updateRate) {
this.updateRate = updateRate;
}
}
......@@ -15,6 +15,11 @@ import java.util.List;
import java.util.stream.Collectors;
public class MiddlewareGenerator extends CMakeGenerator {
private Integer updateRate = 100;
public void setUpdateRate(int updateRate) {
this.updateRate = updateRate;
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
......@@ -79,7 +84,8 @@ public class MiddlewareGenerator extends CMakeGenerator {
.replace("${compName}", name)
.replace("${includes}", includes)
.replace("${addAdapters}", addAdapters)
.replace("${initParams}",initParams);
.replace("${initParams}",initParams)
.replace("${updateRate}", updateRate.toString());
FileContent res = new FileContent();
......
......@@ -6,6 +6,7 @@ import java.util.Set;
public class CliParameters {
private static final boolean DEFAULT_WRITE_TAG_FILE = false;
private static final String DEFAULT_EMADL_BACKEND = "MXNET";
private static final int DEFAULT_UPDATE_RATE = 100;
private String modelsDir;
private String outputDir;
......@@ -14,11 +15,12 @@ public class CliParameters {
private String emadlBackend;
private Boolean writeTagFile;
private ClusteringParameters clusteringParameters;
private Integer updateRate;
public CliParameters() {
}
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClusteringParameters clusteringParameters) {
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClusteringParameters clusteringParameters, Integer updateRate) {
this.modelsDir = modelsDir;
this.outputDir = outputDir;
this.rootModel = rootModel;
......@@ -26,6 +28,7 @@ public class CliParameters {
this.emadlBackend = emadlBackend;
this.writeTagFile = writeTagFile;
this.clusteringParameters = clusteringParameters;
this.updateRate = updateRate;
}
public String getModelsDir() {
......@@ -56,4 +59,8 @@ public class CliParameters {
return Optional.ofNullable(clusteringParameters);
}
public int getUpdateRate() {
return updateRate == null ? DEFAULT_UPDATE_RATE : updateRate;
}
}
......@@ -46,7 +46,7 @@ public class CliParametersLoader {
.create();
JsonDeserializer<CliParameters> desCliParameters = new StrictJsonDeserializer<>(Arrays.asList("emadlBackend","writeTagFile","clusteringParameters","modelsDir","outputDir","rootModel","generators"), delegateGson);
JsonDeserializer<CliParameters> desCliParameters = new StrictJsonDeserializer<>(Arrays.asList("emadlBackend","writeTagFile","clusteringParameters","modelsDir","outputDir","rootModel","generators", "updateRate"), delegateGson);
JsonDeserializer<ClusteringParameters> desClustering = new StrictJsonDeserializer<>(Arrays.asList("numberOfClusters","flatten","flattenLevel","chooseBy","algorithmParameters", "metric"), delegateGson);
JsonDeserializer<DynamicSpectralClusteringCliParameters> desSpectral = new StrictJsonDeserializer<>(Arrays.asList("numberOfClusters","l","sigma"), delegateGson);
......
......@@ -119,6 +119,7 @@ public final class DistributedTargetGeneratorCli {
DistributedTargetGenerator generator = new DistributedTargetGenerator();
generator.setGenerationTargetPath(cliParameters.getOutputDir());
generator.setGenerateMiddlewareTags(cliParameters.getWriteTagFile());
generator.setUpdateRate(cliParameters.getUpdateRate());
Set<String> validGenNames = getGeneratorNames();
......
......@@ -10,9 +10,7 @@ import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;
public class EMADLGeneratorImpl implements GeneratorImpl {
private String generationTargetPath;
......@@ -36,7 +34,8 @@ public class EMADLGeneratorImpl implements GeneratorImpl {
List<File> files = new ArrayList<>();
emadlGenerator.setGenerationTargetPath(generationTargetPath);
List<FileContent> fileContents = emadlGenerator.generateStrings(taggingResolver, componentInstanceSymbol, taggingResolver);
List<FileContent> fileContents = emadlGenerator.generateStrings(taggingResolver, componentInstanceSymbol,
taggingResolver, new HashSet<>(), "n");
for (FileContent fileContent : fileContents) {
files.add(emadlGenerator.getEmamGen().generateFile(fileContent));
......
......@@ -10,7 +10,7 @@ ${includes}
using namespace std;
using namespace chrono;
static int exeMs = 100;
static int exeMs = ${updateRate};
bool parseCommandLineParameters(int argc, char* argv[]){
if(argc == 1){
......
......@@ -10,6 +10,7 @@ import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.generator.middleware.impls.*;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Finding;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.junit.Before;
......@@ -298,7 +299,7 @@ public class GenerationTest extends AbstractSymtabTest {
middlewareGenerator.add(new RosCppGenImpl(), "roscpp");
middlewareGenerator.generate(componentInstanceSymbol, taggingResolver);
assertTrue(Log.getFindings().isEmpty());
assertTrue(Log.getFindings().stream().filter(Finding::isError).collect(Collectors.toList()).isEmpty());
}
@Test
......
......@@ -185,5 +185,9 @@ public class ParameterLoadingTest {
Log.enableFailQuick(true);
}
@Test
public void testUpdateRateSet() throws FileNotFoundException {
CliParameters params = loadCliParameters("updateRateSet");
assertEquals(200, params.getUpdateRate());
}
}
{
"modelsDir": "src/test/resources/pacman/",
"outputDir": "target/cliTest/flattenSpectralMultiOverride/",
"rootModel": "de.rwth.pacman.heithoff2.controller",
"generators": ["cpp","roscpp"],
"updateRate": 200
}
\ No newline at end of file
......@@ -34,6 +34,6 @@ component ResNet34{
GlobalPooling(pool_type="avg") ->
FullyConnected(units=1000) ->
Softmax() ->
predictions
predictions;
}
}
\ No newline at end of file
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