0

My file is compiled ahead of time. I calculate small Regions out of an Image. Over these i'd like to normalize with overlap. Therefore i a Func thats calculating the factor with Reduction Domains. Afterwards i try to calculate normalized Regions that are overlapping. The result therefore has a bigger size. As long as the Func i realize is the small Regions its working, when i try compile to b its not working anymore as the result has to have another dimension as the one needed for c. Is there any way to set dimensions for a Func depending on in- or output buffer dimension? Or do you know any other workarounds?

    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);

1 Answer 1

0

For one thing, b is defined using c_x, c_y, g_i but those Vars are not used in the definition.

Possibly you meant to say

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

or for only one b value per block

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.