PyTorch ExportedProgram
Load PyTorch ExportedProgram model, compute output, and generate deployable code
Since R2026a
Libraries:
MATLAB Coder Support Package for PyTorch & LiteRT Models
Description
Add-On Required: This feature requires the MATLAB Coder Support Package for PyTorch and LiteRT Models add-on.
The PyTorch ExportedProgram block loads a PyTorch ExportedProgram model. The block uses the PyTorch ExportedProgram model to run inference on the input data to compute the outputs. The block can generate deployable code.
To load a PyTorch ExportedProgram model, use the PyTorch ExportedProgram model file parameter. By default, the block has one input and output port, in1 and out1. When you load the PyTorch ExportedProgram file, the block updates the number of input and output ports specified in the file.
Note
You must export a PyTorch® model to a torch.export.ExportedProgram in PyTorch 2.8.0,
and save it as a PT2 PyTorch ExportedProgram file. For more information, see Prepare PyTorch Models for MATLAB and Simulink Code Generation.
Examples
Ports
Input
Output
Parameters
Alternative Functionality
You can use a MATLAB Function block, along with the invoke object
function of a PyTorchExportedProgram object, to compute output and generate code.
Extended Capabilities
Version History
Introduced in R2026a

