主要内容

outputSpecifications

Return output specifications for functions in PyTorch ExportedProgram or LiteRT model

Since R2026a

    Description

    Add-On Required: This feature requires the MATLAB Coder Support Package for PyTorch and LiteRT Models add-on.

    spec = outputSpecifications(model) returns the output specifications of the model.

    Note

    Use this syntax to extract specifications of a model that contains only one function. If a model contains multiple functions, you must specify the name of the function for which to extract the specifications.

    [___] = outputSpecifications(___,FcnName=FcnName) returns output specifications for the specified function in the model.

    example

    Examples

    collapse all

    This example shows how to display the output specifications for a specific function of a model.

    Load the LiteRT model named mimo.tflite by using the loadLiteRTModel function. It returns a LiteRTModel object named myModel.

    myModel = loadLiteRTModel("mimo.tflite")
    Loading the model. This may take a few minutes.
    
    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
    
    

    Extract the output specifications that describe the name, size, and data type of the output for the model.

    outputSpec = outputSpecifications(myModel)
    outputSpec = struct with fields:
        Name: {2×1 cell}
        Size: {2×1 cell}
        Type: {2×1 cell}
    
    

    The model has two outputs. Use dot notation to view the contents of each field.

    outputSpec.Name
    ans = 2×1 cell
        {'output_1'}
        {'output_0'}
    
    

    Input Arguments

    collapse all

    Input model, specified as either:

    Name of function for which to return the output specifications, specified as a character vector or string scalar.

    Example: "predict"

    Example: "plus_miso_3x4x5"

    Output Arguments

    collapse all

    Output specifications, returned as a scalar structure array.

    The structure contains these fields.

    Field Name

    Description

    Data Type

    Name

    Output name

    cell

    Size

    Size of the output data

    cell

    Type

    Output data type

    cell

    Extended Capabilities

    expand all

    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