https://github.com/halide/Halide
Raw File
Tip revision: 04258a57c4f8e7f46796e3ee5148a5101a92f7b4 authored by Andrew Adams on 13 February 2024, 21:33:54 UTC
Strip asserts right at the end of lowering
Tip revision: 04258a5
filter.cpp
#include <cassert>
#include <cstdio>
#include <cstdlib>

#include "HalideBuffer.h"
#include "HalideRuntime.h"

#include "hist.h"
#include "hist_auto_schedule.h"

#include "halide_benchmark.h"
#include "halide_image_io.h"

using namespace Halide::Tools;

int main(int argc, char **argv) {
    if (argc != 3) {
        printf("Usage: %s in out\n", argv[0]);
        return 1;
    }

    Halide::Runtime::Buffer<uint8_t, 3> input = load_and_convert_image(argv[1]);
    Halide::Runtime::Buffer<uint8_t, 3> output(input.width(), input.height(), 3);

    double best_manual = benchmark([&]() {
        hist(input, output);
        output.device_sync();
    });
    printf("Manually-tuned time: %gms\n", best_manual * 1e3);

    double best_auto = benchmark([&]() {
        hist_auto_schedule(input, output);
        output.device_sync();
    });
    printf("Auto-scheduled time: %gms\n", best_auto * 1e3);

    convert_and_save_image(output, argv[2]);

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