Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/migraphx/migraphx_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ void* MIGraphXExternalAllocator::Reserve(size_t size) {
return p;
}

void* HIPPinnedAllocator::Alloc(size_t size) {
void* MIGraphXPinnedAllocator::Alloc(size_t size) {
void* p = nullptr;
if (size > 0) {
HIP_CALL_THROW(hipHostMalloc((void**)&p, size));
}
return p;
}

void HIPPinnedAllocator::Free(void* p) {
void MIGraphXPinnedAllocator::Free(void* p) {
HIP_CALL_THROW(hipHostFree(p));
}

Expand Down
11 changes: 5 additions & 6 deletions onnxruntime/core/providers/migraphx/migraphx_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ class MIGraphXExternalAllocator : public MIGraphXAllocator {
std::unordered_set<void*> reserved_;
};

// TODO: add a default constructor
class HIPPinnedAllocator : public IAllocator {
class MIGraphXPinnedAllocator final : public IAllocator {
public:
HIPPinnedAllocator(int device_id, const char* name)
MIGraphXPinnedAllocator(const int device_id, const char* name)
: IAllocator(
OrtMemoryInfo(name, OrtAllocatorType::OrtDeviceAllocator,
OrtMemoryInfo(name, OrtDeviceAllocator,
OrtDevice(OrtDevice::CPU, OrtDevice::MemType::HIP_PINNED, static_cast<OrtDevice::DeviceId>(device_id)),
device_id, OrtMemTypeCPUOutput)) {}

virtual void* Alloc(size_t size) override;
virtual void Free(void* p) override;
void* Alloc(size_t size) override;
void Free(void* p) override;
};

} // namespace onnxruntime
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ProviderInfo_MIGraphX_Impl final : ProviderInfo_MIGraphX {
}

std::unique_ptr<IAllocator> CreateMIGraphXPinnedAllocator(int16_t device_id, const char* name) override {
return std::make_unique<HIPPinnedAllocator>(device_id, name);
return std::make_unique<MIGraphXPinnedAllocator>(device_id, name);
}

} g_info;
Expand Down
Loading