File: bad_partition_always_throws.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 (31 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (2)
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
#include "Halide.h"
using namespace Halide;

int main(int argc, char **argv) {
#ifndef HALIDE_WITH_EXCEPTIONS
    printf("[SKIP] bad_partition_always_throws requires exceptions\n");
    return 0;
#else
    try {
        Func f("f");
        Var x("x");
        f(x) = 0;
        f.partition(x, Partition::Always);
        f.realize({10});
    } catch (const CompileError &e) {
        const std::string_view msg = e.what();
        constexpr std::string_view expected_msg =
            "Loop Partition Policy is set to Always for f.s0.x, "
            "but no loop partitioning was performed.";
        if (msg.find(expected_msg) == std::string_view::npos) {
            std::cerr << "Expected error containing (" << expected_msg << "), but got (" << msg << ")\n";
            return 1;
        }
        printf("Success!\n");
        return 0;
    }

    printf("Did not see any exception!\n");
    return 1;
#endif
}