Don't return values in void functions (#164809)

This PR fixes returning values in void C++ functions.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/164809
Approved by: https://github.com/janeyx99
This commit is contained in:
Yuanyuan Chen
2025-10-08 01:04:11 +00:00
committed by PyTorch MergeBot
parent f713abab16
commit 43fc859625
24 changed files with 182 additions and 133 deletions

View File

@ -127,7 +127,7 @@ struct Event final {
}
void synchronize() const {
return impl_.synchronize();
impl_.synchronize();
}
private:

View File

@ -149,7 +149,7 @@ struct C10_API Storage {
}
void set_data_ptr_noswap(at::DataPtr&& data_ptr) const {
return storage_impl_->set_data_ptr_noswap(std::move(data_ptr));
storage_impl_->set_data_ptr_noswap(std::move(data_ptr));
}
DeviceType device_type() const {

View File

@ -94,11 +94,11 @@ class VirtualGuardImpl final : public DeviceGuardImplInterface {
}
void synchronizeEvent(void* event) const override {
return impl_->synchronizeEvent(event);
impl_->synchronizeEvent(event);
}
void synchronizeDevice(const DeviceIndex device_index) const override {
return impl_->synchronizeDevice(device_index);
impl_->synchronizeDevice(device_index);
}
private:

View File

@ -360,11 +360,11 @@ inline void* raw_alloc_with_stream(size_t nbytes, cudaStream_t stream) {
}
inline void raw_delete(void* ptr) {
return get()->raw_delete(ptr);
get()->raw_delete(ptr);
}
inline void init(int device_count) {
return get()->init(device_count);
get()->init(device_count);
}
inline double getMemoryFraction(c10::DeviceIndex device) {
@ -372,7 +372,7 @@ inline double getMemoryFraction(c10::DeviceIndex device) {
}
inline void setMemoryFraction(double fraction, c10::DeviceIndex device) {
return get()->setMemoryFraction(fraction, device);
get()->setMemoryFraction(fraction, device);
}
inline std::vector<StreamSegmentSize> getExpandableSegmentSizes(
@ -381,11 +381,11 @@ inline std::vector<StreamSegmentSize> getExpandableSegmentSizes(
}
inline void emptyCache(MempoolId_t mempool_id = {0, 0}) {
return get()->emptyCache(mempool_id);
get()->emptyCache(mempool_id);
}
inline void enable(bool value) {
return get()->enable(value);
get()->enable(value);
}
inline bool isEnabled() {
@ -393,7 +393,7 @@ inline bool isEnabled() {
}
inline void cacheInfo(c10::DeviceIndex device, size_t* largestBlock) {
return get()->cacheInfo(device, largestBlock);
get()->cacheInfo(device, largestBlock);
}
inline void* getBaseAllocation(void* ptr, size_t* size) {
@ -401,7 +401,7 @@ inline void* getBaseAllocation(void* ptr, size_t* size) {
}
inline void recordStream(const DataPtr& dataPtr, CUDAStream stream) {
return get()->recordStream(dataPtr, stream);
get()->recordStream(dataPtr, stream);
}
inline c10::CachingDeviceAllocator::DeviceStats getDeviceStats(
@ -410,11 +410,11 @@ inline c10::CachingDeviceAllocator::DeviceStats getDeviceStats(
}
inline void resetAccumulatedStats(c10::DeviceIndex device) {
return get()->resetAccumulatedStats(device);
get()->resetAccumulatedStats(device);
}
inline void resetPeakStats(c10::DeviceIndex device) {
return get()->resetPeakStats(device);
get()->resetPeakStats(device);
}
inline SnapshotInfo snapshot(MempoolId_t mempool_id = {0, 0}) {
@ -451,21 +451,21 @@ inline void recordHistory(
size_t alloc_trace_max_entries,
RecordContext when,
bool clearHistory) {
return get()->recordHistory(
get()->recordHistory(
enabled, context_recorder, alloc_trace_max_entries, when, clearHistory);
}
inline void recordAnnotation(
const std::vector<std::pair<std::string, std::string>>& md) {
return get()->recordAnnotation(md);
get()->recordAnnotation(md);
}
inline void pushCompileContext(std::string& md) {
return get()->pushCompileContext(md);
get()->pushCompileContext(md);
}
inline void popCompileContext() {
return get()->popCompileContext();
get()->popCompileContext();
}
inline bool isHistoryEnabled() {
@ -481,15 +481,15 @@ inline bool checkPoolLiveAllocations(
}
inline void attachOutOfMemoryObserver(OutOfMemoryObserver observer) {
return get()->attachOutOfMemoryObserver(std::move(observer));
get()->attachOutOfMemoryObserver(std::move(observer));
}
inline void attachAllocatorTraceTracker(AllocatorTraceTracker tracker) {
return get()->attachAllocatorTraceTracker(std::move(tracker));
get()->attachAllocatorTraceTracker(std::move(tracker));
}
inline void releasePool(c10::DeviceIndex device, MempoolId_t mempool_id) {
return get()->releasePool(device, mempool_id);
get()->releasePool(device, mempool_id);
}
inline void createOrIncrefPool(
c10::DeviceIndex device,
@ -533,7 +533,7 @@ inline cudaError_t memcpyAsync(
inline void enablePeerAccess(
c10::DeviceIndex dev,
c10::DeviceIndex dev_to_access) {
return get()->enablePeerAccess(dev, dev_to_access);
get()->enablePeerAccess(dev, dev_to_access);
}
} // namespace c10::cuda::CUDACachingAllocator

View File

@ -49,7 +49,7 @@ class DynamicBackendWrapper : public WaitCounterBackendIf {
void stop(std::chrono::steady_clock::time_point now, intptr_t ctx) noexcept
override {
return impl_.stop(
impl_.stop(
impl_.self,
std::chrono::duration_cast<std::chrono::microseconds>(
now.time_since_epoch())
@ -162,6 +162,6 @@ WaitCounterHandle::WaitGuard WaitCounterHandle::start() {
}
void WaitCounterHandle::stop(const SmallVector<intptr_t>& ctxs) {
return impl_.stop(ctxs);
impl_.stop(ctxs);
}
} // namespace c10::monitor