我无法理解为什么下面的Halide代码出现错误。 请让我知道我的错误。
Buffer<uint8_t> input(small_width, small_height, small_depth);
Var x("x"), y("y"), z("z");
Func blur_y1, blur_y2, blur_x1, blur_x2, blur_z1, blur_z2;
blur_y1(x,y,z) = (input(x,y-1,z) + input(x,y+1,z) + 2*input(x,y,z)) / 4;
blur_y2(x,y,z) = (blur_y1(x,y-1,z) + blur_y1(x,y+1,z) + 2*blur_y1(x,y,z)) / 4;
blur_x1(x,y,z) = (blur_y2(x-1,y,z) + blur_y2(x+1,y,z) + 2*blur_y2(x,y,z)) / 4;
blur_x2(x,y,z) = (blur_x1(x-1,y,z) + blur_x1(x+1,y,z) + 2*blur_x1(x,y,z)) / 4;
blur_z1(x,y,z) = (blur_x2(x,y,z-1) + blur_x2(x,y,z+1) + 2*blur_x2(x,y,z)) / 4;
blur_z2(x,y,z) = (blur_z1(x,y,z-1) + blur_z1(x,y,z+1) + 2*blur_z1(x,y,z)) / 4;
Buffer<uint8_t> out(small_width-2, small_height-2, small_depth-2);
out.set_min(1, 1, 1);
blur_z2.realize(out);
错误: 输入缓冲器b0在-1处访问,其在维度0
中的min(0)之前
答案 0 :(得分:3)
看起来模糊的总占用空间在每个方向都是两个像素,而不是一个,所以你需要:
Buffer<uint8_t> out(small_width-4, small_height-4, small_depth-4);
out.set_min(2, 2, 2);