Fix usage of forwarding references (#161094)

I found a number of places that seem to want forwarding
references but the type signature does not reflect that

Pull Request resolved: https://github.com/pytorch/pytorch/pull/161094
Approved by: https://github.com/malfet
This commit is contained in:
Lakshay Garg
2025-09-04 16:34:36 +00:00
committed by PyTorch MergeBot
parent cc5bdd1240
commit 1ebd70d0c0
5 changed files with 6 additions and 6 deletions

View File

@ -374,7 +374,7 @@ static inline std::vector<c10::IValue> makeStack(Inputs&&... inputs) {
template <class... Args>
static inline std::vector<c10::IValue> callOpByHandle(
const c10::OperatorHandle& op,
Args... args) {
Args&&... args) {
auto stack = makeStack(std::forward<Args>(args)...);
c10::Dispatcher::singleton().callBoxed(op, &stack);
return stack;
@ -384,7 +384,7 @@ template <class... Args>
static inline std::vector<c10::IValue> callOpByName(
const char* func_name,
const char* overload_name,
Args... args) {
Args&&... args) {
const std::optional<c10::OperatorHandle> op_handle =
c10::Dispatcher::singleton().findSchema({func_name, overload_name});
assert(op_handle.has_value());

View File

@ -232,7 +232,7 @@ struct base {
return obj<T>::steal(self);
}
template<typename ... Args>
static obj<T> create(Args ... args) {
static obj<T> create(Args&&... args) {
auto self = alloc();
self->init(std::forward<Args>(args)...);
return self;

View File

@ -657,7 +657,7 @@ struct ThreadLocalResults {
}
template <CallType C, EventType E, typename Ephemeral, typename... Args>
TraceKey intern(Ephemeral ephemeral, Args... args) {
TraceKey intern(Ephemeral ephemeral, Args&&... args) {
static_assert(
Config<C>::event_type == E,
"ThreadLocalResults.intern called from the wrong typed context.");

View File

@ -267,7 +267,7 @@ class ExprEval {
}
template <typename T, typename... Ts>
T value(Ts... ts) {
T value(Ts&&... ts) {
call(std::forward<Ts>(ts)...);
return ret_value_.as<T>();
}

View File

@ -81,7 +81,7 @@ int filterCloseReturn(int r) {
// Wrap call to f(args) in loop to retry on EINTR
template <class F, class... Args>
ssize_t wrapNoInt(F f, Args... args) {
ssize_t wrapNoInt(F f, Args&&... args) {
ssize_t r = -1;
do {
r = f(std::forward<Args>(args)...);