execute.ftl 2.07 KB
Newer Older
1
<#list tc.architectureInputSymbols as input>
2
3
4
    vector<float> ${tc.getName(input)} = CNNTranslator::translate(${input.name}<#if input.arrayAccess.isPresent()>[${input.arrayAccess.get().intValue.get()?c}]</#if>);
</#list>
<#list tc.getLayerVariableMembers("1")?keys as member>
5
    vector<float> ${member}(${tc.join(tc.getLayerVariableMembers("1")[member][0], " * ")});
6
</#list>
7

8
<#list tc.architectureOutputSymbols as output>
9
    vector<float> ${tc.getName(output)}(${tc.join(output.ioDeclaration.type.dimensions, " * ")});
10
11
</#list>

Sebastian N.'s avatar
Sebastian N. committed
12
<#list tc.architecture.networkInstructions as networkInstruction>
Sebastian N.'s avatar
Sebastian N. committed
13
14
15
16
17
<#if networkInstruction.isUnroll()>
<#list networkInstruction.toUnrollInstruction().resolvedBodies as resolvedBody>
    _predictor_${networkInstruction?index}_.predict(${tc.join(tc.getStreamInputNames(networkInstruction.body, resolvedBody), ", ")}, ${tc.join(tc.getStreamOutputNames(networkInstruction.body, resolvedBody), ", ")});
</#list>
<#else>
Sebastian N.'s avatar
Sebastian N. committed
18
19
<#if networkInstruction.body.isTrainable()>
    _predictor_${networkInstruction?index}_.predict(${tc.join(tc.getStreamInputNames(networkInstruction.body), ", ")}, ${tc.join(tc.getStreamOutputNames(networkInstruction.body), ", ")});
20
<#else>
21
<#-- ${tc.include(networkInstruction.body, "CPP_INLINE")}; -->
22
</#if>
Sebastian N.'s avatar
Sebastian N. committed
23
</#if>
24
</#list>
25

26
<#list tc.architectureOutputSymbols as output>
27
<#assign shape = output.ioDeclaration.type.dimensions>
28
<#if shape?size == 1>
29
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToCol(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}});
30
31
</#if>
<#if shape?size == 2>
32
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToMat(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}, ${shape[1]?c}});
33
34
</#if>
<#if shape?size == 3>
35
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToCube(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}, ${shape[1]?c}, ${shape[2]?c}});
36
37
</#if>
</#list>