loadLiteRTModel
R2026bSyntax
Description
Add-On Required: This feature requires the MATLAB Coder Support Package for PyTorch and LiteRT Models add-on.
loads a pretrained LiteRT model file.model = loadLiteRTModel(modelFileName)
loads a pretrained LiteRT model file using the specified execution mode.model = loadLiteRTModel(modelFileName,ExecutionMode=ExecutionMode)
Examples
Suppose that you have a LiteRT model named siso.tflite that takes one input and returns one output. Create a LiteRTModel object.
myModel = loadLiteRTModel("siso.tflite")Loading model... Model loaded.
myModel =
LiteRTModel contained in siso.tflite:
Input Specifications
_________________________________________________________________
Input Name Size Type
_____ _______ _________________________________ ________
1 "image" "<variable-size> x 128 x 128 x 3" "single"
Output Specifications
_________________________________________________________
Output Name Size Type
______ __________ _____________________ ________
1 "output_0" "<variable-size> x 1" "single"
properties:
ModelPath - Path to the model file
FcnNames - Names of the functions in the model
methods:
invoke - Performs forward inference by invoking a function in the model
inputSpecifications - Returns the input specifications of the model or of a specific function in the model
outputSpecifications - Returns the output specifications of the model or of a specific function in the model
summary - Displays the input and output specifications of the model or of a specific function in the model
Suppose that you have a LiteRT model named mimo.tflite that takes multiple inputs and returns multiple outputs.
Create a LiteRTModel object by using the MEX execution mode. To use the MEX execution mode, you must install a supported C compiler. For more information about setting up the C/C++ compiler, see Installing and Configuring Prerequisite Products.
myModel = loadLiteRTModel("mimo.tflite",ExecutionMode="MEX")
Loading model... Model loaded.
myModel =
LiteRTModel contained in mimo.tflite:
Input Specifications
___________________________________________________________
Input Name Size Type
_____ ____________ ______________________ ________
1 "features_a" "<variable-size> x 16" "single"
2 "features_b" "<variable-size> x 8" "single"
Output Specifications
_________________________________________________________
Output Name Size Type
______ __________ _____________________ ________
1 "output_1" "<variable-size> x 2" "single"
2 "output_0" "<variable-size> x 4" "single"
properties:
ModelPath - Path to the model file
FcnNames - Names of the functions in the model
methods:
invoke - Performs forward inference by invoking a function in the model
inputSpecifications - Returns the input specifications of the model or of a specific function in the model
outputSpecifications - Returns the output specifications of the model or of a specific function in the model
summary - Displays the input and output specifications of the model or of a specific function in the model
Input Arguments
Name of the LiteRT model file, specified as a character vector or a scalar string.
Example: "myModelName"
Example: "myfolder/myModelName"
Execution mode to use for MATLAB simulation behavior, specified as
"JIT" or "MEX".
JIT code is incompatible with the OpenMP application interface. JIT execution mode
does not support multi-threading. If you want to parallelize
for-loops, use MEX execution mode. You must install a supported C
compiler to use the MEX execution mode. For more information about setting up the C/C++
compiler, see Installing and Configuring Prerequisite Products.
Output Arguments
LiteRT model, returned as a LiteRTModel
object.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)