// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Licensed under the MIT License.
|
|
#include <string_view>
|
|
#define ORT_API_MANUAL_INIT
|
#include "onnxruntime_cxx_api.h"
|
#undef ORT_API_MANUAL_INIT
|
|
#include "ep_factory.h"
|
|
// To make symbols visible on macOS/iOS
|
#ifdef __APPLE__
|
#define EXPORT_SYMBOL __attribute__((visibility("default")))
|
#else
|
#define EXPORT_SYMBOL
|
#endif
|
|
extern "C" {
|
//
|
// Public symbols
|
//
|
EXPORT_SYMBOL OrtStatus* CreateEpFactories(const char* /*registration_name*/, const OrtApiBase* ort_api_base,
|
const OrtLogger* default_logger,
|
OrtEpFactory** factories, size_t max_factories, size_t* num_factories) {
|
const OrtApi* ort_api = ort_api_base->GetApi(ORT_API_VERSION);
|
const OrtEpApi* ep_api = ort_api->GetEpApi();
|
|
// Manual init for the C++ API
|
Ort::InitApi(ort_api);
|
|
std::unique_ptr<OrtEpFactory> factory = std::make_unique<ExampleKernelEpFactory>(*ort_api, *ep_api, *default_logger);
|
|
if (max_factories < 1) {
|
return ort_api->CreateStatus(ORT_INVALID_ARGUMENT,
|
"Not enough space to return EP factory. Need at least one.");
|
}
|
|
factories[0] = factory.release();
|
*num_factories = 1;
|
|
return nullptr;
|
}
|
|
EXPORT_SYMBOL OrtStatus* ReleaseEpFactory(OrtEpFactory* factory) {
|
delete static_cast<ExampleKernelEpFactory*>(factory);
|
return nullptr;
|
}
|
|
} // extern "C"
|