classdef(Abstract) Elementwise
    % Elementwise   Mixin to specify a custom layer that performs
    % element-wise operations.
    % Use this mixin in combination with nnet.layer.Layer. When used in a
    % network, the layer is optimized during inference, code generation,
    % or during network pruning. The layer must apply the same operation 
    % to each element of the input, independently (for example, ReLU, tanh, 
    % PreLU, addition). Further, the operation must depend only the element
    % value and must not depend on the shape or format of the input.
    % Examples of operations that are NOT element-wise include matrix
    % multiplication (*, mtimes), flatten, reshape, concatenation,
    % batchnorm.
    %
    % Example:
    %     % Define a layer that performs element-wise operations.
    %
    %     classdef myLayer < nnet.layer.Layer & nnet.layer.Elementwise
    %        methods
    %           function [Z1,...,Zm] = predict(layer,X1,...,Xn)
    %              % Forward input data through the layer at prediction time
    %              % and output the result.
    %              %
    %              % Inputs:
    %              %    layer       - Layer to forward propagate through
    %              %    X1, ..., Xn - Input data as formatted dlarray objects
    %              % Outputs:
    %              %    Z1, ..., Zm - Outputs of layer forward function
    %
    %              % Layer forward function for prediction goes here.
    %           end
    %        end
    %     end
    %
    % See also nnet.layer.Layer

    %#codegen
    
    %   Copyright 2021 The MathWorks, Inc.
    
end