我的文件是提前编译好的。我从图像中计算出小区域。在这些我想用重叠来规范化。因此 ia Func 就是用归约域计算因子。之后我尝试计算重叠的归一化区域。结果因此具有更大的尺寸。只要我意识到 Func 是它工作的小区域,当我尝试编译到 b 时,它就不再工作了,因为结果必须具有另一个维度作为 c 所需的维度。有没有办法根据输入或输出缓冲区尺寸设置 Func 的尺寸?或者您知道任何其他解决方法吗?
Func cells("cells");
c(g_x,g_y,g_i) = 0.0f;
// this is working
c(g_x, g_y, g_i) = ...
Var c_x("c_x"), c_y("c_y");
// calculate normalization factor
Func norm_factor("norm_factor");
// cpb means cells per block
RDom cbd (0,cpb,0,cpb,0, nBins);
Expr lx = c_x + cbd.x;
Expr ly = c_y + cbd.y;
Expr lz = cbd.z;
norm_factor(c_x, c_y) = 1 / sqrt(Halide::sum(c(lx, ly, lz) * c(lx, ly, lz)) + eta*eta );
// Caculate the normalized Blocks
Func b("blocks");
b(c_x,c_y,g_i) = 0.f;
b(c_x, c_y, g_i) = norm_factor(g_x, g_y) * c(g_x,g_y,g_i);
b.compile_to_file("halide",args);