Halide 内部错误问题

Halide internal error issue

这是代码。我在 VS2013 上使用 Halide,2015 年 8 月 5 日的 Win64 主干。当我执行 diag.compile_to_lowered_stmt("diag.html", {}, HTML) (具有 16MB 堆栈)时,我得到以下错误消息:

"Internal error at E:\Code\Halide\src\IR.cpp:160
Condition failed: a.type() == b.type()
LT of mismatched types"

我已经确认错误是由于以下行引起的:

diag(x, y, c) = select(m135(x, y) > m45(x, y), f45(x, y, c), select(m45(x, y) > m135(x, y), f135(x, y, c), f4x4(x, y, c)));

我能够删除错误的唯一方法是删除两个选择(当然,在这种情况下该函数不可用。)我已经尝试将条件转换为 Expr,并且我已经还检查了 m45 和 m135 的类型(通过将它们分配给 Expr t1,然后查看 t1.type()。)我注意到将“>”更改为“<”甚至“>=”确实不要更改 "LT".

中的错误消息

有什么想法吗?

代码还是和我之前的一样post:

Image<uint8_t> orig_uint = Tools::load_image("../foo.ppm");

Var x, y, c;
Func orig("orig"), orig_lum("orig_lum"), m45("m45"), m135("m135"), f45("f45"), f135("f135"), f4x4_horiz("f4x4_horiz"), f4x4("f4x4"), diag("diag");

Func orig_clamped = BoundaryConditions::repeat_edge(orig_uint);

const float wta = 1.0f, wtb = 3.0f, wt0 = wta * wta, wt1 = wta * wtb, wt2 = wtb * wtb;

orig(x, y, c) = cast<float_t>(orig_clamped(x, y, c));

orig_lum(x, y) = 0.299f * orig(x, y, 0) + 0.587f * orig(x, y, 1) + 0.114f * orig(x, y, 2);

m45(x, y) = abs(orig_lum(x - 1, y - 1) - orig_lum(x, y)) + abs(orig_lum(x, y) - orig_lum(x + 1, y + 1)) + abs(orig_lum(x + 1, y + 1) - orig_lum(x + 2, y + 2));

m135(x, y) = abs(orig_lum(x + 2, y - 1) - orig_lum(x + 1, y)) + abs(orig_lum(x + 1, y) - orig_lum(x, y + 1)) + abs(orig_lum(x, y + 1) - orig_lum(x - 1, y + 2));

f45(x, y, c) = wta * (orig(x - 1, y - 1, c) + orig(x + 2, y + 2, c)) + wtb * (orig(x, y, c) + orig(x + 1, y + 1, c));

f135(x, y, c) = wta * (orig(x - 1, y + 2, c) + orig(x + 2, y - 1, c)) + wtb * (orig(x, y + 1, c) + orig(x + 1, y, c));

f4x4_horiz(x, y, c) = wta * (orig(x - 1, y, c) + orig(x + 2, y, c)) + wtb * (orig(x, y, c) + orig(x + 1, y, c));

f4x4(x, y, c) = wta * (f4x4_horiz(x, y - 1, c) + f4x4_horiz(x, y + 2, c)) + wtb * (f4x4_horiz(x, y, c) + f4x4_horiz(x, y + 1, c));

diag(x, y, c) = select(m135(x, y) > m45(x, y), f45(x, y, c), select(m45(x, y) > m135(x, y), f135(x, y, c), f4x4(x, y, c)));

// schedule
orig_lum.compute_root();
m45.compute_root().bound(x, 0, orig_uint.width()).bound(y, 0, orig_uint.height());
m135.compute_root().bound(x, 0, orig_uint.width()).bound(y, 0, orig_uint.height());
f45.compute_at(diag, x);
f135.compute_at(diag, x);
f4x4.compute_at(diag, x);
diag.compute_root();

// compile so we can take a look at the code
diag.compile_to_lowered_stmt("diag.html", {}, HTML);    // stack oflo here

这是 Halide 中的一个错误。安德鲁亚当斯一小时前推送的修复程序(谢谢!)