neurosim / DNN_NeuroSim_V2.1

Benchmark framework of compute-in-memory based accelerators for deep neural network (on-chip training chip focused)
108 stars 50 forks source link

code after return #10

Open fishfishfishfishfish opened 2 years ago

fishfishfishfishfish commented 2 years ago

It may sound stupid. I found plenty of codes that appear after a function returns. For example in ProcessingUnit.cpp, line 700-712.

vector<vector<double> > CopySubArray(const vector<vector<double> > &orginal, int positionRow, int positionCol, int numRow, int numCol) {
    vector<vector<double> > copy;
    for (int i=0; i<numRow; i++) {
        vector<double> copyRow;
        for (int j=0; j<numCol; j++) {
            copyRow.push_back(orginal[positionRow+i][positionCol+j]);
        }
        copy.push_back(copyRow);
        copyRow.clear();
    }
    return copy;
    copy.clear();
} 

It seems that code after return (in the example copy.clear()) is useless. Does such code do any job? Why add such code? I'm so confused. Can anyone explain this to me? Thank you so much.