Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement nested loop with indexing coordinates different from looping coordinates #8190

Open
mcoduoza opened this issue Apr 11, 2024 · 0 comments

Comments

@mcoduoza
Copy link

Hi,

I am trying to implement the following C++ equivalent code in Halide, whereby the coordinates used in the for loop are different from the coordinates used for assignment within the loop body (the assignment coordinates are computed inside the loop body):

`for (int ty = 0; ty < MAX_TY; ty++){

        for (int tx = 0; tx < MAX_TX; tx++){
            for (int yi = 0; yi < T_SIZE; yi++){
                for (int xi = 0; xi < T_SIZE; xi++){
                    int x = tx * T_SIZE/2 + xi;
                    int y = ty * T_SIZE/2 + yi;
                    output[y][x] += input[ty][tx][yi][xi];
                }
            }
        }
    }`

I tried to use the following Halide line to implement the loop:

output(tx * T_SIZE/2 + xi, ty * T_SIZE/2 + yi) += input(tx, ty, xi, yi)

whereby tx, ty, xi, and yi have been defined as Vars, and T_SIZE has been defined as a constant. However, running this code results in the following error: Undefined variable "tx" in definition of Func "output".

Why is this error message being thrown, and what would be an acceptable way to implement this nested for loop in Halide?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant