Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBCache unnecessary allocation #21

Open
alphaville opened this issue Jan 18, 2016 · 0 comments
Open

FBCache unnecessary allocation #21

alphaville opened this issue Jan 18, 2016 · 0 comments
Assignees

Comments

@alphaville
Copy link
Collaborator

In FBCache the following piece of code has the following problem:

if (m_prob.f1() != NULL) {
        Matrix gradf1_diff = Matrix(m_x_rows, m_x_cols);
        if (m_prob.L1() != NULL) {
            Matrix gradf1_L1diff = Matrix(m_prob.L1()->dimensionOut());
            gradf1_diff = m_prob.L1()->callAdjoint(gradf1_L1diff);
        } else {

        }
        Matrix::add(*m_gradFBEx, -1.0, gradf1_diff, 1.0 / gamma);
    }

The line

Matrix gradf1_diff = Matrix(m_x_rows, m_x_cols);

allocates memory for a dense matrix. Then, line

gradf1_diff = m_prob.L1()->callAdjoint(gradf1_L1diff);

computes the value of the adjoint of L1 at gradf1_L1diff and copies the value to gradf1_diff!
This happens with the invocation of Matrix::operator=. Notice that would be different to do

Matrix gradf1_diff = m_prob.L1()->callAdjoint(gradf1_L1diff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant