Unexpected Standard exception from MEX file (pytorch model forward)
When I call mex api from Matlab, I got an unexpected standard exception.
I exported 2 pytorch DNN models to 'A.pt' and 'B.pt' files.
And I implemented c++ functions that load models from the '.pt 'files and run models (forward).
The c++ implementation works fine, I can get proper results from the models.
I built the load &amp; run forward function into '.dll' library,
and I implemented a mex api function can call them.
When I call the mex api in Matlab environment,
the 2 models are loaded normally, and the first model runs forward properly.
However, when run forward the 2nd model, I got the following exception.

Unexpected Standard exception from MEX file
What():The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: error in LoadLibraryA

I have no clue why the c++ implementation works fine but the exception occurs when call it through mex api from Matlab.
Because the load &amp; run forward functions are unchanged I expected the exactly same results.
It is more difficult to debug because there is no call-stack print.
Is there any way to get call-stack ?
Please give me any advice.
Thanks in advance.
-environment-------------------------------
c++ compiler : visual studio 2017 community
matlab : R2020a
libtorch : 1.6
pytorch : 1.5
python : 3.6
cuda : 10.2


From Mr. Cris Luengo's comments, I solved this problem by copying all libtorch dlls into Matlab's own bin folder. There are several duplicated files but I overwrote them. I'm not sure it is safe or not, so may be backup of previous dlls is good choice. Thank you Mr. Cris Luengo.
