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

move has no effect on const variables #1333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

RSilicon
Copy link

Proposed changes

Remove std::move for const variables

Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@@ -977,7 +977,7 @@ std::vector<array> Convolution::vjp(
}
}

grad = slice(grad, std::move(starts), std::move(stops), stream());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those ones aren't const are they?

@@ -824,7 +824,7 @@ std::function<std::vector<array>(const std::vector<array>&)> compile(
// Mark the entry as not empty since we are about to fill it
entry.empty = false;
// Set the constants
entry.constants = std::move(constants);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one is not a constant is it?

Copy link
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first 2 were left

@@ -824,7 +824,7 @@ std::function<std::vector<array>(const std::vector<array>&)> compile(
// Mark the entry as not empty since we are about to fill it
entry.empty = false;
// Set the constants
entry.constants = std::move(constants);
entry.constants = constants;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constants are actually passed by value here or did I miss something.

@@ -331,7 +331,7 @@ void Softmax::eval_cpu(const std::vector<array>& inputs, array& out) {
return x_copy;
}
};
array in = check_input(std::move(inputs[0]));
array in = check_input(inputs[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this was left because initially it was written like this

array in_pre = inputs[0]; // copy first
auto in = check_input(std::move(in_pre));

@@ -977,7 +977,7 @@ std::vector<array> Convolution::vjp(
}
}

grad = slice(grad, std::move(starts), std::move(stops), stream());
grad = slice(grad, starts, stops, stream());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slice takes its arguments by value. What we should actually do is check if there are places that could pass by move yet pass by copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants