Commit 77afa5b3 authored by danielkisov's avatar danielkisov
Browse files

adding exception in CNNArch2GluonTemplateController for CustomLayerDeclaration...

adding exception in CNNArch2GluonTemplateController for CustomLayerDeclaration to always call the CustomLayer.ftl
parent 41f86cc3
Pipeline #425726 failed with stage
in 31 seconds
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-gluon-generator</artifactId>
<version>0.4.6-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -17,7 +17,7 @@
<!-- .. SE-Libraries .................................................. -->
<CNNArch2X.version>0.4.6-SNAPSHOT</CNNArch2X.version>
<CNNArch2X.version>0.5.0-SNAPSHOT</CNNArch2X.version>
<EMADL2PythonWrapper.version>0.0.3-SNAPSHOT</EMADL2PythonWrapper.version>
<!-- .. Libraries .................................................. -->
......
......@@ -30,6 +30,12 @@ public class CNNArch2GluonTemplateController extends CNNArchTemplateController {
ftlContext.put(TEMPLATE_CONTROLLER_KEY, this);
ftlContext.put(ELEMENT_DATA_KEY, getCurrentElement());
ftlContext.put(NET_DEFINITION_MODE_KEY, netDefinitionMode.toString());
if (this.getDataElement().getElement() instanceof LayerSymbol){
if(((LayerSymbol) (this.getDataElement().getElement())).getDeclaration() instanceof CustomLayerDeclaration){
templatePath = relativePath + "CustomLayer" + FTL_FILE_ENDING;
}
}
getTemplateConfiguration().processTemplate(ftlContext, templatePath, writer);
}
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if mode == "ARCHITECTURE_DEFINITION">
self.${element.name} = ${element.element.arguments[0].rhs.value?remove_beginning("Optional[")?remove_ending("]")}.${element.element.arguments[0].rhs.value?remove_beginning("Optional[")?remove_ending("]")}(
<#list element.element.arguments[1].rhs.value?split(",") as parameter>
${parameter?remove_beginning("Optional[")?remove_ending("]")}<#sep>, </#sep>
</#list>)
<#if element.element.arguments?has_content>
self.${element.name} = ${element.element.name}.${element.element.name}(<#rt>
<#list element.element.arguments as argument>
${argument.name}=${argument.rhs.value.get()}<#sep>, </#sep><#t>
</#list>)<#t>
<#else>
self.${element.name} = ${element.element.name}.${element.element.name}()
</#if>
<#elseif mode == "FORWARD_FUNCTION">
${element.name} = self.${element.name}(${input})
<#elseif mode == "PARAMETER_VALIDATION">
${element.name}temp = ${element.element.arguments[0].rhs.value?remove_beginning("Optional[")?remove_ending("]")}.${element.element.arguments[0].rhs.value?remove_beginning("Optional[")?remove_ending("]")}()
<#if element.element.arguments?has_content>
${element.name}temp = ${element.element.name}.${element.element.name}()
parameters_with_type = ${element.name}temp.get_parameters()
<#list element.element.arguments[1].rhs.value?split(", ") as parameter>
if '${parameter?remove_beginning("Optional[")?remove_ending("]")?keep_before("=")}' in parameters_with_type:
if isinstance(${parameter?remove_beginning("Optional[")?remove_ending("]")?keep_after("=")},parameters_with_type['${parameter?remove_beginning("Optional[")?remove_ending("]")?keep_before("=")}']) == False:
raise TypeError('Wrong ' + str(type(${parameter?remove_beginning("Optional[")?remove_ending("]")?keep_after("=")})) + ' of parameter \'${parameter?remove_beginning("Optional[")?remove_ending("]")?keep_before("=")}\' given in the model')
<#list element.element.arguments as argument>
if '${argument.name}' in parameters_with_type:
if isinstance(${argument.rhs.value.get()},parameters_with_type['${argument.name}']) == False:
raise TypeError('Wrong ' + str(type(${argument.rhs.value.get()})) + ' of parameter \'${argument.name}\' given in the model')
else:
raise AttributeError('Parameter of Layer not added to get_parameters function')
</#list>
</#if>
</#if>
\ 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