classdef ReshapeLayer1002 < nnet.layer.Layer & nnet.layer.Formattable
    % A custom layer auto-generated while importing an ONNX network.

    %#ok<*PROPLC>
    %#ok<*NBRAK>
    %#ok<*INUSL>
    %#ok<*VARARG>
    properties (Learnable)
    end

    properties (State)
    end

    properties
        Vars
        NumDims
    end


    methods(Static, Hidden)
        % Specify the path to the class that will be used for codegen
        function name = matlabCodegenRedirect(~)
            name = 'EDHR_Net.coder.ReshapeLayer1002';
        end
    end


    methods
        function this = ReshapeLayer1002(name)
            this.Name = name;
            this.OutputNames = {'Identity_0'};
        end

        function [Identity_0] = predict(this, model_1_output_Relu_)
            if isdlarray(model_1_output_Relu_)
                model_1_output_Relu_ = stripdims(model_1_output_Relu_);
            end
            model_1_output_Relu_NumDims = 4;
            model_1_output_Relu_ = EDHR_Net.ops.permuteInputVar(model_1_output_Relu_, [4 3 1 2], 4);

            [Identity_0, Identity_0NumDims] = ReshapeGraph1004(this, model_1_output_Relu_, model_1_output_Relu_NumDims, false);
            Identity_0 = EDHR_Net.ops.permuteOutputVar(Identity_0, [2 3 4 1], 4);

            Identity_0 = dlarray(single(Identity_0), 'SSCB');
        end

        function [Identity_0] = forward(this, model_1_output_Relu_)
            if isdlarray(model_1_output_Relu_)
                model_1_output_Relu_ = stripdims(model_1_output_Relu_);
            end
            model_1_output_Relu_NumDims = 4;
            model_1_output_Relu_ = EDHR_Net.ops.permuteInputVar(model_1_output_Relu_, [4 3 1 2], 4);

            [Identity_0, Identity_0NumDims] = ReshapeGraph1004(this, model_1_output_Relu_, model_1_output_Relu_NumDims, true);
            Identity_0 = EDHR_Net.ops.permuteOutputVar(Identity_0, [2 3 4 1], 4);

            Identity_0 = dlarray(single(Identity_0), 'SSCB');
        end

        function [Identity_0, Identity_0NumDims1005] = ReshapeGraph1004(this, model_1_output_Relu_, model_1_output_Relu_NumDims, Training)

            % Execute the operators:
            % Reshape:
            [shape, Identity_0NumDims] = EDHR_Net.ops.prepareReshapeArgs(model_1_output_Relu_, this.Vars.new_shape__565, model_1_output_Relu_NumDims, 0);
            Identity_0 = reshape(model_1_output_Relu_, shape{:});

            % Set graph output arguments
            Identity_0NumDims1005 = Identity_0NumDims;

        end

    end

end