Skip to content

Getting InternalError with a combination of compute_with, and reductions that use functions with update definitions #8149

@sakehl

Description

@sakehl

This example program

#include "Halide.h"

using namespace Halide;

int main(int argc, char **argv){
  Func denominator_inter("denominator_inter");
  Func numerator("numerator"), denominator("denominator");
  Var i("i"), si("si"), vis("vis");

  numerator(si) = 0;
  denominator(si) = 0;
  RDom rv(0, 10, "rv");

  denominator_inter(i, vis) = 0;
  denominator_inter(0, vis) = 1 + vis;
  denominator(rv) += denominator_inter(0, rv);

  numerator(rv) += rv;
  numerator.compute_root();
  denominator.compute_root();
  denominator.update().compute_with(numerator.update(), rv);

  Func next("next");
  next(si) = numerator(si) / denominator(si);

  try{
    Target target = get_target_from_environment();
    target.set_feature(Target::Debug);
    next.compile_to_static_library("TestHalide.c", {}, "Test", target);
  } catch (Halide::Error &e){
    std::cerr << "Halide Error: " << e.what() << std::endl;
    __throw_exception_again;
  } 
}

throws an internal error:

Halide Error: Internal Error at /home/halidenightly/build_bot/worker/halide-nightly-release_17-x86-64-linux-cmake/halide-source/src/CodeGen_LLVM.cpp:1293 triggered by user code at : Symbol not found: denominator.s1.rv$x
The following names are in scope:
{
  ::Test
  denominator
  next
  next.buffer
  next.device_dirty
  next.dimensions
  next.extent.0
  next.min.0
  next.stride.0
  next.type
  numerator
  numerator.s1.rv$x
  numerator.si.extent_realized
  t12
}


whilst I believe this would be a valid program.

I've attached the output when running this with HL_DEBUG_CODEGEN=2

out.txt

I'm using the latest released version 17.0.1.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions