Skip to content
Merged
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
59 changes: 59 additions & 0 deletions onnxruntime/core/providers/migraphx/migraphx_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,22 @@
OrtHardwareDeviceType hw_type,
const OrtLogger& default_logger_in)
: ort_api{ort_api_in}, default_logger{default_logger_in}, ep_name{ep_name}, ort_hw_device_type{hw_type} {
ort_version_supported = ORT_API_VERSION; // set to the ORT version we were compiled with
GetName = GetNameImpl;
GetVendor = GetVendorImpl;
GetVendorId = GetVendorIdImpl;
GetVersion = GetVersionImpl;

GetSupportedDevices = GetSupportedDevicesImpl;
CreateEp = CreateEpImpl;
ReleaseEp = ReleaseEpImpl;

CreateAllocator = CreateAllocatorImpl;
ReleaseAllocator = ReleaseAllocatorImpl;
CreateDataTransfer = CreateDataTransferImpl;

IsStreamAware = IsStreamAwareImpl;
CreateSyncStreamForDevice = CreateSyncStreamForDeviceImpl;
}

// Returns the name for the EP. Each unique factory configuration must have a unique name.
Expand All @@ -201,6 +212,16 @@
return factory->vendor.c_str();
}

static uint32_t GetVendorIdImpl(const OrtEpFactory* this_ptr) noexcept {
const auto* factory = static_cast<const MigraphXEpFactory*>(this_ptr);
return factory->vendor_id;
}

static const char* GetVersionImpl(const OrtEpFactory* this_ptr) noexcept {
const auto* factory = static_cast<const MigraphXEpFactory*>(this_ptr);
return factory->version.c_str();
}

// Creates and returns OrtEpDevice instances for all OrtHardwareDevices that this factory supports.
// An EP created with this factory is expected to be able to execute a model with *all* supported
// hardware devices at once. A single instance of MigraphX EP is not currently setup to partition a model among
Expand Down Expand Up @@ -245,10 +266,48 @@
// no-op as we never create an EP here.
}

static OrtStatus* ORT_API_CALL CreateAllocatorImpl(OrtEpFactory* this_ptr,
const OrtMemoryInfo* /*memory_info*/,
const OrtKeyValuePairs* /*allocator_options*/,
OrtAllocator** allocator) noexcept {
auto* factory = static_cast<MigraphXEpFactory*>(this_ptr);

*allocator = nullptr;
return factory->ort_api.CreateStatus(
ORT_INVALID_ARGUMENT,
"CreateAllocator should not be called as we did not add OrtMemoryInfo to our OrtEpDevice.");
}

static void ORT_API_CALL ReleaseAllocatorImpl(OrtEpFactory* /*this_ptr*/, OrtAllocator* /*allocator*/) noexcept {
// should never be called as we don't implement CreateAllocator
}

static OrtStatus* ORT_API_CALL CreateDataTransferImpl(OrtEpFactory* /*this_ptr*/,
OrtDataTransferImpl** data_transfer) noexcept {
*data_transfer = nullptr; // not implemented
return nullptr;
}

static bool ORT_API_CALL IsStreamAwareImpl(const OrtEpFactory* /*this_ptr*/) noexcept {
return false;
}

static OrtStatus* ORT_API_CALL CreateSyncStreamForDeviceImpl(OrtEpFactory* this_ptr,
const OrtMemoryDevice* /*memory_device*/,
const OrtKeyValuePairs* /*stream_options*/,
OrtSyncStreamImpl** stream) noexcept {
auto* factory = static_cast<MigraphXEpFactory*>(this_ptr);

*stream = nullptr;
return factory->ort_api.CreateStatus(
ORT_INVALID_ARGUMENT, "CreateSyncStreamForDevice should not be called as IsStreamAware returned false.");
}

const OrtApi& ort_api;
const OrtLogger& default_logger;
const std::string ep_name;
const std::string vendor{"AMD"};
const std::string version{"1.0.0"}; // MigraphX EP version

Check warning on line 310 in onnxruntime/core/providers/migraphx/migraphx_provider_factory.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <string> for string [build/include_what_you_use] [4] Raw Output: onnxruntime/core/providers/migraphx/migraphx_provider_factory.cc:310: Add #include <string> for string [build/include_what_you_use] [4]

const uint32_t vendor_id{0x1002};
const OrtHardwareDeviceType ort_hw_device_type; // Supported OrtHardwareDevice
Expand Down
Loading