I think we were typing at the same time and you posted yours right before mine 
I personally don’t think this error is due to RTOS strict memory policies.
This is a compile error, this is related to how you use the libtorch apis in main.cpp, to me, this is more like an implementation error.
Can you try just include several libtorch headers without doing anything in main.cpp, see whether you can compile it successfully?