Skip to content

Commit 1685e82

Browse files
committed
fix cherry-pick for 2.7
1 parent 86b8b4e commit 1685e82

File tree

2 files changed

+18
-46
lines changed

2 files changed

+18
-46
lines changed

aten/src/ATen/hip/impl/HIPAllocatorMasqueradingAsCUDA.h

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class HIPAllocatorMasqueradingAsCUDA final : public HIPCachingAllocator::HIPAllo
6767
allocator_->setMemoryFraction(fraction, device);
6868
}
6969

70-
void emptyCache(MempoolId_t mempool_id = {0, 0}) override {
71-
allocator_->emptyCache(mempool_id);
70+
void emptyCache() override {
71+
allocator_->emptyCache();
7272
}
7373

7474
void enable(bool value) override {
@@ -103,8 +103,8 @@ class HIPAllocatorMasqueradingAsCUDA final : public HIPCachingAllocator::HIPAllo
103103
allocator_->resetPeakStats(device);
104104
}
105105

106-
HIPCachingAllocator::SnapshotInfo snapshot(MempoolId_t mempool_id = {0, 0}) override {
107-
return allocator_->snapshot(mempool_id);
106+
HIPCachingAllocator::SnapshotInfo snapshot() override {
107+
return allocator_->snapshot();
108108
}
109109

110110
void beginAllocateToPool(
@@ -128,15 +128,10 @@ class HIPAllocatorMasqueradingAsCUDA final : public HIPCachingAllocator::HIPAllo
128128
return allocator_->getPoolUseCount(device, mempool_id);
129129
}
130130

131-
void createOrIncrefPool(
131+
void ensureExistsAndIncrefPool(
132132
c10::DeviceIndex device,
133-
MempoolId_t mempool_id,
134-
HIPAllocator* allocator = nullptr) override {
135-
allocator_->createOrIncrefPool(device, mempool_id, allocator);
136-
}
137-
138-
void setUseOnOOM(c10::DeviceIndex device, MempoolId_t mempool_id) override {
139-
allocator_->setUseOnOOM(device, mempool_id);
133+
MempoolId_t mempool_id) override {
134+
allocator_->ensureExistsAndIncrefPool(device, mempool_id);
140135
}
141136

142137
bool checkPoolLiveAllocations(
@@ -162,24 +157,15 @@ class HIPAllocatorMasqueradingAsCUDA final : public HIPCachingAllocator::HIPAllo
162157
bool enabled,
163158
HIPCachingAllocator::CreateContextFn context_recorder,
164159
size_t alloc_trace_max_entries,
165-
HIPCachingAllocator::RecordContext when,
166-
bool clearHistory) override {
167-
allocator_->recordHistory(enabled, context_recorder, alloc_trace_max_entries, when, clearHistory);
160+
HIPCachingAllocator::RecordContext when) override {
161+
allocator_->recordHistory(enabled, context_recorder, alloc_trace_max_entries, when);
168162
}
169163

170164
void recordAnnotation(
171165
const std::vector<std::pair<std::string, std::string>>& md) override {
172166
allocator_->recordAnnotation(md);
173167
}
174168

175-
void pushCompileContext(std::string& md) override {
176-
allocator_->pushCompileContext(md);
177-
}
178-
179-
void popCompileContext() override {
180-
allocator_->popCompileContext();
181-
}
182-
183169
void attachOutOfMemoryObserver(HIPCachingAllocator::OutOfMemoryObserver observer) override {
184170
allocator_->attachOutOfMemoryObserver(observer);
185171
}

aten/src/ATen/hip/impl/HIPCachingAllocatorMasqueradingAsCUDA.h

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ inline void setMemoryFraction(double fraction, c10::DeviceIndex device) {
3737
return get()->setMemoryFraction(fraction, device);
3838
}
3939

40-
inline void emptyCache(MempoolId_t mempool_id = {0, 0}) {
41-
return get()->emptyCache(mempool_id);
40+
inline void emptyCache() {
41+
return get()->emptyCache();
4242
}
4343

4444
inline void enable(bool value) {
@@ -70,8 +70,8 @@ inline void resetPeakStats(c10::DeviceIndex device) {
7070
return get()->resetPeakStats(device);
7171
}
7272

73-
inline HIPCachingAllocator::SnapshotInfo snapshot(MempoolId_t mempool_id = {0, 0}) {
74-
return get()->snapshot(mempool_id);
73+
inline HIPCachingAllocator::SnapshotInfo snapshot() {
74+
return get()->snapshot();
7575
}
7676

7777
inline std::shared_ptr<HIPCachingAllocator::AllocatorState> getCheckpointState(
@@ -101,25 +101,16 @@ inline void recordHistory(
101101
bool enabled,
102102
HIPCachingAllocator::CreateContextFn context_recorder,
103103
size_t alloc_trace_max_entries,
104-
HIPCachingAllocator::RecordContext when,
105-
bool clearHistory) {
104+
HIPCachingAllocator::RecordContext when) {
106105
return get()->recordHistory(
107-
enabled, context_recorder, alloc_trace_max_entries, when, clearHistory);
106+
enabled, context_recorder, alloc_trace_max_entries, when);
108107
}
109108

110109
inline void recordAnnotation(
111110
const std::vector<std::pair<std::string, std::string>>& md) {
112111
return get()->recordAnnotation(md);
113112
}
114113

115-
inline void pushCompileContext(std::string& md) {
116-
return get()->pushCompileContext(md);
117-
}
118-
119-
inline void popCompileContext() {
120-
return get()->popCompileContext();
121-
}
122-
123114
inline bool isHistoryEnabled() {
124115
return get()->isHistoryEnabled();
125116
}
@@ -144,15 +135,10 @@ inline void releasePool(c10::DeviceIndex device, MempoolId_t mempool_id) {
144135
return get()->releasePool(device, mempool_id);
145136
}
146137

147-
inline void createOrIncrefPool(
138+
inline void ensureExistsAndIncrefPool(
148139
c10::DeviceIndex device,
149-
MempoolId_t mempool_id,
150-
HIPCachingAllocator::HIPAllocator* allocator_ptr = nullptr) {
151-
get()->createOrIncrefPool(device, mempool_id, allocator_ptr);
152-
}
153-
154-
inline void setUseOnOOM(c10::DeviceIndex device, MempoolId_t mempool_id) {
155-
get()->setUseOnOOM(device, mempool_id);
140+
MempoolId_t mempool_id) {
141+
get()->ensureExistsAndIncrefPool(device, mempool_id);
156142
}
157143

158144
inline int getPoolUseCount(c10::DeviceIndex device, MempoolId_t mempool_id) {

0 commit comments

Comments
 (0)