loadPyTorchExportedProgram
R2026bSyntax
Description
Add-On Required: This feature requires the MATLAB Coder Support Package for PyTorch and LiteRT Models add-on.
loads a pretrained PyTorch® ExportedProgram model file.model = loadPyTorchExportedProgram(modelFileName)
Note
This function takes a PyTorch ExportedProgram model file as input.
You must first export a PyTorch model to a torch.export.ExportedProgram in PyTorch
version 2.7.1 to version 2.11, and save it as a PT2 PyTorch ExportedProgram file. For more
information, see Prepare PyTorch Models for MATLAB and Simulink Code Generation.
loads a pretrained PyTorch ExportedProgram model file using the specified execution mode.model = loadPyTorchExportedProgram(modelFileName,ExecutionMode=ExecutionMode)
Examples
Input Arguments
Output Arguments
Limitations
The code generator might apply optimizations that assume the absence of NaN values, which can affect NaN propagation behavior. If model inputs contain NaN values, generated code might produce different results from the reference framework.
Extended Capabilities
Version History
Introduced in R2026a