File: rdom_input_aottest.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 (28 lines) | stat: -rw-r--r-- 670 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
#include <stdio.h>

#include "HalideBuffer.h"
#include "rdom_input.h"

using namespace Halide::Runtime;

int main(int argc, char **argv) {
    Buffer<uint8_t, 2> input(3, 3);
    input.for_each_element([&](int x, int y) {
        input(x, y) = x * 16 + y;
    });

    Buffer<uint8_t, 2> output(3, 3);
    rdom_input(input, output);

    output.for_each_element([&](int x, int y) {
        int expected = input(x, y) ^ 0xff;
        int actual = output(x, y);
        if (expected != actual) {
            fprintf(stderr, "output(%d, %d) was %d instead of %d\n", x, y, actual, expected);
            exit(1);
        }
    });

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