execute.ftl 3.09 KB
Newer Older
1
<#list tc.architectureInputSymbols as input>
2
3
    vector<float> ${tc.getName(input)} = CNNTranslator::translate(${input.name}<#if input.arrayAccess.isPresent()>[${input.arrayAccess.get().intValue.get()?c}]</#if>);
</#list>
4
5
<#list tc.getLayerVariableMembers("1", true)?keys as member>
    vector<float> ${member}(${tc.join(tc.getLayerVariableMembers("1", true)[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
30
31
<#if (output.ioDeclaration.type.domain.isNaturalNumber() || output.ioDeclaration.type.domain.isWholeNumber())>
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToIntCol(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}});
<#else>
32
    ${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}});
33
</#if>
34
</#if>
35
<#if shape?size == 2>
36
37
38
<#if (output.ioDeclaration.type.domain.isNaturalNumber() || output.ioDeclaration.type.domain.isWholeNumber())>
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToIntMat(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}, ${shape[1]?c}});
<#else>
39
    ${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}});
40
</#if>
41
</#if>
42
<#if shape?size == 3>
43
44
45
<#if (output.ioDeclaration.type.domain.isNaturalNumber() || output.ioDeclaration.type.domain.isWholeNumber())>
    ${output.name}<#if output.arrayAccess.isPresent()>[${output.arrayAccess.get().intValue.get()?c}]</#if> = CNNTranslator::translateToIntCube(${tc.getName(output)}, std::vector<size_t> {${shape[0]?c}, ${shape[1]?c}, ${shape[2]?c}});
<#else>
46
    ${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}});
47
48

</#if>
49
50
</#if>
</#list>