Skip to content

Performance regression from Halide V14 -> V15 with compute_at() #7623

@catid

Description

@catid
// Reproduces a regression in Halide V15:
// Using .compute_at() causes huge slow-downs.
class halide15_bug_generator : public Halide::Generator<halide15_bug_generator>
{
public:
    Input<Buffer<uint8_t>> input{"input", 2};
    Output<Buffer<uint8_t>> output{"output", 2};

    // Typically used for image coordinates
    Var x, y, xo, yo, xi, yi;

    Func intermediate{"intermediate"};

    void generate()
    {
        const int radius = 16;

        Func input_repeat = BoundaryConditions::repeat_edge(input);

        RDom r(-radius, radius*2);

        intermediate(x, y) = sum(2.3456f * cast<float>(input_repeat(x + r, y)));

        output(x, y) = saturating_cast<uint8_t>( intermediate(x, y) * 255.f );
    }

    void schedule()
    {
        const int vsize = natural_vector_size(output.type());

        output.tile(x, y, xo, yo, xi, yi, 64, 64)
            .vectorize(xi, vsize);

        // Adding this line causes V15 to go 5x slower.
        intermediate.compute_at(output, yi);
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions