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

<#list tc.getNoDuplicateArchitectureOutputs() as output>
11
<#if tc.getName(output)??>
12
    vector<float> ${tc.getName(output)}(${tc.join(output.ioDeclaration.type.dimensions, " * ")});
13
</#if>
14
15
</#list>

16
<#list tc.architecture.streams as stream>
17
18
<#if stream.isTrainable()>
    _predictor_${stream?index}_.predict(${tc.join(tc.getStreamInputNames(stream), ", ")}, ${tc.join(tc.getStreamOutputNames(stream), ", ")});
19
20
<#else>
${tc.include(stream, "CPP_INLINE")}
21
22
</#if>
</#list>
23

24
<#list tc.architecture.unrolls as unroll>
25
26
27
<#list unroll.getBodiesForAllTimesteps() as body>
<#if body.isTrainable()>
    _predictor_${tc.architecture.streams?size + body?index}_.predict(${tc.join(tc.getStreamInputNames(body), ", ")}, ${tc.join(tc.getStreamOutputNames(body), ", ")});
28
<#else>
29
${tc.include(unroll, true, "CPP_INLINE")}
30
31
</#if>
</#list>
32
</#list>
33

34
<#list tc.architecture.outputs as output>
35
<#if tc.getName(output)??>
36
<#assign shape = output.ioDeclaration.type.dimensions>
37
<#if shape?size == 1>
38
    ${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}});
39
40
</#if>
<#if shape?size == 2>
41
    ${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}});
42
43
</#if>
<#if shape?size == 3>
44
    ${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}});
45
</#if>
46
</#if>
47
</#list>