分配函数的卤化物总大小是恒定的,但大于2 ^ 31-1

时间:2018-07-31 08:35:29

标签: halide

我正在处理一个处理图像突发的Halide项目。我的初始数据集是9个4208 * 3120像素的图像突发,格式为uint16_t。我在运行时遇到了constant_allocation_size错误:

“错误:

Total size for allocation layer_0 is constant but exceeds 2^31 - 1.
Aborted (core dumped)".

其中layer_0是使用compute_root()计划的降采样函数;

示例代码如下:

Func my_process(Func input, ...){
  <do something here...> 
  output.compute_root().parallel(y).vectorize(x, 16);
}

Func raw2gray(Func input, std::string name){
   ...
   compute_root();
}

Func imgs_mirror = BoundaryConditions::mirror_interior(imgs, 0, imgs.width(), 0, imgs.height());
Func layer_0 = raw2gray(imgs_mirror, "layer_0");
Func out_imgs = my_process(layer_0, ...);

有人知道如何缩小我的固定分配大小或如何增加2 ^ 31-1上限吗?

2 个答案:

答案 0 :(得分:0)

我自己弄清楚了。如果有人遇到类似问题,请在此处发布我的解决方案。

这是由我的功能边界说明引起的。尽管我将BoundaryConditions放置到输入图像中就足够了,所以我在后面的过程中并不关心函数边界问题。但是,由于我的后一个函数对图像进行分层处理并在其间操纵几个像素的坐标,因此计算回原始图像的边界限制会令人惊讶地大,从而导致镜像图像的大小高达8GB。

每次操作坐标后添加一个夹具,此问题得以解决。

答案 1 :(得分:0)

如果确实需要2 ^ 31-1个以上的元素,则可以在编译管道(JIT或AOT)时将Target::LargeBuffers添加到要使用的编译目标中。这将限制增加到2 ^ 63-1个元素。