Multiple Layers of For-Loops #8642
Unanswered
MichaelElexon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Could you provide a minimum reproducible example of your code please? (try to reduce it down to ~10-20 lines idealy) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey all.
I'm trying to do some iterative optimization and I'm struggling to figure out how I can nest for-loops.
My cost function has a for-loop in it (it calculate the cost by doing an operation over a vector field).
Each iteration needs to run the cost function with 27 different parameter combinations (thus I'm using a for-loop to iteratively feed these into the cost functions)
I want to perform 80000 iterations (thus I'm using a for-loop here too).
EG, the python code looks like this:
I get the following error when trying to implement these loops directly in taichi:
"struct_for cannot be nested inside a kernel"
As a result, I've put the outer loops in python context, but but I did some profiling and 85% of my computation time is coming from doing this.
I don't need the outer iterations to be parallelized (i'm choosing a new set of parameters based upon results, so I have to do iterations serially).
Is there a common solution for nesting these loops? Or another taichi-esque way of solving this problem?
Beta Was this translation helpful? Give feedback.
All reactions