LUT是否有任何限制:尺寸无限制 [英] Are there any restrictions with LUT: unbounded way in dimension

查看:109
本文介绍了LUT是否有任何限制:尺寸无限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试运行下面的示例代码(类似于查找表)时,它总是生成以下错误消息:函数'out'的纯定义以维度0的方式来无限制地调用函数'color'"

When trying to run the sample code below (similar to a look up table), it always generates the following error message: "The pure definition of Function 'out' calls function 'color' in an unbounded way in dimension 0".

RDom r(0, 10, 0, 10);
Func label, color, out;
Var x,y,c;

label(x,y) = 0;
label(r.x,r.y) = 1;

color(c) = 0;
color(label(r.x,r.y)) = 255;

out(x,y) = color(label(x,y));

out.realize(10,10);

在调用实现之前,我试图像下面这样静态设置边界,但没有成功.

Before calling realize, I have tried to statically set bound, like below, without success.

color.bound(c,0,10);
label.bound(x,0,10).bound(y,0,10);
out.bound(x,0,10).bound(y,0,10);

我也看了直方图示例,但是它们有些不同.

I also looked at the histogram examples, but they are a bit different.

这是Halide中的某种限制吗?

Is this some kind of restrictions in Halide?

推荐答案

卤化物可通过分析作为参数传递给Func的值的范围来防止任何越界访问(并决定要计算的内容).如果这些值是无界的,则无法做到这一点.使它们有界的方法是使用钳位:

Halide prevents any out of bounds access (and decides what to compute) by analyzing the range of the values you pass as arguments to a Func. If those values are unbounded, it can't do that. The way to make them bounded is with clamp:

out(x, y) = color(clamp(label(x, y), 0, 9));

在这种情况下,其不受限制的原因是标签具有更新定义,这使分析放弃了.如果您改写这样的标签:

In this case, the reason it's unbounded is that label has an update definition, which makes the analysis give up. If you wrote label like this instead:

label(x, y) = select(x >= 0 && x < 10 && y >= 0 && y < 10, 1, 0);

那么您就不需要夹子了.

Then you wouldn't need the clamp.

这篇关于LUT是否有任何限制:尺寸无限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆