Skip to content

Commit 5ddc269

Browse files
lwfacebook-github-bot
authored andcommitted
Merge ivalue::Future's markCompleted and markCompletedWithDataPtrs (pytorch#56512)
Summary: Pull Request resolved: pytorch#56512 I don't know if there was a reason to keep them separate, but since the former deferred to the latter, it seems to me that we can get the exact same behavior by merging them and making the `data_ptrs` argument optional (by giving it a default value). ghstack-source-id: 127035767 Test Plan: Unit tests Reviewed By: mrshenli Differential Revision: D27861069 fbshipit-source-id: 93a49d6959b65a8d4ab9b31accce90bf30cd441e
1 parent af23822 commit 5ddc269

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

aten/src/ATen/core/ivalue_inl.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -357,22 +357,16 @@ struct C10_EXPORT ivalue::Future : c10::intrusive_ptr_target {
357357
}
358358

359359
/**
360-
* Explicitly mark the future as completed with the output value.
361-
*/
362-
void markCompleted(IValue value) {
363-
markCompletedWithDataPtrs(std::move(value));
364-
}
365-
366-
/**
367-
* Explicitly mark the future as completed with the output value and DataPtrs.
368-
* The data_ptrs contains storage pointers for all tensors in IValue, which
369-
* will be passed to preMarkCompletedHook. Some subclass, like CUDAFuture,
370-
* uses these DataPtrs to synchronize CUDA streams. You only need to provide
371-
* data_ptrs when 1) DataPtrs cannot be extracted through
372-
* IValue::getSubValues() or 2) customized DataPtrs extraction is more
360+
* Explicitly mark the future as completed with the output value. Optionally,
361+
* the storage pointers for all tensors in IValue can be passed as well, and
362+
* it will be passed to preMarkCompletedHook. Some subclass, like CUDAFuture,
363+
* uses these DataPtrs to synchronize CUDA streams. If data_ptrs isn't given
364+
* the subclass will attempt to extract it from the value, if it needs. Thus
365+
* one only needs to provide data_ptrs when 1) DataPtrs cannot be extracted
366+
* through IValue::getSubValues() or 2) customized DataPtrs extraction is more
373367
* efficient.
374368
*/
375-
void markCompletedWithDataPtrs(
369+
void markCompleted(
376370
IValue value,
377371
c10::optional<std::vector<std::reference_wrapper<const at::DataPtr>>>
378372
data_ptrs = c10::nullopt) {

torch/csrc/distributed/rpc/python_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ c10::intrusive_ptr<JitFuture> toPyJitFuture(
164164
return;
165165
}
166166

167-
child->markCompletedWithDataPtrs(ivalue, std::move(dataPtrs));
167+
child->markCompleted(ivalue, std::move(dataPtrs));
168168
}
169169
}));
170170
return child;

0 commit comments

Comments
 (0)