【问题标题】:Creating fixed dimension Halide pipelines创建固定尺寸的卤化物管道
【发布时间】:2016-08-23 01:45:43
【问题描述】:

我的文件是提前编译好的。 我从图像中计算出小区域。在这些我想用重叠来规范化。因此,我是一个 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);

【问题讨论】:

    标签: c++ halide


    【解决方案1】:

    一方面,b 是使用 c_x, c_y, g_i 定义的,但那些 Vars 没有在定义中使用。

    你可能是想说

    b(c_x, c_y, g_i)= norm_factor(c_x, c_y) * c(c_x, c_y, g_i);
    

    或者每个块只有一个 b

    b(c_x, c_y, g_i)   = norm_factor(c_x * cpb, c_y * cpb) * c(c_x * cpb, c_y * cpb, g_i);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多