maedoc:

Tensor *q_t;


Oops this is a dumb question: the above just declares a pointer, but there’s nothing for allocate_temp to intialize.  Other routines would return a usable pointer with Tensor ** type argument, but allocate_temp takes just a Tensor * which needs to point to a usable Tensor instance (even if not allocated).  That’s why declaring a Tensor on the stack and then allocating it works via address:
Tensor x;
context->allocate_temp(..., &x);