Supported Functions

You can generate CUDA® code for a subset of MATLAB® built-in functions and toolbox functions that you call from MATLAB code. These functions appear in alphabetical order in the following table. Some of these functions especially from the Image Processing Toolbox™ contain calls to other functions, GPU Coder™ does not create CUDA kernels for all the loops and functions that the parent function relies on. However, GPU Coder does generate C/C++ code for sections that cannot be mapped to the GPU. The results from the code generated for functions in this list are also numerically equivalent (within tolerance) to its MATLAB counterpart. See, Numerical Differences Between CPU and GPU.

Name

Product

Usage Notes and Limitations

abs

MATLAB

No known limitation

accumneg

Fixed-Point Designer™

No known limitation

accumpos

Fixed-Point Designer

No known limitation

acos

MATLAB

Generates an error during simulation and returns NaN in generated code when the input value X is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(X).

acosd

MATLAB

No known limitation

acosh

MATLAB

Generates an error during simulation and returns NaN in generated code when the input value X is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(X).

acot

MATLAB

No known limitation

acotd

MATLAB

No known limitation

activations

Deep Learning Toolbox™

  • GPU code generation supports the following syntaxes:

    • features = activations(net,X,layer)

    • features = activations(__,Name,Value)

  • The input X must not have variable size. The size must be fixed at code generation time.

  • GPU code generation for the activations function supports inputs that are defined as half-precision floating point data types. For more information, see half.

  • The layer argument must be a compile-time constant.

  • Only the 'OutputAs' and 'MiniBatchSize' name-value pair arguments are supported for code generation. The value of the 'OutputAs' name-value pair must be 'channels'.

  • All name-value pairs must be compile-time constants.

adaptthresh

Image Processing Toolbox

The ForegroundPolarity and Statistic arguments must be compile-time constants.

affine2d

Image Processing Toolbox

When generating code, you can only specify singular objects—arrays of objects are not supported.

alexnet

Deep Learning Toolbox

and

MATLAB

No known limitation

angle

MATLAB

No known limitation

asin

MATLAB

Generates an error during simulation and returns NaN in generated code when the input value X is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(X).

asind

MATLAB

No known limitation

asinh

MATLAB

No known limitation

atan

MATLAB

No known limitation

atan2

MATLAB

If you use atan2 with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

atan2d

MATLAB

If you use atan2d with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

atand

MATLAB

No known limitation

atanh

MATLAB

Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

bin2dec

MATLAB

  • Input text must be specified as a character array. Cell arrays are not supported.

  • When the input is empty, the answer does not match the answer in MATLAB.

bitand

MATLAB

No known limitation

bitcmp

MATLAB

No known limitation

bitget

MATLAB

No known limitation

bitor

MATLAB

No known limitation

bitrevorder

Signal Processing Toolbox™

No known limitation

bitset

MATLAB

No known limitation

bitshift

MATLAB

No known limitation

bitsll

Fixed-Point Designer

Generated code might not handle out of range shifting.

bitsra

Fixed-Point Designer

Generated code might not handle out of range shifting.

bitsrl

Fixed-Point Designer

Generated code might not handle out of range shifting.

bitxor

MATLAB

No known limitation

blkdiag

MATLAB

No known limitation

bsxfun

MATLAB

Code generation does not support sparse matrix inputs for this function.

bwareaopen

Image Processing Toolbox

  • BW must be a 2-D binary image. N-D arrays are not supported.

  • conn must be one of the two-dimensional connectivities (4 or 8) or a 3-by-3 matrix. The 3-D connectivities (6, 18, and 26) are not supported. Matrices of size 3-by-3-by-...-by-3 are not supported.

  • conn must be a compile-time constant.

bwboundaries

Image Processing Toolbox

  • The parameter conn must be a compile-time constant.

  • The parameter options must be a compile-time constant.

  • The return value A can only be a full matrix, not a sparse matrix.

bwconncomp

Image Processing Toolbox

  • bwconncomp only supports 2-D inputs.

  • The conn arguments must be a compile-time constant and the only connectivities supported are 4 or 8. You can also specify connectivity as a 3-by-3 matrix, but it can only be [0 1 0;1 1 1;0 1 0] or ones(3)

  • The PixelIdxList field in the CC struct return value is not supported.

bwdist

Image Processing Toolbox

When generating code, the optional second input argument, method, must be a compile-time constant. Input images must have fewer than 232 pixels.

bweuler

Image Processing Toolbox

No known limitation

bwlabel

Image Processing Toolbox

When generating code, the parameter n must be a compile-time constant.

bwlookup

Image Processing Toolbox

When generating code, specify an input image of class logical.

bwmorph

Image Processing Toolbox

When generating code, the character vectors or string scalars specifying the operation must be a compile-time constant and, for best results, the input image must be of class logical.

bwperim

Image Processing Toolbox

  • bwperim supports only 2-D images.

  • bwperim does not support a no-output-argument syntax.

  • The connectivity matrix input argument, conn, must be a constant.

bwselect

Image Processing Toolbox

  • When generating code, bwselect supports only these syntaxes:

    • BW2 = bwselect(BW, c, r)

    • [BW2, idx] = bwselect(BW, c, r)

    • BW2 = bwselect(BW, c, r, n)

    • [BW2, idx] = bwselect(BW, c, r, n)

  • In addition, the optional fourth input argument, n, must be a compile-time constant.

bwtraceboundary

Image Processing Toolbox

When generating code, the dir, fstep, and conn arguments must be compile-time constants.

bwunpack

Image Processing Toolbox

When generating code, all input arguments must be compile-time constants.

cart2pol

MATLAB

No known limitation

cast

MATLAB

Enumeration inputs must be scalar valued at compile time. Arrays of enumerations are not supported.

ceil

MATLAB

Code generation does not support char or logical data types for X.

chol

MATLAB

Only the first two syntaxes chol(A) and chol(A,triangle) with one output argument are supported.

circshift

MATLAB

Code generation does not support tables and cells for the first input argument.

classify

Deep Learning Toolbox

  • GPU code generation supports the following syntaxes:

    • [YPred,scores] = classify(net,X)

    • [YPred,scores] = classify(net,sequences)

    • [YPred,scores] = classify(__,Name,Value)

  • GPU code generation for the classify function is not supported for regression networks and networks with multiple outputs.

  • GPU code generation for the classify function supports inputs that are defined as half-precision floating point data types. For more information, see half.

  • The input X must not have variable size. The size must be fixed at code generation time.

  • GPU code generation supports only vector sequences. The sequence length can be variable sized. The feature dimension must be fixed at code generation time.

  • Only the 'MiniBatchSize', 'SequenceLength', 'SequencePaddingDirection', and 'SequencePaddingValue' name-value pair arguments are supported for code generation. All name-value pairs must be compile-time constants.

  • Only the 'longest' and 'shortest' option of the 'SequenceLength' name-value pair is supported for code generation.

classUnderlying

MATLAB

No known limitation

compan

MATLAB

No known limitation

complex

MATLAB

No known limitation

conj

MATLAB

No known limitation

conndef

Image Processing Toolbox

When generating code, the num_dims and type arguments must be compile-time constants.

conv

MATLAB

If the inputs have nonfinite values (inf or NaN), the results from the generated code may not numerically match MATLAB simulation.

conv2

MATLAB

If the inputs have nonfinite values (inf or NaN), the results from the generated code may not numerically match MATLAB simulation.

cos

MATLAB

No known limitation

cosh

MATLAB

No known limitation

cot

MATLAB

No known limitation

coth

MATLAB

No known limitation

cross

MATLAB

  • If supplied, dim must be a constant.

  • Code generation does not support sparse matrix inputs for this function.

csc

MATLAB

No known limitation

csch

MATLAB

No known limitation

ctranspose

MATLAB

No known limitation

cwt

Wavelet Toolbox™

  • Single- and double-precision input signal are supported. The precision must be set at compile time.

  • Timetable input signal is not supported.

  • Only analytic Morse ('morse') and Morlet ('amor') wavelets are supported.

  • The following input arguments are not supported: Sampling period (ts), PeriodLimits name-value pair, NumOctave name-value pair, and FilterBank name-value pair.

  • Scaling coefficient output and filter bank output are not supported.

  • Plotting is not supported.

cummax

MATLAB

No known limitation

cummin

MATLAB

No known limitation

cumprod

MATLAB

  • Logical inputs are not supported. Cast input to double first.

  • Code generation does not support sparse matrix inputs for this function.

cumsum

MATLAB

  • Logical inputs are not supported. Cast input to double first.

  • Code generation does not support sparse matrix inputs for this function.

DAGNetwork

Deep Learning Toolbox

darknet19

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = darknet19 or by passing the darknet19 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('darknet19').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax darknet19('Weights','none') is not supported for GPU code generation.

darknet53

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = darknet53 or by passing the darknet53 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('darknet53').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax darknet53('Weights','none') is not supported for GPU code generation.

deg2rad

MATLAB

No known limitation

del2

MATLAB

No known limitation

demosaic

Image Processing Toolbox

sensorAlignment must be a compile-time constant.

deeplabv3plusLayers

Deep Learning Toolbox

For code generation, you must first create a DeepLab v3+ network by using the deeplabv3plusLayers function. Then, use the trainNetwork function on the resulting lgraph object to train the network for segmentation. Once the network is trained and evaluated, you can generate code for the deep learning network object using GPU Coder.

densenet201

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = densenet201 or by passing the densenet201 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('densenet201').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax densenet201('Weights','none') is not supported for GPU code generation.

det

MATLAB

Code generation does not support sparse matrix inputs for this function.

diag

MATLAB

  • If you supply k, then it must be a real and scalar integer value.

  • For variable-size inputs that are variable-length vectors (1-by-: or :-by-1), diag:

    • Treats the input as a vector

    • Returns a matrix with the input vector along the specified diagonal

  • For variable-size inputs that are not variable-length vectors, diag:

    • Treats the input as a matrix

    • Does not support inputs that are vectors at run time

    • Returns a variable-length vector

    If the input is variable-size (:m-by-:n) and has shape 0-by-0 at run time, then the output is 0-by-1, not 0-by-0. However, if the input is a constant size 0-by-0, then the output is [].

  • For variable-size inputs that are not variable-length vectors (1-by-: or :-by-1), diag treats the input as a matrix from which to extract a diagonal vector. This behavior occurs even if the input array is a vector at run time. To force diag to build a matrix from variable-size inputs that are not 1-by-: or :-by-1, use:

    • diag(x(:)) instead of diag(x)

    • diag(x(:),k) instead of diag(x,k)

disparitySGM

Computer Vision Toolbox™

  • The input images I1 and I2 must be rectified, same size, and of same data type.

  • GPU code generation supports the 'UniquenessThreshold' and 'disparityMap' name-value pairs.

  • For very large inputs, the memory requirements of the algorithm may exceed the GPU device limits. In such cases, consider reducing the input size to proceed with code generation.

double

MATLAB

For string inputs with misplaced commas (commas that are not used as thousands separators), generated code results can differ from MATLAB results.

edge

Image Processing Toolbox

  • The method, direction, and sigma arguments must be compile-time constants.

  • The 'approxcanny' method is not supported.

  • Nonprogrammatic syntaxes are not supported. For example, if you do not specify a return value, then edge displays an image. This syntax is not supported with code generation.

exp

MATLAB

No known limitation

eye

MATLAB

  • typename must be a built-in MATLAB numeric type. Does not invoke the static eye method for other classes. For example, eye(m, n, 'myclass') does not invoke myclass.eye(m,n).

  • Size arguments must have a fixed size.

factorial

MATLAB

No known limitation

fft

MATLAB

No known limitation

fft2

MATLAB

No known limitation

fftfilt

Signal Processing Toolbox

Digital filter objects are not supported for code generation.

fftn

MATLAB

The sz argument must have a fixed size.

fftshift

MATLAB

No known limitation

filter

MATLAB

filter2

MATLAB

No known limitation

fitgeotrans

Image Processing Toolbox

  • When generating code, the transformationType argument must be a compile-time constant and only the following transformation types are supported: 'nonreflectivesimilarity', 'similarity', 'affine', and 'projective'.

fix

MATLAB

Code generation does not support char or logical data types for X.

floor

MATLAB

Code generation does not support char or logical data types for X.

fspecial

Image Processing Toolbox

When generating code, all inputs must be constants at compilation time.

gather

MATLAB

No known limitation

ge

MATLAB

No known limitation

getrangefromclass

MATLAB

No known limitation

googlenet

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = googlenet or by passing the googlenet function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('googlenet').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax googlenet('Weights','none') is not supported for GPU code generation.

gt

MATLAB

No known limitation

half

MATLAB

  • CUDA compute capability of 5.3 or higher is required for generating and executing code with half-precision data types.

  • CUDA toolkit version of 10.0 or higher is required for generating and executing code with half-precision data types.

  • The memory allocation (malloc) mode for generating CUDA code must be set to 'Discrete'.

    For more information, see coder.gpuConfig.

  • Half-precision complex data types are not supported for GPU code generation.

  • For GPU Code generation, half-precision matrix multiplication can only be performed with real inputs.

  • In MATLAB, the isobject function returns true with a half-precision input. However, in generated code, this function returns false.

  • If your target hardware does not have native support for half-precision, then half is used as a storage type, with arithmetic operations performed in single precision.

  • Some functions use half only as a storage type and the arithmetic is always performed in single-precision, regardless of the target hardware.

  • Code generation for 32-bit targets is not supported if your MATLAB code contains half-precision data types.

histeq

Image Processing Toolbox

When generating code, histeq does not support indexed images.

hough

Image Processing Toolbox

  • The optional parameters 'Theta' and 'RhoResolution' must be compile-time string constants.

  • The optional Theta vector must have a bounded size.

houghlines

Image Processing Toolbox

The optional parameter names 'FillGap' and 'MinLength' must be compile-time constants. Their associated values need not be compile-time constants.

houghpeaks

Image Processing Toolbox

The optional parameter names 'Threshold' and 'NHoodSize' must be compile-time constants. Their associated values need not be compile-time constants.

hsv2rgb

MATLAB

No known limitation

hypot

MATLAB

If you use hypot with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

ifft

MATLAB

ifft2

MATLAB

Symmetry type 'symmetric' is not supported.

ifftn

MATLAB

  • Symmetry type 'symmetric' is not supported.

  • The sz argument must have a fixed size.

ifftshift

MATLAB

No known limitation

im2double

MATLAB

No known limitation

im2int16

Image Processing Toolbox

No known limitation

im2single

Image Processing Toolbox

No known limitation

im2uint8

Image Processing Toolbox

No known limitation

imabsdiff

Image Processing Toolbox

No known limitation

imadjust

Image Processing Toolbox

When generating code, imadjust does not support indexed images.

imag

MATLAB

No known limitation

imbinarize

Image Processing Toolbox

When generating code, all character vector input arguments must be compile-time constants.

imbothat

Image Processing Toolbox

  • The input image I must be 2-D or 3-D.

  • The structuring element SE must be a compile-time constant.

imboxfilt

Image Processing Toolbox

When generating code, all character vector input arguments must be compile-time constants.

imclearborder

Image Processing Toolbox

  • Supports only up to 3-D inputs.

  • The optional second input argument, conn, must be a compile-time constant.

imclose

Image Processing Toolbox

  • The input image I must be 2-D or 3-D.

  • The structuring element SE must be a compile-time constant.

imcomplement

Image Processing Toolbox

imcomplement does not support int64 and uint64 data types.

imcrop

Image Processing Toolbox

  • The interactive syntaxes are not supported, including:

    • J = imcrop

    • J = imcrop(I)

    • X2 = imcrop(X,cmap)

    • J = imcrop(h)

  • Indexed images are not supported, including the non-interactive syntax X2 = imcrop(X,cmap,rect);

imdilate

Image Processing Toolbox

  • The input image, IM, must be 2-D or 3-D.

  • The structuring element argument SE must be a compile-time constant.

  • Packed binary input image (PACKOPT syntax) is not supported.

  • For 3-D input images with more than three channels, only C/C++ code is generated.

  • CUDA code is generated only for 1-D or 2-D structuring elements. If the structuring element is 3-D, C/C++ code is generated. Code generation is not supported for structuring elements with more than three dimensions.

  • For non-flat structuring elements, only C/C++ code is generated.

imerode

Image Processing Toolbox

imfill

Image Processing Toolbox

  • The optional input arguments, conn and 'holes', must be compile-time constants.

  • imfill supports up to 3-D inputs only. (No N-D support.)

  • The interactive syntax to select points, imfill(BW,0,CONN) is not supported.

  • With the locations input argument, once you select a format at compile time, you cannot change it at run time. However, the number of points in locations can be varied at run time.

imfilter

Image Processing Toolbox

  • When generating code, the input image, A, must be 2-D or 3-D. The value of the input argument, options, must be a compile-time constant.

  • If you specify a large kernel h, a kernel that contains large values, or specify an image containing large values, you can see different results between MATLAB and generated code using codegen for floating point data types. This happens because of accumulation errors due to different algorithm implementations.

  • With CUDA toolkit v9.0, a bug in the NVIDIA® optimization causes numerical mismatch between the results from the generated code and MATLAB. As a workaround, turn off the optimization by passing the following flags to the configuration object (cfg) before generating the code.

    cfg.GpuConfig.CompilerFlags = ‘-Xptxas -O0’

    NVIDIA is expected to fix this bug in CUDA toolkit v9.1.

imgaussfilt

Image Processing Toolbox

  • imgaussfilt does not support the FilterDomain parameter for code generation. Filtering is always done in the 'spatial' domain in generated code.

  • When generating code, all character vector input arguments must be compile-time constants.

imgradient3

Image Processing Toolbox

When generating code, the input argument method must be a compile-time constant.

imgradientxyz

Image Processing Toolbox

When generating code, the input argument method must be a compile-time constant.

imhist

Image Processing Toolbox

  • If the first input is a binary image, then n must be a scalar constant of value 2 at compile time.

  • Nonprogrammatic syntaxes are not supported. For example, the syntax imhist(I), where imhist displays the histogram, is not supported.

imhmax

Image Processing Toolbox

When generating code, the optional third input argument, conn, must be a compile-time constant.

immse

Image Processing Toolbox

No known limitation

imopen

Image Processing Toolbox

  • The input image I must be 2-D or 3-D.

  • The structuring element SE must be a compile-time constant.

imoverlay

Image Processing Toolbox

When generating code, if you specify color as a character vector, then the value must be a compile-time constant.

imreconstruct

Image Processing Toolbox

  • When generating code, the optional third input argument, conn, must be a compile-time constant, and can only take the value 4 or 8.

  • imreconstruct does not support uint64 and int64 data types for code generation.

impyramid

Image Processing Toolbox

direction must be a compile-time constant.

imquantize

Image Processing Toolbox

No known limitation

imread

Image Processing Toolbox

  • Supports reading of 8-bit JPEG images only. The input argument filename must be a valid absolute path or relative path.

imresize

Image Processing Toolbox

  • 'Colormap' and 'Dither' Name-Value pair arguments are not supported.

  • Indexed image is not supported.

  • Custom interpolation kernel is not supported.

  • For certain interpolation kernels, there may be a small numerical mismatch between the results in MATLAB and the generated code.

imrotate

Image Processing Toolbox

  • Input images of data type categorical are not supported.

  • The method and bbox arguments must be compile-time constants.

imtophat

Image Processing Toolbox

  • The image input I must be 2-D or 3-D.

  • The structuring element SE must be a compile-time constant.

imwarp

Image Processing Toolbox

  • Input images of data type categorical are not supported.

  • The geometric transformation object input, tform, must be an affine2d or projective2d object and must be constant.

  • The interpolation method and optional parameter names must be constants.

  • The spatial referencing information output, RB, is not supported.

inceptionresnetv2

Deep Learning Toolbox

For code generation, you can load the network by using the syntax net = inceptionresnetv2 or by passing the inceptionresnetv2 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('inceptionresnetv2')

For more information, see Load Pretrained Networks for Code Generation.

inceptionv3

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = inceptionv3 or by passing the inceptionv3 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('inceptionv3').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax inceptionv3('Weights','none') is not supported for GPU code generation.

int8, int16, int32, int64

MATLAB

No known limitation

integralBoxFilter

Image Processing Toolbox

The 'NormalizationFactor' parameter must be a compile-time constant.

interp2

MATLAB

  • Xq and Yq must be the same size. Use meshgrid to evaluate on a grid.

  • For best results, provide X and Y as vectors. The values in these vectors must be strictly monotonic and increasing.

  • Code generation does not support the 'makima' interpolation method.

  • For the 'cubic' interpolation method, if the grid does not have uniform spacing, an error results. In this case, use the 'spline' interpolation method.

  • For best results when you use the 'spline' interpolation method:

    • Use meshgrid to create the inputs Xq and Yq.

    • Use a small number of interpolation points relative to the dimensions of V. Interpolating over a large set of scattered points can be inefficient.

intlut

Image Processing Toolbox

No known limitation

isaUnderlying

MATLAB

No known limitation

isequal

MATLAB

No known limitation

isfloat

MATLAB

No known limitation

isinteger

MATLAB

No known limitation

islogical

MATLAB

No known limitation

ismatrix

MATLAB

No known limitation

isnumeric

MATLAB

No known limitation

isreal

MATLAB

No known limitation

isrow

MATLAB

No known limitation

issparse

MATLAB

No known limitation

issymmetric

MATLAB

Code generation does not support sparse matrix inputs for this function.

istft

Signal Processing Toolbox

The 'ConjugateSymmetric' argument is not supported for code generation.

istril

MATLAB

Code generation does not support sparse matrix inputs for this function.

istriu

MATLAB

Code generation does not support sparse matrix inputs for this function.

isvector

MATLAB

No known limitation

kron

MATLAB

Code generation does not support sparse matrix inputs for this function.

lab2rgb

Image Processing Toolbox

When generating code, all character vector input arguments must be compile-time constants.

label2idx

Image Processing Toolbox

No known limitation

ldivide

MATLAB

If you use ldivide with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

le

MATLAB

No known limitation

length

MATLAB

No known limitation

linsolve

MATLAB

  • The opts structure must be a constant scalar. Code generation does not support arrays of options structures.

  • Code generation only optimizes these cases:

    • UT

    • LT

    • UHESS = true (the TRANSA can be either true or false)

    • SYM = true and POSDEF = true

    Other options are equivalent to using mldivide.

  • Code generation does not support sparse matrix inputs for this function.

log

MATLAB

When the input value x is real, but the output should be complex, simulation ends with an error. To produce the complex result, make the input value complex by passing in complex(x).

log10

MATLAB

No known limitation

log1p

MATLAB

No known limitation

logical

MATLAB

No known limitation

lt

MATLAB

No known limitation

lu

MATLAB

Code generation does not support sparse matrix inputs for this function.

matchFeatures

Computer Vision Toolbox

CUDA code is generated only for the exhaustive matching method. If the Approximate method is selected, GPU Coder issues a warning and generates C/C++ code for this function.

mean

MATLAB

  • If you specify dim, then it must be a constant.

  • The outtype and nanflag options must be constant character vectors.

  • Integer types do not support the 'native' output data type option.

mean2

Image Processing Toolbox

No known limitation

medfilt2

Image Processing Toolbox

When generating code, the padopt argument must be a compile-time constant.

meshgrid

MATLAB

No known limitation

mfcc

Audio Toolbox™

No known limitation

minus

MATLAB

If you use minus with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

mldivide

MATLAB

No known limitation

mobilenetv2

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = mobilenetv2 or by passing the mobilenetv2 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('mobilenetv2')

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax mobilenetv2('Weights','none') is not supported for GPU code generation.

mpower

MATLAB

  • If A is a 2-by-2 or larger matrix and B is Inf or -Inf, then A^B returns a matrix of NaN values.

  • For A^b, if b is a noninteger scalar, then at least one of A or b must be complex.

  • Code generation does not support sparse matrix inputs for this function.

mrdivide

MATLAB

Code generation does not support sparse matrix inputs for this function.

mtimes

MATLAB

Multiplication of pure imaginary numbers by non-finite numbers might not match MATLAB. The code generator does not specialize multiplication by pure imaginary numbers—it does not eliminate calculations with the zero real part. For example, (Inf + 1i)*1i = (Inf*0 – 1*1) + (Inf*1 + 1*0)i = NaN + Infi.

multithresh

Image Processing Toolbox

The input argument N must be a compile-time constant.

NaN or nan

MATLAB

Dimensions must be real, nonnegative, integers.

nasnetmobile

Deep Learning Toolbox

For code generation, you can load the network by using the syntax net = nasnetmobile or by passing the nasnetmobile function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('nasnetmobile')

For more information, see Load Pretrained Networks for Code Generation.

nasnetlarge

Deep Learning Toolbox

For code generation, you can load the network by using the syntax net = nasnetlarge or by passing the nasnetlarge function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('nasnetlarge')

For more information, see Load Pretrained Networks for Code Generation.

ne

MATLAB

Code generation does not support using ne to test inequality between an enumeration member and a string array, a character array, or a cell array of character arrays.

nextpow2

MATLAB

No known limitation

nnz

MATLAB

No known limitation

numel

MATLAB

No known limitation

ones

MATLAB

Dimensions must be real, nonnegative integers.

ordfilt2

Image Processing Toolbox

  • GPU code generation requires the inputs to be bounded. If the input is of variable dimension, the software generates C code.

  • When generating code, the padopt argument must be a compile-time constant.

  • The generated GPU code is not optimized if the domain value that defines the neighborhood for the filtering operation is of size greater than 11x11.

    For better performance, consider setting the StackLimitPerThread option in the coder.gpuConfig object to Inf.

otsuthresh

Image Processing Toolbox

No known limitation

padarray

Image Processing Toolbox

  • Input arrays of data type categorical are not supported.

  • When generating code, padarray supports only up to 3-D inputs.

  • The input arguments padval and direction must be compile-time constants.

pdist Statistics and Machine Learning Toolbox™

  • The supported distance input argument values (Distance) for optimized CUDA code are 'euclidean', 'squaredeuclidean', 'seuclidean', 'cityblock', 'minkowski', 'chebychev', 'cosine', 'correlation', 'hamming', and 'jaccard'.

  • Distance cannot be a custom distance function.

  • Distance must be a compile-time constant.

pdist2 Statistics and Machine Learning Toolbox

  • The supported distance input argument values (Distance) for optimized CUDA code are 'euclidean', 'squaredeuclidean', 'seuclidean', 'cityblock', 'minkowski', 'chebychev', 'cosine', 'correlation', 'hamming', and 'jaccard'.

  • Distance cannot be a custom distance function.

  • Distance must be a compile-time constant.

  • Names in name-value pair arguments must be compile-time constants.

  • The sorted order of tied distances in the generated code can be different from the order in MATLAB due to numerical precision.

plus

MATLAB

If you use plus with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

pointCloud

Computer Vision Toolbox

  • GPU code generation for variable input sizes is not optimized. Consider using constant size inputs for an optimized code generation.

  • GPU code generation supports the 'Color', 'Normal', and 'Intensity' name-value pairs.

  • GPU code generation supports the findNearestNeighbors, findNeighborsInRadius, findPointsInROI, removeInvalidPoints, and select methods.

  • For very large inputs, the memory requirements of the algorithm may exceed the GPU device limits. In such cases, consider reducing the input size to proceed with code generation.

pol2cart

MATLAB

No known limitation

polyint

MATLAB

No known limitation

pow2

Fixed-Point Designer

No known limitation

power

MATLAB

  • When both X and Y are real, but power(X,Y) is complex, simulation produces an error and generated code returns NaN. To get the complex result, make the input value X complex by passing in complex(X). For example, power(complex(X),Y).

  • When both X and Y are real, but X .^ Y is complex, simulation produces an error and generated code returns NaN. To get the complex result, make the input value X complex by using complex(X). For example, complex(X).^Y.

  • Code generation does not support sparse matrix inputs for this function.

predict

Deep Learning Toolbox

  • GPU code generation supports the following syntaxes:

    • YPred = predict(net,X)

    • [YPred1,...,YPredM] = predict(__)

    • YPred = predict(net,sequences)

    • __ = predict(__,Name,Value)

  • The input X must not have variable size. The size must be fixed at code generation time.

  • GPU code generation for the predict function supports inputs that are defined as half-precision floating point data types. For more information, see half.

  • GPU code generation supports only vector sequences. The sequence length can be variable sized. The feature dimension must be fixed at code generation time.

  • Only the 'MiniBatchSize', 'SequenceLength', 'SequencePaddingDirection', and 'SequencePaddingValue' name-value pair arguments are supported for code generation. All name-value pairs must be compile-time constants.

  • Only the 'longest' and 'shortest' option of the 'SequenceLength' name-value pair is supported for code generation.

predictAndUpdateState

Deep Learning Toolbox

  • GPU code generation supports the following syntaxes:

    • [updatedNet,YPred] = predictAndUpdateState(recNet,sequences)

    • [updatedNet,YPred] = predictAndUpdateState(__,Name,Value)

  • GPU code generation for the predictAndUpdateState function is only supported for recurrent neural networks and cuDNN target library.

  • GPU code generation supports only vector sequences. The sequence length can be variable sized. The feature dimension must be fixed at code generation time.

  • Only the 'MiniBatchSize', 'SequenceLength', 'SequencePaddingDirection', and 'SequencePaddingValue' name-value pair arguments are supported for code generation. All name-value pairs must be compile-time constants.

  • Only the 'longest' and 'shortest' option of the 'SequenceLength' name-value pair is supported for code generation.

prod

MATLAB

If you supply dim, it must be a constant.

projective2d

Image Processing Toolbox

When generating code, you can only specify singular objects—arrays of objects are not supported.

psnr

Image Processing Toolbox

No known limitation

qr

MATLAB

Code generation does not support sparse matrix inputs for this function.

rad2deg

MATLAB

No known limitation

rank

MATLAB

Code generation does not support sparse matrix inputs for this function.

resetState

Deep Learning Toolbox

GPU code generation for the resetState function is only supported for recurrent neural networks and cuDNN target library.

rcond

MATLAB

Code generation does not support sparse matrix inputs for this function.

rdivide

MATLAB

If you use rdivide with single type and double type operands, the generated code might not produce the same result as MATLAB. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).

real

MATLAB

No known limitation

reallog

MATLAB

No known limitation

realsqrt

MATLAB

No known limitation

rectint

MATLAB

No known limitation

repelem

MATLAB

The input must be a vector or matrix. The input cannot be a multidimensional array.

repmat

MATLAB

  • Size arguments must have a fixed size.

  • For sparse matrices, the repmat function does not support trailing ones as inputs after the first two dimensions.

reshape

MATLAB

  • If the input is a compile-time empty cell array, then the size arguments must be constants.

  • Size arguments must have a fixed size.

  • For sparse matrices, the reshape function does not support trailing ones as inputs after the first two dimensions.

resnet18

Deep Learning Toolbox

resnet50

Deep Learning Toolbox

resnet101

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = resnet101 or by passing the resnet101 function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('resnet101')

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax resnet101('Weights','none') is not supported for GPU code generation.

rgb2gray

MATLAB

No known limitation

rgb2hsv

MATLAB

No known limitation

rgb2lab

Image Processing Toolbox

When generating code, all character vector input arguments must be compile-time constants.

rot90

MATLAB

Does not support cell arrays for the first argument.

round

MATLAB

  • Code generation supports only the syntax Y = round(X).

  • Code generation does not support char or logical data types for X.

sec

MATLAB

No known limitation

sech

MATLAB

No known limitation

segnetLayers

Computer Vision Toolbox

For code generation, you must first create a SegNet network by using the segnetLayers function. Then, use the trainNetwork function on the resulting lgraph object to train the network for segmentation. Once the network is trained and evaluated, you can generate code for the DAGNetwork object using GPU Coder.

selectStrongestBboxMulticlass

Computer Vision Toolbox

  • Code generation is only supported for numeric labels.

  • Code generation is not supported for rotated rectangle bounding box inputs.

SeriesNetwork

Deep Learning Toolbox

sin

MATLAB

No known limitation

single

MATLAB

No known limitation

sinh

MATLAB

No known limitation

size

MATLAB

No known limitation

sortrows

MATLAB

  • The first input argument must not be a cell array.

  • If A is complex with all zero imaginary parts, then MATLAB might convert A to real(A) before calling sortrows(A). In this case, MATLAB sorts the rows of A by real(A), but the generated code sorts the rows of A by abs(A). To make the generated code match MATLAB, use sortrows(real(A)) or sortrows(A,'ComparisonMethod','real').

sph2cart

MATLAB

No known limitation

sqrt

MATLAB

Simulation produces an error. Generated standalone code returns NaN when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

squeeze

MATLAB

Does not support cell arrays.

squeezenet

Deep Learning Toolbox

  • For code generation, you can load the network by using the syntax net = squeezenet or by passing the squeezenet function to coder.loadDeepLearningNetwork. For example: net = coder.loadDeepLearningNetwork('squeezenet').

    For more information, see Load Pretrained Networks for Code Generation.

  • The syntax squeezenet('Weights','none') is not supported for GPU code generation.

ssdObjectDetector

Computer Vision Toolbox

  • Only the detect method of the ssdObjectDetector is supported for code generation.

  • The bounding box output from code generation may have small numerical differences with the simulation results from MATLAB.

  • The code generator resizes the input image size to the detect method to that of the input layer size of the network. However, the bounding boxes output generated is with reference to the original input size.

  • The roi argument to the detect method must be a codegen constant (coder.const()) and a 1x4 vector.

  • Only the Threshold, SelectStrongest, MinSize, MaxSize, and MiniBatchSize Name-Value pairs are supported. All name-value pair must be compile time constant.

  • The channel and batch size of the input image must be fixed size.

  • The labels output is returned as a categorical array.

std

MATLAB

If you specify dim, then it must be a constant.

stft

Signal Processing Toolbox

  • The 'ConjugateSymmetric' argument is not supported for code generation.

  • Timetables are not supported for code generation.

stretchlim

Image Processing Toolbox

No known limitation

sub2ind

MATLAB

  • The first argument must be a valid size vector. Code generation does not support size vectors for arrays with more than intmax elements.

  • The generated code treats NaN inputs as out of range and throws a run-time error.

subsasgn

Fixed-Point Designer

No known limitation

subsindex

MATLAB

No known limitation

subsref

Fixed-Point Designer

No known limitation

sum

MATLAB

  • If you specify dim, then it must be a constant.

  • The outtype and nanflag options must be constant character vectors.

superpixels

Image Processing Toolbox

  • All character vector inputs must be compile-time constants.

  • The value of 'IsInputLab' (true or false) must be a compile-time constant.

svd

MATLAB

  • Code generation uses a different SVD implementation than MATLAB uses. Because the singular value decomposition is not unique, left and right singular vectors might differ from those computed by MATLAB.

  • When the input matrix contains a nonfinite value, the generated code does not issue an error. Instead, the output contains NaN values.

  • Code generation does not support sparse matrix inputs for this function.

swapbytes

MATLAB

Inheritance of the class of the input to swapbytes in a MATLAB Function block is supported only when the class of the input is double. For non-double inputs, the input port data types must be specified, not inherited.

tan

MATLAB

No known limitation

tanh

MATLAB

No known limitation

times

MATLAB

  • Multiplication of pure imaginary numbers by non-finite numbers might not match MATLAB. The code generator does not specialize multiplication by pure imaginary numbers—it does not eliminate calculations with the zero real part. For example, (Inf + 1i)*1i = (Inf*0 – 1*1) + (Inf*1 + 1*0)i = NaN + Infi.

  • If you use times with single type and double type operands, the generated code might not produce the same result as MATLAB.

trace

MATLAB

Code generation does not support sparse matrix inputs for this function.

transpose

MATLAB

No known limitation

tril

MATLAB

If you supply the argument that represents the order of the diagonal matrix, then it must be a real and scalar integer value.

triu

MATLAB

If you supply the argument that represents the order of the diagonal matrix, then it must be a real and scalar integer value.

true

MATLAB

Dimensions must be real, nonnegative, integers.

typecast

MATLAB

  • The value of the data type argument must be lowercase.

  • When you use typecast with inherited input port data types in MATLAB Function blocks, the software can throw a size error. To avoid this error, specify the block input port data types explicitly.

  • Integer input or result classes must map directly to a C type on the target hardware.

  • The input must be a variable-length vector or a fixed-size vector.

  • The output vector always has the same orientation as the input vector.

uint8, uint16, uint32, uint64

MATLAB

No known limitation

uminus

MATLAB

No known limitation

unetLayers

Computer Vision Toolbox

You can use the U-Net network for code generation. First, create the network using the unetLayers function. Then, use the trainNetwork function to train the network for segmentation. After training and evaluating the network, you can generate code for the DAGNetwork object by using GPU Coder.

uplus

MATLAB

No known limitation

vander

MATLAB

No known limitation

var

MATLAB

If specified, dim must be a constant.

vertcat

Fixed-Point Designer

No known limitation

vgg16

Deep Learning Toolbox

vgg19

Deep Learning Toolbox

watershed

Image Processing Toolbox

  • Supports only 2-D images

  • Supports only 4 or 8 connectivity

  • Supports images containing up to 65,535 regions

  • Output type is always uint16

xception

Deep Learning Toolbox

xor

MATLAB

No known limitation

ycbcr2rgb

Image Processing Toolbox

No known limitation

yolov2Layers

Computer Vision Toolbox

For code generation, you must first create a YOLO v2 network by using the yolov2Layers function. Then, use the trainYOLOv2ObjectDetector function on the resulting lgraph object to train the network for object detection. Once the network is trained and evaluated, you can generate code for the yolov2ObjectDetector object using GPU Coder.

yolov2ObjectDetector

Computer Vision Toolbox

  • Only the detect method of the yolov2ObjectDetector is supported for code generation.

  • The roi argument to the detect method must be a codegen constant (coder.const()) and a 1x4 vector.

  • Only the Threshold, SelectStrongest, MinSize, MaxSize, and MiniBatchSize Name-Value pairs are supported.

  • The height, width, channel, and batch size of the input image must be fixed size.

  • The minimum batch size value passed to detect method must be fixed size.

  • The labels output is returned as a cell array of character vectors, such as {'car','bus'}.

zeros

MATLAB

Dimensions must be nonnegative real integers.