Skip to content

FAQ: What is the most effective way to convert between casadi.DM and torch.tensor (pytorch) other than using numpy in between?

András Retzler edited this page Oct 7, 2022 · 2 revisions

The simplest way to convert variable u:

casadi.DM(u.detach().numpy())

There is a low overhead buffer API to evaluate CasADi Functions from Python here:

https://github.com/casadi/casadi/blob/master/test/python/function.py#L2541

FAQTODO write up how to use that.

Clone this wiki locally