Hi Richard,
Thanks! Removing that line does work, there’s now no error. The question now is: when would it be appropriate to flatten the parameters? The restrictions on in-place operations on leaf variables means that I have to clone, adjust, then write back the parameters every update which fragments them.
Do I just have to eat the performance penalty and find some intermittent opportunities to flatten them? Or can I do something smarter?