%% Check Custom Layer for Code Generation Compatibility
% Check the code generation compatibility of the custom layer codegenPreluLayer.
% The custom layer codegenPreluLayer, attached to this is example as a supporting file, applies the PReLU operation to  the input data. To access this layer, open this example as a live script.
% Create an instance of the layer and check its validity using checkLayer. Specify the valid input size as the size of a single observation of typical input to the layer. The layer expects 4-D array inputs, where the first three dimensions correspond to the height, width, and number of channels of the previous layer output, and the fourth dimension corresponds to the observations.
% Specify the typical size of the input of an observation and set the 'ObservationDimension' option to 4. To check for code generation compatibility, set the CheckCodegenCompatibility option to true. The checkLayer function does not check for functions that are not compatible with code generation. To check that the custom layer definition is supported for code generation, first use the Code Generation Readiness app. For more information, see Check Code by Using the Code Generation Readiness Tool.

layer = codegenPreluLayer(20,"prelu");
validInputSize = [24 24 20];
checkLayer(layer,validInputSize,ObservationDimension=4,CheckCodegenCompatibility=true)

% The function does not detect any issues with the layer.
% Copyright 2020 The MathWorks, Inc.