Commit ff93bc23 authored by Abdallah Atouani's avatar Abdallah Atouani
Browse files

add tests for new DatasetArtifact tagging schema

parent 1bdd2d88
Pipeline #445516 passed with stage
in 1 minute and 27 seconds
......@@ -7,6 +7,8 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl;
import de.monticore.lang.monticar.emadl.tagging.artifacttag.DatasetArtifactTagSchema;
import de.monticore.lang.monticar.emadl.tagging.artifacttag.LayerArtifactParameterTagSchema;
import de.monticore.lang.monticar.emadl.tagging.dltag.DataPathTagSchema;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
......@@ -19,6 +21,8 @@ public class AbstractTaggingResolverTest extends AbstractSymtabTest {
Scope scope = createSymTab(modelPath);
TaggingResolver tagging = new TaggingResolver(scope, Arrays.asList(modelPath));
DataPathTagSchema.registerTagTypes(tagging);
DatasetArtifactTagSchema.registerTagTypes(tagging);
LayerArtifactParameterTagSchema.registerTagTypes(tagging);
return tagging;
}
......
package de.monticore.lang.monticar.emadl.tagging.artifacttag;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.emadl.AbstractTaggingResolverTest;
import de.monticore.lang.monticar.emadl.tagging.dltag.DataPathSymbol;
import de.monticore.lang.tagging._symboltable.TagSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
public class ArtifactTaggingTest extends AbstractTaggingResolverTest {
private TaggingResolver tagging = createSymTabandTaggingResolver("src/test/resources");
@Test
public void testValidDatasetArtifactTag() {
EMAComponentSymbol symbol = tagging.<EMAComponentSymbol>resolve("tagging.artifacttagging.Alexnet", EMAComponentSymbol.KIND)
.orElse(null);
Collection<TagSymbol> tags = tagging.getTags(symbol, DatasetArtifactSymbol.KIND);
assertEquals(1, tags.size());
DatasetArtifactSymbol datasetArtifactSymbol = (DatasetArtifactSymbol) tags.iterator().next();
assertEquals("com/emadl/dataset/mnist/2", datasetArtifactSymbol.getArtifact());
assertEquals("mnist-2-dataset", datasetArtifactSymbol.getJar());
assertEquals("HDF5", datasetArtifactSymbol.getType());
}
@Test
public void testValidLayerArtifactParameterTag() {
EMAComponentSymbol symbol = tagging.<EMAComponentSymbol>resolve("tagging.artifacttagging.Parent", EMAComponentSymbol.KIND).get();
Collection<TagSymbol> tagsA1 = tagging.getTags(symbol.getSpannedScope().getLocalSymbols().get("a1").iterator().next(), DatasetArtifactSymbol.KIND);
Collection<TagSymbol> tagsA2 = tagging.getTags(symbol.getSpannedScope().getLocalSymbols().get("a2").iterator().next(), DatasetArtifactSymbol.KIND);
assertEquals(1, tagsA1.size());
assertEquals(1, tagsA2.size());
DatasetArtifactSymbol tagA1 = (DatasetArtifactSymbol) tagsA1.iterator().next();
assertEquals("com/emadl/dataset/sst2/40", tagA1.getArtifact());
assertEquals("sst2-40-dataset", tagA1.getJar());
assertEquals("LMDB", tagA1.getType());
DatasetArtifactSymbol tagA2 = (DatasetArtifactSymbol) tagsA2.iterator().next();
assertEquals("com/monticore/lang/monticar/imdb/2", tagA2.getArtifact());
assertEquals("imdb-2-dataset", tagA2.getJar());
assertEquals("HDF5", tagA2.getType());
}
}
/* (c) https://github.com/MontiCore/monticore */
package tagging.artifacttagging;
conforms to artifacttag.DatasetArtifactTagSchema,
artifacttag.LayerArtifactParameterTagSchema;
tags AlexNet {
tag Alexnet with DatasetArtifact = {artifact = com.emadl.dataset:mnist:2, type = HDF5};
tag Parent.a1 with DatasetArtifact = {artifact = com.emadl.dataset:sst2:40, type = LMDB};
tag Parent.a2 with DatasetArtifact = {artifact = com.monticore.lang.monticar:imdb:2, type = HDF5};
}
/* (c) https://github.com/MontiCore/monticore */
package tagging.artifacttagging;
component Alexnet{
ports in Z(0:255)^{3, 224, 224} image,
out Q(0:1)^{1000} predictions;
implementation CNN {
def split1(i){
[i] ->
Convolution(kernel=(5,5), channels=128) ->
Lrn(nsize=5, alpha=0.0001, beta=0.75) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding="no_loss") ->
Relu()
}
def split2(i){
[i] ->
Convolution(kernel=(3,3), channels=192) ->
Relu() ->
Convolution(kernel=(3,3), channels=128) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding="no_loss") ->
Relu()
}
def fc(){
FullyConnected(units=4096) ->
Relu() ->
Dropout()
}
image ->
Convolution(kernel=(11,11), channels=96, stride=(4,4), padding="no_loss") ->
Lrn(nsize=5, alpha=0.0001, beta=0.75) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding="no_loss") ->
Relu() ->
Split(n=2) ->
split1(i=[0|1]) ->
Concatenate() ->
Convolution(kernel=(3,3), channels=384) ->
Relu() ->
Split(n=2) ->
split2(i=[0|1]) ->
Concatenate() ->
fc(->=2) ->
FullyConnected(units=1000) ->
Softmax() ->
predictions;
}
}
/* (c) https://github.com/MontiCore/monticore */
package tagging.artifacttagging;
component Parent {
instance Alexnet a1;
instance Alexnet a2;
}
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