约束: 1. 有一个指向具有大小边距的图像的指针 (ImHeight,ImWidth) 2. 过滤器大小 (FH,FW) ;FH,FW 为奇数 3. ActualImageHeight = ImHeight-2*(FH/2); ActualImageWidth = ImWidth-2*(FW/2);
如何:
- 用指针初始化图像,使图像(0,0)是像素(0,0)而不是边缘像素?
- 在不使用边界条件/钳位的情况下定义时间表 - 因为给定的图像指针内存已经占了边距
约束: 1. 有一个指向具有大小边距的图像的指针 (ImHeight,ImWidth) 2. 过滤器大小 (FH,FW) ;FH,FW 为奇数 3. ActualImageHeight = ImHeight-2*(FH/2); ActualImageWidth = ImWidth-2*(FW/2);
如何:
修改图像的最小坐标。您没有说明您使用的是 JIT 还是 AOT,但这是一个 JIT 实现。
Halide::Image input( ImWidth + 2 * FW, ImHeight + 2 * FH ), output;
input.set_min( -FW, -FH );
Func f;
f(x,y) = ( input( x - FW, y - FH ) + input( x + FW - 1, y + FH - 1 ) ) / 2;
output = f.realize( ImWidth, ImHeight );
对于 AOT:
ImageParam
_input
Param<int>
forImWidth
并使ImHeight
它们成为 AOT 函数的参数。int
。ImWidth
ImHeight
set_bounds
对和set_stride
的所有维度使用input
和f.output_buffer()
。如果是 a ,这些 take Expr
s 所以会接受。ImWidth + 2 * FW
ImWidth
Param<int>