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

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

    properties (State)
    end

    properties
        Vars
        NumDims
    end

    methods(Static, Hidden)
        % Specify the properties of the class that will not be modified
        % after the first assignment.
        function p = matlabCodegenNontunableProperties(~)
            p = {
                % Constants, i.e., Vars, NumDims and all learnables and states
                'Vars'
                'NumDims'
                };
        end
    end


    methods(Static, Hidden)
        % Instantiate a codegenable layer instance from a MATLAB layer instance
        function this_cg = matlabCodegenToRedirected(mlInstance)
            this_cg = EDHR_Net_SCNew.coder.ReshapeLayer1000(mlInstance);
        end
        function this_ml = matlabCodegenFromRedirected(cgInstance)
            this_ml = EDHR_Net_SCNew.ReshapeLayer1000(cgInstance.Name);
            if isstruct(cgInstance.Vars)
                names = fieldnames(cgInstance.Vars);
                for i=1:numel(names)
                    fieldname = names{i};
                    this_ml.Vars.(fieldname) = dlarray(cgInstance.Vars.(fieldname));
                end
            else
                this_ml.Vars = [];
            end
            this_ml.NumDims = cgInstance.NumDims;
        end
    end

    methods
        function this = ReshapeLayer1000(mlInstance)
            this.Name = mlInstance.Name;
            this.OutputNames = {'model_1_separable_4'};
            if isstruct(mlInstance.Vars)
                names = fieldnames(mlInstance.Vars);
                for i=1:numel(names)
                    fieldname = names{i};
                    this.Vars.(fieldname) = EDHR_Net_SCNew.coder.ops.extractIfDlarray(mlInstance.Vars.(fieldname));
                end
            else
                this.Vars = [];
            end

            this.NumDims = mlInstance.NumDims;
        end

        function [model_1_separable_4] = predict(this, main_input_0__)
            if isdlarray(main_input_0__)
                main_input_0_ = stripdims(main_input_0__);
            else
                main_input_0_ = main_input_0__;
            end
            main_input_0NumDims = 4;
            main_input_0 = EDHR_Net_SCNew.coder.ops.permuteInputVar(main_input_0_, [4 1 2 3], 4);

            [model_1_separable_4__, model_1_separable_4NumDims__] = ReshapeGraph1000(this, main_input_0, main_input_0NumDims, false);
            model_1_separable_4_ = EDHR_Net_SCNew.coder.ops.permuteOutputVar(model_1_separable_4__, [3 4 2 1], 4);

            model_1_separable_4 = dlarray(single(model_1_separable_4_), 'SSCB');
        end

        function [model_1_separable_4, model_1_separable_4NumDims1001] = ReshapeGraph1000(this, main_input_0, main_input_0NumDims, Training)

            % Execute the operators:
            % Reshape:
            [shape1000, model_1_separable_4NumDims] = EDHR_Net_SCNew.coder.ops.prepareReshapeArgs(main_input_0, this.Vars.new_shape__606, coder.const(main_input_0NumDims), 0);
            model_1_separable_4 = reshape(main_input_0, shape1000{:});

            % Set graph output arguments
            model_1_separable_4NumDims1001 = model_1_separable_4NumDims;

        end

    end

end