File: bounds_inference_complex.cpp

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (35 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Halide.h"
#include <stdio.h>

using namespace Halide;

int main(int argc, char **argv) {
    const int K = 8;

    Func f[K];
    Var x, y;

    if (argc > 1)
        srand(atoi(argv[1]));
    else
        srand(0);

    f[0](x, y) = x + y;
    f[1](x, y) = x * y;
    for (int i = 2; i < K; i++) {
        int j1 = rand() % i;
        int j2 = rand() % i;
        int j3 = rand() % i;
        f[i](x, y) = f[j1](x - 1, y - 1) + f[j2](x + 1, clamp(f[j3](x + 1, y - 1), 0, 7));

        if (rand() & 1) {
            f[i].compute_root();
            f[i].vectorize(x, 4);
        }
    }

    Buffer<int> out = f[K - 1].realize({32, 32});

    printf("Success!\n");
    return 0;
}